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