The regular-xmlpickler package

[Tags: bsd3, deprecated, library]

Deprecated in favor of generic-xmlpickler

Generic generation of HXT XmlPickler instances using Regular.


[Skip to ReadMe]

Properties

Versions0.1, 0.1.1, 0.1.2, 0.2
Change logCHANGELOG
Dependenciesbase (==4.*), hxt (>=9.2 && <9.4), regular (>=0.2 && <0.4), text [details]
LicenseBSD3
Copyright(c) 2014, Silk
AuthorSilk
Maintainercode@silk.co
CategoryXML, Data
Home pagehttp://github.com/silkapp/regular-xmlpickler
Source repositoryhead: git clone https://github.com/silkapp/regular-xmlpickler.git
UploadedFri Apr 4 10:10:19 UTC 2014 by ErikHesselink
DistributionsLTSHaskell:0.2, NixOS:0.2
Downloads1958 total (64 in last 30 days)
Votes
0 []
StatusDocs available [build log]
Successful builds reported [all 1 reports]

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for regular-xmlpickler-0.2

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