generic-xmlpickler

Generic generation of HXT XmlPickler instances using GHC Generics.

http://github.com/silkapp/generic-xmlpickler

Version on this page:0.1.0.5@rev:5
LTS Haskell 12.26:0.1.0.5@rev:8
Stackage Nightly 2018-09-28:0.1.0.5@rev:8
Latest on Hackage:0.1.0.6

See all snapshots generic-xmlpickler appears in

BSD-3-Clause licensed by Silk
Maintained by [email protected]
This version can be pinned in stack with:generic-xmlpickler-0.1.0.5@sha256:60b7d455c087425400e240ec1149e2d27fdd45725c6cdabed2ca71b39a2a1aa2,1505

Module documentation for 0.1.0.5

Used by 1 package in lts-9.21(full list with versions):

generic-xmlpickler

Build Status

This package allows you to automatically derive hxt picklers (conversions to and from xml) using GHC Generics. It has been ported from regular-xmlpickler

A simple example:

{-# LANGUAGE DeriveGeneric #-}

import GHC.Generics
import Data.Maybe (listToMaybe)
import Generics.XmlPickler (gxpickle)
import Text.XML.HXT.Arrow.Pickle (XmlPickler (..), showPickled, unpickleDoc)
import Text.XML.HXT.Parser.XmlParsec (xread)

data User = User
  { name  :: String
  , admin :: Bool
  } deriving (Show, Generic)

instance XmlPickler User where
  xpickle = gxpickle


userString :: String
userString = showPickled [] (User "Simon" True)
-- = "<user><name>Simon</name><admin>true</admin></user>"

user :: Maybe User
user = unpickleDoc xpickle =<< listToMaybe (xread "<user><name>Simon</name><admin>true</admin></user>")
-- = Just (User {name = "Simon", admin = True})

Changes

0.1.0.4

  • Fix build on GHC 8.

0.1.0.3

  • Allow generic-deriving 1.8.*.

0.1.0.2

  • Fix build on GHC-7.4

0.1.0.1

  • Add test suite and fix bugs that produced empty tag names.

0.1.0.0

  • Initial release, ported from regular-xmlpickler.