Created
October 28, 2017 09:32
-
-
Save afcondon/ae962a7647efec5eb77a6769417c6990 to your computer and use it in GitHub Desktop.
tiny fragment showing so-simple-they're-not-documented HXT pickler examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- targeting this XML: | |
-- <label id="123">do</label> | |
xpLabel :: PU Label | |
xpLabel = xpElem "label" $ | |
xpWrap ( uncurry Label | |
, \l -> (lid l, ltext l) | |
) $ | |
xpPair (xpAttr "id" xpickle) | |
(xpXmlText) | |
-- targetting this XML: | |
-- <description>Some stuff in here</description> | |
data Description = Description String deriving (Eq, Show) | |
instance XmlPickler Description where | |
xpickle = xpDescription | |
xpDescription :: PU Description | |
xpDescription | |
= xpElem "description" $ | |
xpWrap (\ n -> Description n | |
, \ (Description n) -> n ) $ | |
xpXmlText |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment