[Haskell-cafe] Haddock Markup
Wolfgang Jeltsch
g9ks157k at acme.softbase.org
Mon Feb 9 12:32:46 EST 2009
Am Montag, 9. Februar 2009 15:10 schrieben Sie:
> I want for long to write math formulas in a paper in Haskell. Actually,
> lhs2TeX can do such transformations but it is quite limited in handling
> of parentheses and does not support more complicated transformations
> (transforming prefix notation in infix notation or vice versa with
> minimal parentheses).
>
> […]
>
> I imagine some rule based configuration that is implemented using
> haskell-src, that handles all identifiers, say, with prefix "parameter"
> as wildcards:
>
> sumFor [parameterA..parameterB] (\parameterI -> parameterS)
> => \sum_{parameterI=parameterA}^{parameterB} parameterS
>
> Unfortunately a tool for this transformation still has to be written,
> but wouldn't that be really cool? The tool might be even relatively
> simple, but the configuration is certainly non-trivial and it would have
> to be hard-wired into cabal in order to provide identical rendering on
> all systems and output formats (TeX or MathML).
This reminds me of an idea which I had some time ago. The idea is to write all
your documentation in Template Haskell, possibly using quasiquoting to
support Haddock-like syntax. Then you could write math as ordinary Haskell
expressions and embed these expressions into your documentation expressions.
This would make the documentation language very extensible since you could
always write your own extensions in the form of some Haskell code fragments
or libraries.
To build the documentation, one would run GHC with a special flag or whatever
which makes the Template Haskell parts build HTML or whatever. Without the
flag, the documentation code would do nothing. By using Template Haskell, one
would have access to information about identifiers, types etc. A basic
Haddock Haskell library could provide functions which use that information to
build HTML or whatever from the actual documentation. These functions would
then be used in the Template Haskell code.
Does this make some sense?
Best wishes,
Wolfgang
More information about the Haskell-Cafe
mailing list