generic-xmlpickler: Generic generation of HXT XmlPickler instances using GHC Generics.

[ bsd3, data, library, xml ] [ Propose Tags ]

Generic generation of HXT XmlPickler instances using GHC Generics.

[Skip to Readme]




Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],,,,,,
Change log
Dependencies base (>=4.6 && <4.9), generic-deriving (>=1.6 && <1.8), hxt (>=9.2 && <9.4), text [details]
License BSD-3-Clause
Copyright (c) 2015, Silk
Author Silk
Revised Revision 1 made by AdamBergmark at 2015-05-19T17:28:57Z
Category XML, Data
Home page
Source repo head: git clone
Uploaded by AdamBergmark at 2015-03-01T17:12:06Z
Reverse Dependencies 3 direct, 6 indirect [details]
Downloads 6837 total (13 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-03-01 [all 1 reports]

Readme for generic-xmlpickler-

[back to package description]


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})