packages feed

hexpat-pickle 0.4 → 0.5

raw patch · 3 files changed

+17/−13 lines, 3 filesdep ~hexpatPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: hexpat

API changes (from Hackage documentation)

- Text.XML.Expat.Pickle: defaultParserOptions :: ParseOptions tag text
- Text.XML.Expat.Pickle: type ParserOptions tag text = ParseOptions tag text
+ Text.XML.Expat.Pickle: ParseOptions :: Maybe Encoding -> Maybe (tag -> Maybe text) -> ParseOptions tag text
+ Text.XML.Expat.Pickle: data ParseOptions tag text :: * -> * -> *
+ Text.XML.Expat.Pickle: defaultParseOptions :: ParseOptions tag text
+ Text.XML.Expat.Pickle: entityDecoder :: ParseOptions tag text -> Maybe (tag -> Maybe text)
+ Text.XML.Expat.Pickle: overrideEncoding :: ParseOptions tag text -> Maybe Encoding
- Text.XML.Expat.Pickle: unpickleXML :: (GenericXMLString tag, GenericXMLString text) => ParserOptions tag text -> PU (Node tag text) a -> ByteString -> a
+ Text.XML.Expat.Pickle: unpickleXML :: (GenericXMLString tag, GenericXMLString text) => ParseOptions tag text -> PU (Node tag text) a -> ByteString -> a
- Text.XML.Expat.Pickle: unpickleXML' :: (GenericXMLString tag, GenericXMLString text) => ParserOptions tag text -> PU (Node tag text) a -> ByteString -> Either String a
+ Text.XML.Expat.Pickle: unpickleXML' :: (GenericXMLString tag, GenericXMLString text) => ParseOptions tag text -> PU (Node tag text) a -> ByteString -> Either String a
- Text.XML.Expat.Pickle: xpWithDefault :: a -> PU [t] a -> PU [t] a
+ Text.XML.Expat.Pickle: xpWithDefault :: a -> PU t a -> PU t a

Files

Text/XML/Expat/Pickle.hs view
@@ -131,8 +131,8 @@         UAttributes,         QAttributes,         NAttributes,-        ParserOptions(..),-        defaultParserOptions,+        ParseOptions(..),+        defaultParseOptions,         -- * Pickler adapters         xpRoot,         xpContent,@@ -179,11 +179,8 @@         GenericXMLString(..) --re-exported     ) where -import Text.XML.Expat.IO (Encoding) import Text.XML.Expat.Tree import Text.XML.Expat.Format-import Text.XML.Expat.Qualified-import Text.XML.Expat.Namespaced import Control.Exception.Extensible import Data.Maybe import Data.List@@ -241,7 +238,7 @@ -- XML document - lazy version.   In the event of an error, it throws either -- 'Text.XML.Expat.Tree.XMLParseException' or 'UnpickleException'. unpickleXML :: (GenericXMLString tag, GenericXMLString text) =>-               ParserOptions tag text+               ParseOptions tag text             -> PU (Node tag text) a             -> BL.ByteString             -> a@@ -251,7 +248,7 @@ -- | A helper that combines 'parseXML' with 'unpickleTree' to unpickle from an -- XML document - strict version. unpickleXML' :: (GenericXMLString tag, GenericXMLString text) =>-                ParserOptions tag text+                ParseOptions tag text              -> PU (Node tag text) a              -> B.ByteString              -> Either String a@@ -501,8 +498,15 @@ -- Unlike 'xpDefault', the default value /is/ encoded in the XML document. -- -- Note on lazy unpickle: The child is evaluated strictly.-xpWithDefault :: a -> PU [t] a -> PU [t] a-xpWithDefault a pa = xpTryCatch pa (xpLift a)+xpWithDefault :: a -> PU t a -> PU t a+xpWithDefault a pa = xpTryCatch pa (lift a)+  where+    -- use this instead of standard xpLift, allowing us to use a more general tree type+    lift a = PU+      { unpickleTree = const a+      , unpickleTree' = const $ Right a+      , pickleTree = error "xpWithDefault impossible" -- xpTryCatch never runs the second pickler+      }  -- | Convert XML text \<-\> a 2-tuple using the two arguments. xpPair :: PU [t] a -> PU [t] b -> PU [t] (a,b)
hexpat-pickle.cabal view
@@ -1,6 +1,6 @@ Cabal-Version: >= 1.2 Name: hexpat-pickle-Version: 0.4+Version: 0.5 Synopsis: XML picklers based on hexpat, source-code-similar to those of the HXT package Description:   A library of combinators that allows Haskell data structures to be pickled@@ -36,7 +36,7 @@ Library   Build-Depends:     base >= 3 && < 5,-    hexpat >= 0.11,+    hexpat >= 0.19,     utf8-string >= 0.3.3,     bytestring >= 0.9,     text >= 0.1,
test/tests.hs view
@@ -13,7 +13,7 @@ -- | Tests where input and XML output differ u2 :: (NFData a, Eq a, Show a) => String -> String -> String -> Either String a -> PU [UNode String] a -> IO () u2 title inXML chkXML inEVal inPU = do-    let inTree = parseThrowing (defaultParserOptions { parserEncoding = Just UTF8 }) (L.pack $ map c2w inXML)+    let inTree = parseThrowing (defaultParseOptions { defaultEncoding = Just UTF8 }) (L.pack $ map c2w inXML)         inTreeXML = formatTree' inTree         eVal = unpickleTree' (xpRoot inPU) inTree     assertEqual (title++" - strict unpickle") inEVal eVal@@ -21,7 +21,7 @@         Right val -> do             -- Make sure that the lazy unpickler gives the same result             assertEqual (title++" - lazy unpickle") val (unpickleTree (xpRoot inPU) inTree)-            let chkTree = parseThrowing (defaultParserOptions { parserEncoding = Just UTF8 }) (L.pack $ map c2w chkXML) :: UNode String+            let chkTree = parseThrowing (defaultParseOptions { defaultEncoding = Just UTF8 }) (L.pack $ map c2w chkXML) :: UNode String                 chkTreeXML = formatTree' chkTree                 outXML = pickleXML' (xpRoot inPU) val             assertEqual (title++" - pickle") chkTreeXML outXML