    {-# LANGUAGE FlexibleInstances #-}
    --------------------------------------------------------------------
    -- |
    -- Module    : Text.XML.Light
    -- Copyright : (c) Galois, Inc. 2007
    -- License   : BSD3
    --
    -- Maintainer: Iavor S. Diatchki <diatchki@galois.com>
    -- Stability : provisional
    -- Portability: portability
    --
    -- A lightweight XML parsing, filtering and generating library.
    --
    -- This module reexports functions from:
    --
    -- * "Text.XML.Light.Types"
    --
    -- * "Text.XML.Light.Proc"
    --
    -- * "Text.XML.Light.Input"
    --
    -- * "Text.XML.Light.Output"
    --

    module Text.XML.Light (

        module Text.XML.Light,
        module Text.XML.Light.Types,
        module Text.XML.Light.Proc,
        module Text.XML.Light.Input,
        module Text.XML.Light.Output

      ) where

    import Text.XML.Light.Types
    import Text.XML.Light.Proc
    import Text.XML.Light.Input
    import Text.XML.Light.Output

    -- | Add an attribute to an element.
    add_attr :: Attr -> Element -> Element
    add_attr :: Attr -> Element -> Element
    add_attr Attr
    a Element
    e = [Attr] -> Element -> Element
    add_attrs [Attr
    a] Element
    e

    -- | Add some attributes to an element.
    add_attrs :: [Attr] -> Element -> Element
    add_attrs :: [Attr] -> Element -> Element
    add_attrs [Attr]
    as Element
    e = Element
    e { elAttribs = as ++ elAttribs e }

    -- | Create an unqualified name.
    unqual :: String -> QName
    unqual :: String -> QName
    unqual String
    x = QName
    blank_name { qName = x }

    -- | A smart element constructor which uses the type of its argument
    -- to determine what sort of element to make.
    class Node t where
      node :: QName -> t -> Element

    instance Node ([Attr],[Content]) where
      node :: QName -> ([Attr], [Content]) -> Element
    node QName
    n ([Attr]
    attrs,[Content]
    cont) = Element
    blank_element { elName     = n
                                          , elAttribs  = attrs
                                          , elContent  = cont
                                          }

    instance Node [Attr]             where node :: QName -> [Attr] -> Element
    node QName
    n [Attr]
    as   = QName -> ([Attr], [Content]) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([Attr]
    as,[]::[Content])
    instance Node Attr               where node :: QName -> Attr -> Element
    node QName
    n Attr
    a    = QName -> [Attr] -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n [Attr
    a]
    instance Node ()                 where node :: QName -> () -> Element
    node QName
    n ()   = QName -> [Attr] -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([]::[Attr])

    instance Node [Content]          where node :: QName -> [Content] -> Element
    node QName
    n [Content]
    cs     = QName -> ([Attr], [Content]) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([]::[Attr],[Content]
    cs)
    instance Node Content            where node :: QName -> Content -> Element
    node QName
    n Content
    c      = QName -> [Content] -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n [Content
    c]
    instance Node ([Attr],Content)   where node :: QName -> ([Attr], Content) -> Element
    node QName
    n ([Attr]
    as,Content
    c) = QName -> ([Attr], [Content]) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([Attr]
    as,[Content
    c])
    instance Node (Attr,Content)     where node :: QName -> (Attr, Content) -> Element
    node QName
    n (Attr
    a,Content
    c)  = QName -> ([Attr], [Content]) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([Attr
    a],[Content
    c])

    instance Node ([Attr],[Element]) where
      node :: QName -> ([Attr], [Element]) -> Element
    node QName
    n ([Attr]
    as,[Element]
    cs) = QName -> ([Attr], [Content]) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([Attr]
    as,(Element -> Content) -> [Element] -> [Content]
    forall a b. (a -> b) -> [a] -> [b]
    map Element -> Content
    Elem [Element]
    cs)

    instance Node ([Attr],Element)   where node :: QName -> ([Attr], Element) -> Element
    node QName
    n ([Attr]
    as,Element
    c) = QName -> ([Attr], [Element]) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([Attr]
    as,[Element
    c])
    instance Node (Attr,Element)     where node :: QName -> (Attr, Element) -> Element
    node QName
    n (Attr
    a,Element
    c)  = QName -> ([Attr], Element) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([Attr
    a],Element
    c)
    instance Node ([Element])        where node :: QName -> [Element] -> Element
    node QName
    n [Element]
    es     = QName -> ([Attr], [Element]) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([]::[Attr],[Element]
    es)
    instance Node (Element)          where node :: QName -> Element -> Element
    node QName
    n Element
    e      = QName -> [Element] -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n [Element
    e]

    instance Node ([Attr],[CData])   where
      node :: QName -> ([Attr], [CData]) -> Element
    node QName
    n ([Attr]
    as,[CData]
    cs) = QName -> ([Attr], [Content]) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([Attr]
    as,(CData -> Content) -> [CData] -> [Content]
    forall a b. (a -> b) -> [a] -> [b]
    map CData -> Content
    Text [CData]
    cs)

    instance Node ([Attr],CData)     where node :: QName -> ([Attr], CData) -> Element
    node QName
    n ([Attr]
    as,CData
    c) = QName -> ([Attr], [CData]) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([Attr]
    as,[CData
    c])
    instance Node (Attr,CData)       where node :: QName -> (Attr, CData) -> Element
    node QName
    n (Attr
    a,CData
    c)  = QName -> ([Attr], CData) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([Attr
    a],CData
    c)
    instance Node [CData]            where node :: QName -> [CData] -> Element
    node QName
    n [CData]
    es     = QName -> ([Attr], [CData]) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([]::[Attr],[CData]
    es)
    instance Node CData              where node :: QName -> CData -> Element
    node QName
    n CData
    e      = QName -> [CData] -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n [CData
    e]

    instance Node ([Attr],String)    where
      node :: QName -> ([Attr], String) -> Element
    node QName
    n ([Attr]
    as,String
    t) = QName -> ([Attr], CData) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([Attr]
    as,CData
    blank_cdata { cdData = t })

    instance Node (Attr,String)      where node :: QName -> (Attr, String) -> Element
    node QName
    n (Attr
    a,String
    t)  = QName -> ([Attr], String) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([Attr
    a],String
    t)
    instance Node [Char]             where node :: QName -> String -> Element
    node QName
    n String
    t      = QName -> ([Attr], String) -> Element
    forall t. Node t => QName -> t -> Element
    node QName
    n ([]::[Attr],String
    t)

    -- | Create node with unqualified name
    unode :: Node t => String -> t -> Element
    unode :: forall t. Node t => String -> t -> Element
    unode = QName -> t -> Element
    forall t. Node t => QName -> t -> Element
    node (QName -> t -> Element)
    -> (String -> QName) -> String -> t -> Element
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> QName
    unqual