regular-xmlpickler: Generic generation of HXT XmlPickler instances using Regular.

[ bsd3, data, deprecated, library, xml ] [ Propose Tags ] [ Report a vulnerability ]
Deprecated in favor of generic-xmlpickler

Generic generation of HXT XmlPickler instances using Regular.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1, 0.1.1, 0.1.2, 0.2
Change log CHANGELOG
Dependencies base (>=4 && <5), hxt (>=9.2 && <9.4), regular (>=0.2 && <0.4), text [details]
License BSD-3-Clause
Copyright (c) 2014, Silk
Author Silk
Maintainer code@silk.co
Category XML, Data
Home page http://github.com/silkapp/regular-xmlpickler
Source repo head: git clone https://github.com/silkapp/regular-xmlpickler.git
Uploaded by ErikHesselink at 2014-04-04T10:10:19Z
Distributions
Reverse Dependencies 4 direct, 5 indirect [details]
Downloads 4564 total (15 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Successful builds reported [all 1 reports]

Readme for regular-xmlpickler-0.2

[back to package description]

This package allows you to automatically derive hxt picklers (conversions to and from xml) using the regular generics package.

A simple example:

{-# LANGUAGE TemplateHaskell
           , EmptyDataDecls
           , TypeFamilies
           #-}

import Generics.Regular (deriveAll, PF)
import Text.XML.HXT.Arrow.Pickle (XmlPickler (..))
import Generics.Regular.XmlPickler (gxpickle)

data User = User
  { name  :: String
  , admin :: Bool
  }

-- Derive Regular instance.
deriveAll ''User "PFUser"
type instance PF User = PFUser

-- Define generic pickler instance.
instance XmlPickler User where
  xpickle = gxpickle

Now you can use the functionality from Text.XML.HXT.Arrow.Pickle. For example:

> showPickled [] (User "Simon" True)

"<user><name>Simon</name><admin>true</admin></user>"

> unpickleDoc xpickle $ head $ xread "<user><name>Simon</name><admin>true</admin></user>" :: Maybe User

Just (User {name = "Simon", admin = True})