[Haskell-cafe] Re: Haddock Markup

Henning Thielemann lemming at henning-thielemann.de
Tue Feb 10 06:39:59 EST 2009


Heinrich Apfelmus schrieb:
> Henning Thielemann wrote:
>> 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 would like to write
>>   sumFor [0..n] (\i -> i^2)
>>     (with sumFor xs f = sum $ map f xs)
>> which is rendered as
>>   \sum_{i=0}^{n} i^2
>> or
>>   integrate 1000 (a,b) (\t -> f t)
>> to be rendered as
>>   \int_a^b f(t) \dif t
> 
> Neat idea! Can't you do implement this as a DSL?
> 
>     sumFor x xs f =
>        "\sum_{" ++ x ++ "=" ++ head xs ++ "}^{" ++ last xs ++ "} "
>        ++ f x


My original idea was to use the formulas in papers both for typesetting
and for unit testing. Thus, when you state that a function fulfills a
law, that it can be automatically tested by QuickCheck, that this at
least true for some instances.
The same would be useful for Haddock documentation. I remember that
someone proposed to permit Haddock to expose the implementation of some
functions as examples or as unit-tests/laws. Now we could extend this
idea to allow Haddock not only to expose the implementation of
functions, but also to tell Haddock how to render its implementation.


More information about the Haskell-Cafe mailing list