Browse Source

avoid direct use of PU constructor

Building picklers from predefined combinators is more robust against possible future API changes.
master
Philipp Balzarek 13 years ago
parent
commit
789881254e
  1. 2
      pontarius-xmpp.cabal
  2. 13
      source/Network/Xmpp/Marshal.hs

2
pontarius-xmpp.cabal

@ -59,7 +59,7 @@ Library
, void >=0.5.5 , void >=0.5.5
, xml-types >=0.3.1 , xml-types >=0.3.1
, xml-conduit >=1.0 , xml-conduit >=1.0
, xml-picklers >=0.3.2 , xml-picklers >=0.3.3
Exposed-modules: Network.Xmpp Exposed-modules: Network.Xmpp
, Network.Xmpp.IM , Network.Xmpp.IM
, Network.Xmpp.Internal , Network.Xmpp.Internal

13
source/Network/Xmpp/Marshal.hs

@ -2,7 +2,9 @@
-- respectively. By convensions, pickler/unpickler ("PU") function names start -- respectively. By convensions, pickler/unpickler ("PU") function names start
-- out with "xp". -- out with "xp".
{-# Language OverloadedStrings, ViewPatterns, NoMonomorphismRestriction #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# OPTIONS_HADDOCK hide #-} {-# OPTIONS_HADDOCK hide #-}
@ -274,7 +276,8 @@ xpStreamFeatures = ("xpStreamFeatures","") <?> xpWrap
"{urn:ietf:params:xml:ns:xmpp-sasl}mechanism" (xpContent xpId)) "{urn:ietf:params:xml:ns:xmpp-sasl}mechanism" (xpContent xpId))
xpJid :: PU Text Jid xpJid :: PU Text Jid
xpJid = PU { unpickleTree = \input -> case jidFromText input of xpJid = ("xpJid", "") <?>
Nothing -> UnpickleError $ ErrorMessage "Could not parse JID." xpPartial ( \input -> case jidFromText input of
Just jid -> Result jid Nothing Nothing -> Left "Could not parse JID."
, pickleTree = \input -> jidToText input } Just jid -> Right jid)
jidToText

Loading…
Cancel
Save