From 2ca1ca20bb34778df9470e964fc66ebfca0af4e8 Mon Sep 17 00:00:00 2001 From: Jon Kristensen Date: Sat, 1 Jun 2013 14:01:34 +0200 Subject: [PATCH] Remove IsString instance of `Jid' IsString instances are never supposed to fail, but parsing Strings to JIDs might. We might do this later with Template Haskell instead, or something. --- source/Network/Xmpp/Marshal.hs | 2 +- source/Network/Xmpp/Types.hs | 3 --- tests/Tests.hs | 6 +++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/source/Network/Xmpp/Marshal.hs b/source/Network/Xmpp/Marshal.hs index ff893da..da7dbd0 100644 --- a/source/Network/Xmpp/Marshal.hs +++ b/source/Network/Xmpp/Marshal.hs @@ -277,4 +277,4 @@ xpJid :: PU Text Jid xpJid = PU { unpickleTree = \input -> case jidFromText input of Nothing -> UnpickleError $ ErrorMessage "Could not parse JID." Just jid -> Result jid Nothing - , pickleTree = \input -> pack $ jidToText input } + , pickleTree = \input -> jidToText input } diff --git a/source/Network/Xmpp/Types.hs b/source/Network/Xmpp/Types.hs index dea21e7..45999cd 100644 --- a/source/Network/Xmpp/Types.hs +++ b/source/Network/Xmpp/Types.hs @@ -936,9 +936,6 @@ parseJid s = case jidFromText $ Text.pack s of Just jid -> jid Nothing -> error $ "Jid value (" ++ s ++ ") did not validate" -instance IsString Jid where - fromString = fromJust . jidFromText . Text.pack - -- | Converts a Text to a JID. jidFromText :: Text -> Maybe Jid jidFromText t = do diff --git a/tests/Tests.hs b/tests/Tests.hs index ba7dadb..41f334a 100644 --- a/tests/Tests.hs +++ b/tests/Tests.hs @@ -28,13 +28,13 @@ import System.Environment import System.Log.Logger testUser1 :: Jid -testUser1 = "echo1@species64739.dyndns.org/bot" +testUser1 = parseJid "echo1@species64739.dyndns.org/bot" testUser2 :: Jid -testUser2 = "echo2@species64739.dyndns.org/bot" +testUser2 = parseJid "echo2@species64739.dyndns.org/bot" supervisor :: Jid -supervisor = "uart14@species64739.dyndns.org" +supervisor = parseJid "uart14@species64739.dyndns.org" config = def{sessionStreamConfiguration = def{connectionDetails = UseHost "localhost" (PortNumber 5222)}}