Skip to content

Instantly share code, notes, and snippets.

@afcondon
Created October 28, 2017 09:32
Show Gist options
  • Save afcondon/ae962a7647efec5eb77a6769417c6990 to your computer and use it in GitHub Desktop.
Save afcondon/ae962a7647efec5eb77a6769417c6990 to your computer and use it in GitHub Desktop.
tiny fragment showing so-simple-they're-not-documented HXT pickler examples
-- 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