Browse Source

Fix Jid Read instance using error

(#102)
master
Philipp Balzarek 10 years ago
parent
commit
8d159048ec
  1. 23
      source/Network/Xmpp/Types.hs

23
source/Network/Xmpp/Types.hs

@ -894,16 +894,19 @@ instance Read Jid where
readsPrec _ s = do readsPrec _ s = do
-- Verifies that the first word is "parseJid", parses the second word and -- Verifies that the first word is "parseJid", parses the second word and
-- the remainder, if any, and produces these two values or fails. -- the remainder, if any, and produces these two values or fails.
let (s', r) = case lex s of case lex s of
[] -> error "Expected `parseJid \"<jid>\"'" [("parseJid", r')] ->
[("parseJid", r')] -> case lex r' of case lex r' of
[] -> error "Expected `parseJid \"<jid>\"'" [(s', r'')] ->
[(s'', r'')] -> (s'', r'') case (reads s') of
_ -> error "Expected `parseJid \"<jid>\"'" ((jidTxt,_):_) ->
_ -> error "Expected `parseJid \"<jid>\"'" case jidFromText (Text.pack jidTxt) of
-- Read the JID string (removes the quotes), validate, and return. Nothing -> []
[(parseJid (read s' :: String), r)] -- May fail with "Prelude.read: no parse" Just jid' -> [(jid', r'')]
-- or the `parseJid' error message (see below) _ -> []
_ -> []
_ -> []
#if WITH_TEMPLATE_HASKELL #if WITH_TEMPLATE_HASKELL

Loading…
Cancel
Save