MkOneOf1
A helper program to use with dtdtohaskell
Usage
MkOneOf n
[m]
Overview
DtdToHaskell translates XML DTD into equivalent Haskell types. When there is a choice between different tags, DtdToHaskell uses types like OneOf2, OneOf3, OneOf4, etc. The module Text.XML.HaXml.OneOfN currently defines these types up OneOf20. If your DTD requires larger choices, you can use this program to generate them.
MkOneOf takes an integer N or an integer range N M and writes to the standard output a Haskell module with respectively the datatype OneOfN or the datatypes OneOfN up to and including OneOfM.
Examples
If we run "MkOneOf 1 2", the program will print
module Text.XML.HaXml.OneOfN where
import Text.XML.HaXml.Xml2Haskell
data OneOf1 a
= OneOf1 a
deriving (Eq,Show)
instance (XmlContent a)
=> XmlContent (OneOf1 a)
where
fromElem cs =
(choice OneOf1
$ (->(Nothing,c))) cs
toElem (OneOf1 x) = toElem x
----
data OneOf2 a b
= OneOf2 a | TwoOf2 b
deriving (Eq,Show)
instance (XmlContent a,XmlContent b)
=> XmlContent (OneOf2 a b)
where
fromElem cs =
(choice OneOf2 $ choice TwoOf2
$ (->(Nothing,c))) cs
toElem (OneOf2 x) = toElem x
toElem (TwoOf2 x) = toElem x
----
Releases
10 releases since Debian 4.0 (Etch); the text changed 3 times.