summaryrefslogtreecommitdiff
path: root/p/haxml/debian/MkOneOf.1
blob: 72015c5c8bece2f5bcc5a83027de942ba5695199 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
.TH MkOneOf "1" "October 2007" "MkOneOf, version 1.17" "User Commands"
.SH NAME
MkOneOf \- a helper program to use with DtdToHaskell
.SH SYNOPSIS
.B MkOneOf
n [m]
.SH DESCRIPTION
\fBDtdToHaskell\fP translates XML DTD into equivalent Haskell types.
When there is a choice between different tags, \fBDtdToHaskell\fP 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.
.PP
\fBMkOneOf\fP takes an integer \fBN\fP or an integer range \fBN M\fP and writes to the standard output a Haskell module with respectively the datatype OneOf\fBN\fP or the datatypes OneOf\fBN\fP up to and including OneOf\fBM\fP.
.SH EXAMPLES
If we run "MkOneOf 1 2", the program will print
.nf
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
        $ (\c->(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
        $ (\c->(Nothing,c))) cs
    toElem (OneOf2 x) = toElem x
    toElem (TwoOf2 x) = toElem x

----
.fi
.SH COPYRIGHT
.TP
The HaXml library and tools were written by and are copyright to
Copyright \(co 1998 \(en 2006    Malcolm Wallace and Colin Runciman
.TP
The library incorporates the module Text.ParserCombinators.HuttonMeijerWallace
Copyright \(co 1996           Graham Hutton and Erik Meijer
.TP
with modifications
Copyright \(co 1998 \(en 2000    Malcolm Wallace
.TP
and may also use or incorporate the module Text.PrettyPrint.HughesPJ
Copyright \(co 1996 \(en 1997    John Hughes and Simon Peyton Jones
.PP
The HaXml library is licensed under the terms of the GNU Lesser General Public Licence (LGPL), with the following special exception:
.RS
.PP
As a relaxation of clause 6 of the LGPL, the copyright holders of this library give permission to use, copy, link, modify, and distribute, binary-only object-code versions of an executable linked with the Library, without requiring the supply of any mechanism to modify or replace the Library and relink (clauses 6a, 6b, 6c, 6d, 6e), provided that all the other terms of clause 6 are complied with.
.RE
.PP
The HaXml tools Xtract, Validate, DtdToHaskell, and MkOneOf, are licensed under the terms of the GNU General Public Licence (GPL).
.PP
This library and toolset is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Licences for more details.
.SH "SEE ALSO"
.BR DtdToHaskell (1)
.SH AUTHOR
This contents of this manual page was copied from the HTML documentation and slightly edited by Arjan Oosting <arjan@debian.org> for the Debian system (but may be used by others).