Generic generation of HXT XmlPickler instances using GHC Generics.

Version on this page:
LTS Haskell 11.1:
Stackage Nightly 2018-03-12:
Latest on Hackage:

See all snapshots generic-xmlpickler appears in

BSD3 licensed by Silk
Maintained by

Module documentation for


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


  • Fix build on GHC 8.

  • Allow generic-deriving 1.8.*.

  • Fix build on GHC-7.4

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

  • Initial release, ported from regular-xmlpickler.
Depends on 4 packages:
Used by 2 packages:
comments powered byDisqus