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

[ bsd3, data, library, xml ] [ Propose Tags ] [ Report a vulnerability ]

Generic generation of HXT XmlPickler instances using GHC Generics.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.1.0.4, 0.1.0.5, 0.1.0.6
Change log CHANGELOG.md
Dependencies base (>=4.5 && <4.14), generic-deriving (>=1.6 && <1.14), ghc-prim (>=0.2 && <0.5), hxt (>=9.2 && <9.4), text [details]
Tested with ghc ==7.4.2, ghc ==7.6.3, ghc ==7.8.4, ghc ==7.10.3, ghc ==8.0.2, ghc ==8.2.1, ghc ==8.4.4, ghc ==8.6.5, ghc ==8.8.1
License BSD-3-Clause
Copyright (c) 2015, Silk
Author Silk
Maintainer code@silk.co
Category XML, Data
Home page http://github.com/silkapp/generic-xmlpickler
Source repo head: git clone https://github.com/silkapp/regular-xmlpickler.git
Uploaded by AdamBergmark at 2019-11-13T17:16:49Z
Distributions
Reverse Dependencies 3 direct, 6 indirect [details]
Downloads 6924 total (9 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-11-13 [all 1 reports]

Readme for generic-xmlpickler-0.1.0.6

[back to package description]

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