HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulexmlgen-0.6.2.2Haskell2010

Text.XML.Generator

This module provides combinators for generating XML documents.

As an example, suppose you want to generate the following XML document:

<?xml version="1.0"?>
<people>
  <person age="32">Stefan</person>
  <person age="4">Judith</person>
</people>

Then you could use the following Haskell code:

let people = [("Stefan", "32"), ("Judith", "4")]
in doc defaultDocInfo $
     xelem "people" $
       xelems $ map ((name, age) -> xelem "person" (xattr "age" age <#> xtext name)) people
  • 10 types
  • 4 classes
  • 27 values
  • Packagexmlgen-0.6.2.2
  • Exports42
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceGenerator.hs

General

1 declaration
newtypenewtype Xml t
#

The type Xml t represent a piece of XML of type t, where t is usually one of Elem, Attr, or Doc.

Instances8Semigroup, Monoid, AddChildren, …

Documents

4 declarations
newtypenewtype Doc
#

A piece of XML at the document level.

Instances2Misc, Renderable
  • Misc DocDefined in xmlgen-0.6.2.2 · Text.XML.Generator
  • Renderable DocDefined in xmlgen-0.6.2.2 · Text.XML.Generator

The default document info (standalone, without document type, without content before/after the root element).

Namespaces

7 declarations
datadata Namespace
#

Type for representing presence or absence of an XML namespace.

Instances2Eq, Show
  • Eq NamespaceDefined in xmlgen-0.6.2.2 · Text.XML.Generator
  • Show NamespaceDefined in xmlgen-0.6.2.2 · Text.XML.Generator

A Namespace value denoting the default namespace.

  • For elements, this is the namespace currently mapped to the empty prefix.

  • For attributes, the default namespace does not carry any namespace information.

Elements

11 declarations
newtypenewtype Elem
#

A piece of XML at the element level.

Instances7Misc, Renderable, Semigroup, Monoid, AddChildren, …
classclass AddChildren c where
#

Class for adding children to an element.

The various instances of this class allow the addition of different kinds of children.

Instances7AddChildren, …
valuexelems :: [Xml Elem] -> Xml Elem
#

Merges a list of elements into a single piece of XML at the element level.

method(<>) :: a -> a -> a
#

An associative operation.

Examples
Example1 expression
[1,2,3] <> [4,5,6][1,2,3,4,5,6]
Example1 expression
Just [1, 2, 3] <> Just [4, 5, 6]Just [1,2,3,4,5,6]
Example1 expression
putStr "Hello, " <> putStrLn "World!"Hello, World!
value(<#>) :: a -> b -> (a, b)
#

Shortcut for constructing pairs. Used in combination with xelem for separating child-attributes from child-elements.

Attributes

6 declarations
newtypenewtype Attr
#

A piece of XML at the attribute level.

Instances6Renderable, Semigroup, Monoid, AddChildren
valuexattrs :: [Xml Attr] -> Xml Attr
#

Merge a list of attributes into a single piece of XML at the attribute level.

Text

4 declarations
valuexentityRef :: Name -> Xml Elem
#

Constructs a reference to the named entity. Note: no escaping is performed on the name of the entity

Other

2 declarations
classclass Renderable t => Misc t where
#

Class providing methods for adding processing instructions and comments.

Methods

  • xprocessingInstruction :: String -> String -> Xml t

    Constructs a processing instruction with the given target and content. Note: Rendering does not perform escaping on the target and the content.

  • xcomment :: String -> Xml t

    Constructs an XML comment. Note: No escaping is performed on the text of the comment.

Instances2Misc
  • Misc DocDefined in xmlgen-0.6.2.2 · Text.XML.Generator
  • Misc ElemDefined in xmlgen-0.6.2.2 · Text.XML.Generator

Rendering

3 declarations
classclass Renderable t where
#

Any type subject to rendering must implement this type class.

Instances3Renderable

XHTML documents

4 declarations