A generic program is written once and works on values of many data types. Generic\ud Haskell is a recent extension of the functional programming language Haskell that supports\ud generic programming. This paper discusses how Generic Haskell can be used to implement\ud XML tools whose behaviour depends on the DTD or Schema of the input XML document.\ud Example tools include XML editors, databases, and compressors. Generic Haskell is ideally\ud suited for implementing XML tools:\ud • Knowledge of the DTD can be used to provide more precise functionality, such as manipulations\ud of an XML document that preserve validity in an XML editor, or better\ud compression in an XML compressor.\ud • Generic Haskell programs are typed. Consequently, valid documents are transformed to\ud valid documents, possibly structured according to another DTD. Thus Generic Haskell\ud supports the construction of type correct XML tools.\ud • The generic features of Generic Haskell make XML tools easier to implement in a surprisingly\ud small amount of code.\ud • The Generic Haskell compiler may perform all kinds of advanced optimisations on the\ud code, such as partial evaluation or deforestation, which are difficult to conceive or implement\ud by an XML tool developer.\ud By embedding Schema and XML data into Haskell data types, we show how Generic Haskell\ud can be used as a generic XML processing language. We will demonstrate the approach by\ud implementing an XML compressor in Generic Haskell
To submit an update or takedown request for this paper, please submit an Update/Correction/Removal Request.