[Haskell-cafe] Re: Haddock Markup

Heinrich Apfelmus apfelmus at quantentunnel.de
Mon Feb 9 13:40:30 EST 2009


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


Regards,
apfelmus

-- 
http://apfelmus.nfshost.com



More information about the Haskell-Cafe mailing list