HSXML version 1.13. Overloading polyvariadic functions
This message announces the version 1.13 of HSXML. HSXML is a library for writing and transforming typed semi-structured data in Haskell -- in S-expression syntax, with the extensible set of `tags', and statically enforced content model restrictions. A particular application is writing web pages in Haskell. We obtain HTML, XHTML or other output formats by running the Haskell web page in an appropriate rendering monad. The benefit of representing XML-like documents as a typed data structure/Haskell code is static rejection of bad documents -- not only those with undeclared tags but also those where elements appear in wrong contexts. The web page http://pobox.com/~oleg/ftp/Scheme/xml.html#typed-SXML gives further motivation and description. It points to an example of authoring web pages in HSXML and a complex example of context-sensitive HSXLT transformations: producing structurally distinct HTML and XML/RSS from the same master file. The complete source code with several examples is available at http://pobox.com/~oleg/ftp/Haskell/HSXML.tar.gz The new version of HSXML contains more examples, many of which have been very kindly suggested by shelarcy. One example in particular, quote.hs, demonstrates overloading of a polyvariadic function. That may seem impossible: a polyvariadic function typically has the type forall t. C t => t. How overload on t? How to overload on arguments or the result of the function if we don't know even the number of arguments let alone their types. It's all in the future, when the function is applied. As it turns out, if we make preparations in the present, we can overload the future.
On Sun, Feb 04, 2007 at 08:31:55PM -0800, oleg@pobox.com wrote:
The benefit of representing XML-like documents as a typed data structure/Haskell code is static rejection of bad documents -- not only those with undeclared tags but also those where elements appear in wrong contexts.
Seems like http://www.informatik.uni-freiburg.de/~thiemann/haskell/WASH/ has has the same purpose, has it? Cheers, schneegloeckchen
schneegloeckchen wrote:
Seems like http://www.informatik.uni-freiburg.de/~thiemann/haskell/WASH/ has has the same purpose [as HSXML], has it?
_Some_ of the same purpose, yes. But HSXML does follow the S-expression syntax -- something that has not been attained in Haskell. Here's a sample HSXML: [p "Haskell is a general purpose," [[em [[strong "purely"]] "functional"]] "programming language"] one may observe the absence of any commas and other list delimiters. The things in square brackets can't be lists anyway because their `elements' patently have different types. The strings are represented as strings rather than (text "string") etc. The `p' element obviously can have arbitrary number of subelements and strings. On a Scheme system that takes square brackets (which is the R6RS behavior) the above expression can be read with one `read' call -- proving that HSXML is an S-expression.
participants (2)
-
mm -
oleg@pobox.com