Browse Source

Export `Jid' helper functions, rename 'fromString(s)' to `fromText(s)'

master
Jon Kristensen 13 years ago
parent
commit
226e6481b9
  1. 2
      source/Network/Xmpp.hs
  2. 9
      source/Network/Xmpp/Types.hs

2
source/Network/Xmpp.hs

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

9
source/Network/Xmpp/Types.hs

@ -39,7 +39,8 @@ module Network.Xmpp.Types
, Jid(..) , Jid(..)
, isBare , isBare
, isFull , isFull
, fromString , fromText
, fromTexts
, StreamEnd(..) , StreamEnd(..)
, InvalidXmppXml(..) , InvalidXmppXml(..)
) )
@ -875,14 +876,14 @@ instance IsString Jid where
fromText :: Text -> Maybe Jid fromText :: Text -> Maybe Jid
fromText t = do fromText t = do
(l, d, r) <- eitherToMaybe $ AP.parseOnly jidParts t (l, d, r) <- eitherToMaybe $ AP.parseOnly jidParts t
fromStrings l d r fromTexts 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.
fromStrings :: Maybe Text -> Text -> Maybe Text -> Maybe Jid fromTexts :: Maybe Text -> Text -> Maybe Text -> Maybe Jid
fromStrings l d r = do fromTexts 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