From 789881254edd4838aeca76b7621bb5777cf24cab Mon Sep 17 00:00:00 2001
From: Philipp Balzarek
Date: Sun, 9 Jun 2013 23:59:02 +0200
Subject: [PATCH] avoid direct use of PU constructor
Building picklers from predefined combinators is more robust against possible future API changes.
---
pontarius-xmpp.cabal | 2 +-
source/Network/Xmpp/Marshal.hs | 13 ++++++++-----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/pontarius-xmpp.cabal b/pontarius-xmpp.cabal
index 3e9aa3c..3322b92 100644
--- a/pontarius-xmpp.cabal
+++ b/pontarius-xmpp.cabal
@@ -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
diff --git a/source/Network/Xmpp/Marshal.hs b/source/Network/Xmpp/Marshal.hs
index da7dbd0..ce68966 100644
--- a/source/Network/Xmpp/Marshal.hs
+++ b/source/Network/Xmpp/Marshal.hs
@@ -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
"{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