Scripting XML with Generic Haskell
Publication date
2003
Authors
Atanassow, F.
Clarke, D.
Jeuring, J.T.
Editors
Advisors
Supervisors
DOI
Document Type
Preprint
Metadata
Show full item recordCollections
License
Abstract
A generic program is written once and works on values of many data
types. Generic Haskell is a recent extension of the functional programming
language Haskell that supports generic programming. This paper discusses how
Generic Haskell can be used to implement XML tools whose behaviour depends
on the DTD or Schema of the input XML document. Example tools include
XML editors, databases, and compressors. Generic Haskell is ideally suited for
implementing XML tools:
• Knowledge of the DTD can be used to provide more precise functionality,
such as manipulations of an XML document that preserve validity in an
XML editor, or better compression in an XML compressor.
• Generic Haskell programs are typed. Consequently, valid documents
are transformed to valid documents, possibly structured according to
another DTD. Thus Generic Haskell supports the construction of type
correct XML tools.
• The generic features of Generic Haskell make XML tools easier to implement
in a surprisingly small amount of code.
• The Generic Haskell compiler may perform all kinds of advanced optimisations
on the code, such as partial evaluation or deforestation, which
are difficult to conceive or implement by an XML tool developer.
By embedding Schema and XML data into Haskell data types, we show how
Generic Haskell can be used as a generic XML processing language. We will
demonstrate the approach by implementing an XML compressor in Generic
Haskell.