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 @@ -43,8 +43,8 @@ module Network.Xmpp
, Jid(..)
, isBare
, isFull
, fromText
, fromTexts
, jidFromText
, jidFromTexts
-- * Stanzas
-- | 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

18
source/Network/Xmpp/Types.hs

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

Loading…
Cancel
Save