Good Haskell Style

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Thu Aug 2 10:41:39 EDT 2007


"Alistair Bayley" <alistair at abayley.org> writes:

> > It uses -cpp if CPP is in the language extensions in the .cabal file.
> 
> So it does. So now Haddock completes, but produces very limited output.
> 
> > Perhaps unlitting should be done by converting all literate comments
> > into {- ... -} style comments.

I have a programme (FishFeeder) that does this; it's a bit
hacky, but I could post it here if someone was interested in
taking it on.

> As I alluded to earlier, I have a program which I wrote to do this. It
> prefixes "--" rather than enclosing in {- -},

Mine uses {- -} and escapes any such present in comments.

Here is the first comment from the source, which is itself
literate haddock:

| Preprocess literate haskell with Haddockumentation in the
  literate comments for use with Haddock.
  So making things a bit prettier

  Assumes that there is at least one space after every \">\",
  and indents the \"{-\"s (but not the \"-}\"s) by that much so
  that Haddock doesn't give a parse error. This is a bit of
  a hack, but I reckon it's haddock's fault since comments
  shouldn't have any effect on layout.


> and it's not perfect

I'd very be surprised if mine were!

> (there are a number of cases it doesn't handle, although I'm of the
> opinion that you shouldn't be doing whatever it fails on). I'm
> thinking it might be feasible to distribute this in the Takusen
> release and hook it into the cabal "setup haddock" command to
> preprocess the .lhs files.

It would surely be better to distribute a tool (either with
compilers or with haddock) so that it worked for anyone who
likes literate haskell?

> I have been tempted to run it over our .lhs once and for all, and
> convert everything to regular .hs files, but Oleg seems to like the
> birdtrack style, so we've decided to stick with it for now.

I much prefer the birdtrack style; it's a matter of taste,
and there's nothing more likely to cause disaffection than
insisting that someone abide by someone else's taste. I
would hate to see it deprecated just because the tools were
no good.

-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk




More information about the Libraries mailing list