[Haskell-cafe] predicates in XML toolboxes

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Tue Apr 12 06:29:19 EDT 2005

Henning Thielemann <lemming at henning-thielemann.de> writes:

> The XML toolboxes HaXml, HXML and the XML toolbox uses one function type 
> (called filter) for different purposes.
> predicates                   a -> Bool
> selectors, transformators    a -> a
> list-valued functions        a -> [a]
> are all implemented with the one type (a -> [a]).
>   In my opinion this means a significant loss of type safety and quality of 
> documentation. Are there more type safe XML/HTML processor libraries in 
> Haskell?

When we were first experimenting with designs that later became
HaXml, we did indeed have separate notions of predicate, transformer,
selector, and so on.  But having lots of different types like this
meant it was more difficult to plug things together nicely into a
combinator framework.  Thus, we decided to squash everything together
into the filter type, so each piece was modular and could fit with
any other piece.  I think it was a good design.

But I take your point that this approach reduces type safety.
One option we considered was to use the DTD "type" of XML document
fragments themselves as a basis for a type system over the combinator
library.  Doubtless this would have required some subtle class
machinery to overload the same operation over many different DTDs.
Maybe even dependent types, subtyping, or union/intersection types
would be needed to get it just right.  In the end, we decided that
the mismatch between DTDs and Hindley-Milner was too great to do a
good job here, so the combinator library remained rather generic
and almost typeless.


More information about the Haskell-Cafe mailing list