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

13
source/Network/Xmpp/Marshal.hs

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

Loading…
Cancel
Save