packages feed

xml-picklers 0.3.1 → 0.3.2

raw patch · 2 files changed

+29/−3 lines, 2 files

Files

src/Data/XML/Pickle.hs view
@@ -127,6 +127,7 @@   , xpElems    -- ** Character Content   , xpContent+  , xpBool    -- * Pickler combinators    -- ** choice   , xpOption@@ -385,6 +386,32 @@ xpTrees :: PU a a xpTrees = xpId +-- | Converts Booleans to XML boolean values+--+-- * true and 1 are read as True+--+-- * false and 0 are read as False+--+-- * all other values generate an unpickle error+--+-- Will always generate true or false (not 0 or 1) when pickling+xpBool :: PU Text Bool+xpBool = ("xpBool" ,"") <?+> PU+          { unpickleTree =+                 \v -> case () of ()+                                      | v `elem` ["true",  "1"] ->+                                          Result True Nothing+                                      | v `elem` ["false", "0"] ->+                                          Result False Nothing+                                      | otherwise -> UnpickleError+                                                     (ErrorMessage $+                                                      "Not a boolean value: "+                                                      `Text.append` v)+          , pickleTree = \v -> case v of+                     True -> "true"+                     False -> "false"+          }+ -- | Apply a bijection before pickling / after unpickling xpWrap :: (a -> b) -> (b -> a) -> PU t a -> PU t b xpWrap to from xp = ("xpWrap","") <?+>@@ -959,8 +986,7 @@                             child' xp [y]                     } --+-- | Ignore input/output and replace with constant values xpConst :: a -> PU t () -> PU t a xpConst c xp = ("xpConst" ,"") <?> xpWrap (const c) (const ()) xp 
xml-picklers.cabal view
@@ -1,6 +1,6 @@ Cabal-Version: >= 1.2 Name: xml-picklers-Version: 0.3.1+Version: 0.3.2 Synopsis: XML picklers based on xml-types, ported from hexpat-pickle Description:   A library of combinators that allows Haskell data structures to be pickled