From 226e6481b90b844fb8efb9b23f4c80c485157611 Mon Sep 17 00:00:00 2001 From: Jon Kristensen Date: Tue, 19 Feb 2013 00:13:47 +0100 Subject: [PATCH] Export `Jid' helper functions, rename 'fromString(s)' to `fromText(s)' --- source/Network/Xmpp.hs | 2 ++ source/Network/Xmpp/Types.hs | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/source/Network/Xmpp.hs b/source/Network/Xmpp.hs index cd1daf0..f2e3a51 100644 --- a/source/Network/Xmpp.hs +++ b/source/Network/Xmpp.hs @@ -39,6 +39,8 @@ module Network.Xmpp , Jid(..) , isBare , isFull + , fromText + , fromTexts -- * 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 diff --git a/source/Network/Xmpp/Types.hs b/source/Network/Xmpp/Types.hs index e2eae15..b23ec9c 100644 --- a/source/Network/Xmpp/Types.hs +++ b/source/Network/Xmpp/Types.hs @@ -39,7 +39,8 @@ module Network.Xmpp.Types , Jid(..) , isBare , isFull - , fromString + , fromText + , fromTexts , StreamEnd(..) , InvalidXmppXml(..) ) @@ -875,14 +876,14 @@ instance IsString Jid where fromText :: Text -> Maybe Jid fromText t = do (l, d, r) <- eitherToMaybe $ AP.parseOnly jidParts t - fromStrings l d r + fromTexts 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. -fromStrings :: Maybe Text -> Text -> Maybe Text -> Maybe Jid -fromStrings l d r = do +fromTexts :: Maybe Text -> Text -> Maybe Text -> Maybe Jid +fromTexts l d r = do localPart <- case l of Nothing -> return Nothing Just l'-> do