This seems like a good way of transitioning from .lhs to haddock'd .hs. In the long run, I think we (meaning Simon :-) should to extend haddock to take the place of the .lhs style of documenting code.
To generate .hs from .lhs, the right way is to use GHC: $ ghc -E Foo.lhs -o Foo.hs The great thing about this is that it goes through the same preprocessing stages that your source goes through in order to compile it. So for example if you use CPP on your source too, just say 'ghc -E -cpp' to get the preprocessed output.
I use haddock to document interfaces for modules and it works wonderfully for that (and it would be even better if I could use haddock comments inside records and in between constructor arguments, hint, hint).
But I find myself using it in comments within code (especially within local functions) too. Perhaps a haddock that had two modes (one for interfaces, one for implementation) would work. The interface mode would work as it does now. The implementation mode would produce a .html version of the entire module, using haddock comments to mark it up.
Simon: how much work would this be?
That's an interesting idea. It's not at all what Haddock was intended for, but that's not to say it couldn't be done! There are some issues to do with how you want the output to look: should it retain the indentation of the original source, or ident according to some fixed style? If you want the indentation from the original source then Haddock's front end will need some changes to support retaining that information. Throwing away the original indentation and generating output indented according to a fixed style would be rather easier. Cheers, Simon
On Thursday 24 April 2003 08:10 am, Simon Marlow wrote:
Simon: how much work would this be?
That's an interesting idea. It's not at all what Haddock was intended for, but that's not to say it couldn't be done!
Glad to hear it.
There are some issues to do with how you want the output to look: should it retain the indentation of the original source, or ident according to some fixed style? If you want the indentation from the original source then Haddock's front end will need some changes to support retaining that information. Throwing away the original indentation and generating output indented according to a fixed style would be rather easier.
I agree. One could imagine providing a mildly configurable style (for example, do notation has a few widely used competing styles: layout only, braces and semis, or even totally Utrecht). Cheers, Andy -- Andy Moran Ph. (503) 526 3472 Galois Connections Inc. Fax. (503) 350 0833 3875 SW Hall Blvd. http://www.galois.com Beaverton, OR 97005 moran@galois.com
Hello.
To generate .hs from .lhs, the right way is to use GHC:
$ ghc -E Foo.lhs -o Foo.hs
Argh, ok, this is really convincing. The next time I will read ghc --help at first :-) I like your ideas about such a "Haskell2Html" or "Super Haddock". Ciao, Steffen
"Simon Marlow" <simonmar@microsoft.com> writes:
Somebody else¹ wrote:
This seems like a good way of transitioning from .lhs to haddock'd .hs. In the long run, I think we (meaning Simon :-) should to extend haddock to take the place of the .lhs style of documenting code.
That's an interesting idea. It's not at all what Haddock was intended for, but that's not to say it couldn't be done!
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}). Would a Haddock replacement give me the same kind of functionality in producing a nice printable copy? I definitely have grown attached to having math, footnotes, page headings, sections, and so on. -kzm ¹) As Exchange doesn't leave useful thread information, I'm not quite sure who. Simon and others, if you must use Exchange, could you take care to leave an attribution, prefereably including the message-id? -- If I haven't seen further, it is by standing in the footprints of giants
On Friday 25 April 2003 09:09, Ketil Z. Malde wrote:
This seems like a good way of transitioning from .lhs to haddock'd .hs. In the long run, I think we (meaning Simon :-) should to extend haddock to take the place of the .lhs style of documenting code.
That's an interesting idea. It's not at all what Haddock was intended for, but that's not to say it couldn't be done!
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}). Would a Haddock replacement give me the same kind of functionality in producing a nice printable copy? I definitely have grown attached to having math, footnotes, page headings, sections, and so on.
That makes two of us. I've been doing almost all my haskell work using lhs files + LaTeX, and I'd really miss it if was removed someday. Haddock documentation seems very nice but it serves a diferent purpose. J.A.
Jorge Adriano <jadrian@mat.uc.pt> 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}). Would a Haddock replacement give me the same kind of functionality in producing a nice printable copy? I definitely have grown attached to having math, footnotes, page headings, sections, and so on.
That makes two of us. I've been doing almost all my haskell work using lhs files + LaTeX, and I'd really miss it if was removed someday. Haddock documentation seems very nice but it serves a diferent purpose.
Chalk up one more. Is it possible to use lhs + LaTeX + Haddock (as it is) together meaningfully? If not, will it be? Feri.
Is it possible to use lhs + LaTeX + Haddock (as it is) together meaningfully? If not, will it be?
I still like my original idea *g*. It fits this purpose! In my point of view LaTeX commentaries are a good place to hide information for various tools like Haddock. Ok, there is the shortcoming that you have to preprocess the .lhs-files. This may be a little bit confusing at first. Can someone provide a little example of this "active Haskell". Sounds interesting. Ciao, Steffen
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. -- -- Johannes Waldmann ---- http://www.informatik.uni-leipzig.de/~joe/ -- -- joe@informatik.uni-leipzig.de -- phone/fax (+49) 341 9732 204/207 --
(Example application: I'm writing a graph theory text, and I want to embed pictures that are produced by a Haskell program)
.. and of course I want to use Haskell's type checker to check the math formulas in the text. i. e. I want to type them "as Haskell", not "as LaTeX". -- -- Johannes Waldmann ---- http://www.informatik.uni-leipzig.de/~joe/ -- -- joe@informatik.uni-leipzig.de -- phone/fax (+49) 341 9732 204/207 --
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
Johannes Waldmann <joe@informatik.uni-leipzig.de> 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.
I'm not sure if this is what you are looking for, but I wrote my first Haskell program that way. I wrote a little style file named runtest.sty, which provides two environments: heval: You can put expressions inside heval, and you get the expression and the result inserted into your document. This uses GHCi. withstdin: Using this environment, you can execute a program giving it some STDIN, and also see the result. Note that runtest.sty depends on the web2c shell_escape, which is disabled by default. Enable it in your texmf.cfg or by setting the environment variable shell_escape If you're interested, see http://delysid.org/Stunden.tar.gz -- CYa, Mario
participants (10)
-
Andy Moran -
Ferenc Wagner -
Johannes Waldmann -
Jorge Adriano -
ketil@ii.uib.no -
Magnus Carlsson -
Mario Lang -
Simon Marlow -
Steffen Mazanek -
Steffen Mazanek