Johannes Waldmann writes:
On Friday 25 April 2003 09:09, Ketil Z. Malde wrote:
I'm not sure I would like this. I guess I'm one of (the apparently very few?) who are using LaTeX lhs style (using \begin/\end{code}).
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.)
Preferably accompanied by a class (like Show) 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)
I once built a similar beast (for active literate programming in a domain specific language - not Haskell) (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 «funny quotation marks like this». Within the text, one could again escape to Haskell by using curly brackets. We had backends generating LaTeX and HTML. For example, the HacWrite source section «Congruence rules» $do «Following the style of {cite"berry:chemical"}, we define a bunch of congruence rules which can be used freely to find reaction rules to apply.» eqtable eqop [ (s+t , t+s ,«Commutativity of {parop}») , (p(s+t)+u , s+p(t+u) ,«Associativity of {parop}») , (p(s<<t)<<u , s<<p(t<<u) ,«Associativity of {serop}») , (s<<p(t!u) , p(s<·t)<<u ,«Internal communication in {serop}») , (p(s+t)<·u , p(s<·u)+p(t<·u) ,«Distributivity of {feedop} over {parop}») , (p(s!t)<·u , s!p(t<·u) ,«Output from {feedop}») , (p(s!t)<<u , s!p(t<<u) ,«Output from {serop}») , (p(x?s)<·t , s//(t,x) ,«Substitution») ] produced the (moderately nice-looking) HTML code at 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