
On a closely related matter, Benjamin Pierce told me how often he wished that there was a link from the Haddock documentation to the source code for a function. Especially for Prelude functions, he's dead right. So another really useful Haddock enhancement would be the ability to add links to the source code from the Haddock docs --- again on a per-function basis. Do you feel like adding that too? Where should the code live? I'd suggest snap-shoting it at the moment that the Haddock docs are generated, and putting the files with the Haddock docs.
I was thinking about that. It'd probably be a less difficult change to haddock to get it to link to the source code, rather than picking it up as it parses it.
Haddock does know the file name of each .hs file since it's invoked with then on the command line. We can assume that the --source=URL points to the location where haddock was invoked from. This gives us the full url of each .hs file (I think). Then to deal with the use of pre-processors etc, haddock should pickup the {-# LINE ... #-} pragmas just like ghc does, so that it can discover the original file name.
I'd rather have the source code put into the html than linking to it. Say, by default it would be hidden, and shown by a click (javascript). This has the additional benefit that, in the future, one can add annotations to the source. For example, linking every function call to its definition. Cheers, JP.