The generic-xmlpickler package

[Tags:bsd3, library, test]

Generic generation of HXT XmlPickler instances using GHC Generics.


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.5
Change log CHANGELOG.md
Dependencies base (>=4.5 && <4.11), generic-deriving (>=1.6 && <1.12), ghc-prim (>=0.2 && <0.5), hxt (>=9.2 && <9.4), text [details]
License BSD3
Copyright (c) 2015, Silk
Author Silk
Maintainer code@silk.co
Category XML, Data
Home page http://github.com/silkapp/generic-xmlpickler
Source repository head: git clone https://github.com/silkapp/regular-xmlpickler.git
Uploaded Mon Feb 29 21:43:48 UTC 2016 by ErikHesselink
Updated Thu Jul 27 16:46:12 UTC 2017 by AdamBergmark to revision 2
Distributions LTSHaskell:0.1.0.5, NixOS:0.1.0.5, Stackage:0.1.0.5, Tumbleweed:0.1.0.5
Downloads 1084 total (35 in the last 30 days)
Votes
0 []
Status Docs available [build log]
Last success reported on 2016-02-29 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for generic-xmlpickler

Readme for generic-xmlpickler-0.1.0.5

generic-xmlpickler

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