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

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.


Generic generation of HXT XmlPickler instances using GHC Generics.

[Skip to ReadMe]


Dependenciesbase (>=4.5 && <4.14), generic-deriving (>=1.6 && <1.14), ghc-prim (>=0.2 && <0.5), hxt (>=9.2 && <9.4), text [details]
Copyright(c) 2015, Silk
CategoryXML, Data
Home page
Source repositoryhead: git clone
UploadedWed Nov 13 17:16:43 UTC 2019 by AdamBergmark




Maintainers' corner

For package maintainers and hackage trustees

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