Super Haddock (was Re: Literate Programming)
Magnus Carlsson
magnus@cse.ogi.edu
Fri, 25 Apr 2003 11:13:57 -0700
Johannes Waldmann writes:
> > On Friday 25 April 2003 09:09, Ketil Z. Malde wrote:
>=20
> > > I'm not sure I would like this. I guess I'm one of (the apparen=
tly
> > > very few?) who are using LaTeX lhs style (using \begin/\end{code=
}).
>=20
> I don't use .lhs normally but I would love to see some "active lhs",=
> that is, text containing Haskell expressions that actually
> get evaluated when (or before) typsetting.
> (Mathematica has this, and I'm sure some other systems do it also.)
>=20
> Preferably accompanied by a class (like Show)=20
> producing formatted output - perhaps LaTeX, perhaps HTML.
> (Example application: I'm writing a graph theory text,
> and I want to embed pictures that are produced by a Haskell program)=
>=20
> I once built a similar beast (for active literate programming
> in a domain specific language - not Haskell)=20
> (but the implementation was done in Haskell, of course)
> to typeset my PhD thesis.
Thomas Hallgren and I wrote a little system called HacWrite similar to
what you describe, for producing our thesis. (Yes, it was
procrastination! :-)
Basically, it was Haskell, enhanced with a new literal for markup
text, within =ABfunny quotation marks like this=BB. Within the text, o=
ne
could again escape to Haskell by using curly brackets. We had
backends generating LaTeX and HTML. For example, the HacWrite source
section =ABCongruence rules=BB $do
=ABFollowing the style of {cite"berry:chemical"}, we define a
bunch of congruence rules which can be used freely to find
reaction rules to apply.=BB
eqtable eqop
[ (s+t , t+s ,=ABCommutativity of {parop}=BB)
, (p(s+t)+u , s+p(t+u) ,=ABAssociativity of {parop}=BB)
, (p(s<<t)<<u , s<<p(t<<u) ,=ABAssociativity of {serop}=BB)
, (s<<p(t!u) , p(s<=B7t)<<u ,=ABInternal communication in
{serop}=BB)
, (p(s+t)<=B7u , p(s<=B7u)+p(t<=B7u) ,=ABDistributivity of
{feedop} over {parop}=BB)
, (p(s!t)<=B7u , s!p(t<=B7u) ,=ABOutput from {feedop}=BB)
, (p(s!t)<<u , s!p(t<<u) ,=ABOutput from {serop}=BB)
, (p(x?s)<=B7t , s//(t,x) ,=ABSubstitution=BB)
]
produced the (moderately nice-looking) HTML code at=20
http://www.cs.chalmers.se/~hallgren/Thesis/future-work.html#43.1.2
and the hard copy (via LaTeX) on page 241 in
http://www.cs.chalmers.se/~hallgren/Thesis/fudgets_thesis_color.ps.gz=
Although HacWrite was somewhat primitive, it was delightful to be able
to define and use Haskell functions instead of LaTeX macros.
I wonder how many typesetting systems like these there are out there,
written by PhD students...
Cheers,
/M