HaXml-1.25.14: Utilities for manipulating XML documents

Safe Haskell | Safe-Inferred
Language | Haskell98

Text.XML.HaXml.DtdToHaskell.TypeDef

Contents

- Internal representation of types
- Pretty-print a TypeDef
- Name mangling

Description

Defines an internal representation of Haskell data/newtype definitions that correspond to the XML DTD types, and provides pretty-printers to convert these types into the `Doc` type of Text.PrettyPrint.HughesPJ.

Synopsis

- data TypeDef
  - = DataDef Bool Name AttrFields Constructors
  - | EnumDef Name [Name]
- type Constructors = [(Name, [StructType])]
- type AttrFields = [(Name, StructType)]
- data StructType
  - = Maybe StructType
  - | Defaultable StructType String
  - | List StructType
  - | List1 StructType
  - | Tuple [StructType]
  - | OneOf [StructType]
  - | Any
  - | StringMixed
  - | String
  - | Defined Name
- ppTypeDef :: TypeDef -> Doc
- ppHName :: Name -> Doc
- ppXName :: Name -> Doc
- ppAName :: Name -> Doc
- data Name = Name {
  - xName :: String
  - hName :: String
  }
- name :: String -> Name
- name_ :: String -> Name
- name_a :: String -> String -> Name
- name_ac :: String -> String -> String -> Name
- name_f :: String -> String -> Name
- mangle :: String -> String
- manglef :: String -> String

# Internal representation of types

data TypeDef Source #

Constructors

DataDef Bool Name AttrFields Constructors | Bool for main/aux.
EnumDef Name [Name] |

#### Instances

Instances details

Eq TypeDef Source # |
Instance details Defined in Text.XML.HaXml.DtdToHaskell.TypeDef Methods (==) :: TypeDef -> TypeDef -> Bool Source # (/=) :: TypeDef -> TypeDef -> Bool Source #

type Constructors = [(Name, [StructType])] Source #

type AttrFields = [(Name, StructType)] Source #

data StructType Source #

Constructors

Maybe StructType |
Defaultable StructType String | String holds default value.
List StructType |
List1 StructType | Non-empty lists.
Tuple [StructType] |
OneOf [StructType] |
Any | XML's contentspec allows ANY
StringMixed | mixed (#PCDATA | ... )*
String | string only (#PCDATA)
Defined Name |

#### Instances

Instances details

Show StructType Source # |
Instance details Defined in Text.XML.HaXml.DtdToHaskell.TypeDef Methods showsPrec :: Int -> StructType -> ShowS Source # show :: StructType -> String Source # showList :: [StructType] -> ShowS Source #
Eq StructType Source # |
Instance details Defined in Text.XML.HaXml.DtdToHaskell.TypeDef Methods (==) :: StructType -> StructType -> Bool Source # (/=) :: StructType -> StructType -> Bool Source #

# Pretty-print a TypeDef

ppTypeDef :: TypeDef -> Doc Source #

ppHName :: Name -> Doc Source #

Pretty print Haskell name.

ppXName :: Name -> Doc Source #

Pretty print XML name.

ppAName :: Name -> Doc Source #

Pretty print Haskell attributes name.

# Name mangling

data Name Source #

Need to keep both the XML and Haskell versions of a name.

Constructors

Name |

Fields

- xName :: String

  original XML name

- hName :: String

  mangled Haskell name

#### Instances

Instances details

Eq Name Source # |
Instance details Defined in Text.XML.HaXml.DtdToHaskell.TypeDef Methods (==) :: Name -> Name -> Bool Source # (/=) :: Name -> Name -> Bool Source #

name :: String -> Name Source #

Make a type name valid in both XML and Haskell.

name_ :: String -> Name Source #

Append an underscore to the Haskell version of the name.

name_a :: String -> String -> Name Source #

Prefix an attribute enumeration type name with its containing element name.

name_ac :: String -> String -> String -> Name Source #

Prefix an attribute enumeration constructor with its element-tag name, and its enumeration type name.

name_f :: String -> String -> Name Source #

Prefix a field name with its enclosing element name.

mangle :: String -> String Source #

Convert an XML name to a Haskell conid.

manglef :: String -> String Source #

Convert an XML name to a Haskell varid.