Hoogle Search

Within LTS Haskell 24.52 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. module Data.XML.Pickle

    This module provides XML picklers that plug into the XML tree of the xml-types package. This module was "inspired" by hexpat-pickle. The API differences between hexpat-pickle and this module include:

    • When unpickling, picklers will consume matching elmements so that they will be ignored by sucessive picklers. To circumvent this behaviour, use xpPeek
    • Wrappers like xpWrap are uncurried
    • There are no lazy unpicklers
    • Most unpicklers will produce an error when their child unpicklers fail to consume all elements. Use xpClean to discard those elements
    The data type PU t a represents both a pickler (converting Haskell data to XML) and an unpickler (XML to Haskell data), so your code only needs to be written once for both serialization and deserialization. The PU primitives, such as xpElem for XML elements, may be composed into complex arrangements using xpPair and other combinators. Most picklers will try to find the first match rather than failing when the first element doesn't match. This is why the target type often is a list. To prevent this behaviour and commit the pickler to the first element available, use xpIsolate. The top level of the document does not follow this rule, because it is a single node type. xpRoot is needed to adapt this to type [Node] for your pickler to use. You would typically define a pickler for a whole document with xpElem, then pickle it to a single Node with pickleTree (xpRoot myDocPickler) value. NB: Unresolved entities are considered an error and will trigger an exception When unpickling, the following invariant regarding the list of remaining elements should be observed:
    • The returned list should be a subset of or the initial list itself, that is, no elements should be added or changed
    • The relative order of elements should be preserved
    • Elements may, however, be removed from anywhere in the list
    Here is a simple example to get you started:
    {-# LANGUAGE OverloadedStrings #-}
    import Data.Text
    import Data.XML.Types
    import Data.XML.Pickle
    
    -- Person name, age and description
    data Person = Person Text Int Text
    
    xpPerson :: PU [Node] Person
    xpPerson =
    -- How to wrap and unwrap a Person
    xpWrap (\((name, age), descr) -> Person name age descr)
    (\(Person name age descr) -> ((name, age), descr)) $
    xpElem "person"
    (xpPair
    (xpAttr "name" xpId)
    (xpAttr "age" xpPrim))
    (xpContent xpId)
    
    people = [
    Person "Dave" 27 "A fat thin man with long short hair",
    Person "Jane" 21 "Lives in a white house with green windows"]
    
    main = do
    print $ pickle (xpRoot $ xpElemNodes "people" $ xpAll xpPerson) people
    
    Program output would be an xml-value equivalent to:
    <people>
    <person name="Dave" age="27">
    A fat thin man with long short hair
    </person>
    <person name="Jane" age="21">
    Lives in a white house with green windows
    </person>
    </people>
    
    Functions marked with compat are included for compatibility with hexpat-pickle.

  2. data PU t a

    xml-picklers Data.XML.Pickle

    No documentation available.

  3. PU :: (t -> UnpickleResult t a) -> (a -> t) -> PU t a

    xml-picklers Data.XML.Pickle

    No documentation available.

  4. type Pixel = Word64

    xmonad XMonad

    No documentation available.

  5. type Pixmap = XID

    xmonad XMonad

    No documentation available.

  6. type Place = CInt

    xmonad XMonad

    Place of window relative to siblings (used in Circulation requests or events)

  7. data Point

    xmonad XMonad

    counterpart of an X11 XPoint structure

  8. Point :: Position -> Position -> Point

    xmonad XMonad

    No documentation available.

  9. type PolygonShape = CInt

    xmonad XMonad

    No documentation available.

  10. type Position = Int32

    xmonad XMonad

    No documentation available.

Page 1094 of many | Previous | Next