HSX (Haskell Source with XML) allows literal XML syntax in Haskell source code.


Version on this page:0.13.5
LTS Haskell 21.25:
Stackage Nightly 2023-06-21:
Latest on Hackage:

See all snapshots hsx2hs appears in

BSD-3-Clause licensed by Niklas Broberg, Joel Bjornson
Maintained by Jeremy Shaw
This version can be pinned in stack with:hsx2hs-0.13.5@sha256:d880d6809f22ef1a309e75e69481ac4cf3ee9ce525efadefc4bb56842b34ebb4,3422

Module documentation for 0.13.5

HSX (Haskell Source with XML) allows literal XML syntax in Haskell source code. The hsx2hs preprocessor translates .hsx source files into ordinary .hs files. Literal XML syntax is translated into function calls for creating XML values of the appropriate forms. hsx2hs transforms literal XML syntax into a series of function calls. Any project can make use of the syntax by providing definitions for those functions, and the XML values produced will be of the types specified. This works for any types, since hsx2hs doesn't make any assumptions, or inserts any information depending on types. XMLGenerator defines a few typeclasses that together cover the functions injected by the preprocessor. A project that uses these classes to provide the semantics for the injected syntax will be able to use any functions written in terms of these, allowing better code reusability than if each project defines its own semantics for the XML syntax. Also, the classes makes it possible to use the literal syntax at different types within the same module. Achieving that is not as simple as it may seem, but the XMLGenerator module provides all the necessary machinery.