Browse Source

Rename fromText(s) to jidFromText(s)

master
Jon Kristensen 13 years ago
parent
commit
2143ad17ff
  1. 4
      source/Network/Xmpp.hs
  2. 18
      source/Network/Xmpp/Types.hs

4
source/Network/Xmpp.hs

@ -43,8 +43,8 @@ module Network.Xmpp
, Jid(..) , Jid(..)
, isBare , isBare
, isFull , isFull
, fromText , jidFromText
, fromTexts , jidFromTexts
-- * Stanzas -- * Stanzas
-- | The basic protocol data unit in XMPP is the XML stanza. The stanza is -- | The basic protocol data unit in XMPP is the XML stanza. The stanza is
-- essentially a fragment of XML that is sent over a stream. @Stanzas@ come in -- essentially a fragment of XML that is sent over a stream. @Stanzas@ come in

18
source/Network/Xmpp/Types.hs

@ -40,8 +40,8 @@ module Network.Xmpp.Types
, Jid(..) , Jid(..)
, isBare , isBare
, isFull , isFull
, fromText , jidFromText
, fromTexts , jidFromTexts
, StreamEnd(..) , StreamEnd(..)
, InvalidXmppXml(..) , InvalidXmppXml(..)
, Hostname(..) , Hostname(..)
@ -877,25 +877,25 @@ instance Show Jid where
maybe "" (('/' :) . Text.unpack) res maybe "" (('/' :) . Text.unpack) res
instance Read Jid where instance Read Jid where
readsPrec _ x = case fromText (Text.pack x) of readsPrec _ x = case jidFromText (Text.pack x) of
Nothing -> [] Nothing -> []
Just j -> [(j,"")] Just j -> [(j,"")]
instance IsString Jid where instance IsString Jid where
fromString = fromJust . fromText . Text.pack fromString = fromJust . jidFromText . Text.pack
-- | Converts a Text to a JID. -- | Converts a Text to a JID.
fromText :: Text -> Maybe Jid jidFromText :: Text -> Maybe Jid
fromText t = do jidFromText t = do
(l, d, r) <- eitherToMaybe $ AP.parseOnly jidParts t (l, d, r) <- eitherToMaybe $ AP.parseOnly jidParts t
fromTexts l d r jidFromTexts l d r
where where
eitherToMaybe = either (const Nothing) Just eitherToMaybe = either (const Nothing) Just
-- | Converts localpart, domainpart, and resourcepart strings to a JID. Runs the -- | Converts localpart, domainpart, and resourcepart strings to a JID. Runs the
-- appropriate stringprep profiles and validates the parts. -- appropriate stringprep profiles and validates the parts.
fromTexts :: Maybe Text -> Text -> Maybe Text -> Maybe Jid jidFromTexts :: Maybe Text -> Text -> Maybe Text -> Maybe Jid
fromTexts l d r = do jidFromTexts l d r = do
localPart <- case l of localPart <- case l of
Nothing -> return Nothing Nothing -> return Nothing
Just l'-> do Just l'-> do

Loading…
Cancel
Save