RE: class ??? with Haddock
How do I instruct Haddock to preprocess the Haskell files. From your mail I thought that Haddock would do so by default but it complains at the first #ifdef it sees. Unfortunately, I didn't find any Haddock option similar to Hugs' -F. I should really put this in the manual, since it gets asked so often. Anyway, you can use GHC to preprocess your source files before feeding them to Haddock: $ ghc -E -cpp -D__HADDOCK__ Foo.hs -o Foo.raw-hs $ haddock -h Foo.raw-hs ... This also works to turn literate Haskell source into ... er ... illiterate source. Cheers, Simon ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: class ??? with Haddock
Am Donnerstag, 8. Januar 2004 11:02 schrieb Simon Marlow: How do I instruct Haddock to preprocess the Haskell files. From your mail I thought that Haddock would do so by default but it complains at the first #ifdef it sees. Unfortunately, I didn't find any Haddock option similar to Hugs' -F. I should really put this in the manual, since it gets asked so often. Anyway, you can use GHC to preprocess your source files before feeding them to Haddock: $ ghc -E -cpp -D__HADDOCK__ Foo.hs -o Foo.raw-hs $ haddock -h Foo.raw-hs ... This also works to turn literate Haskell source into ... er ... illiterate source. So I have to write the preprocessed source to disk instead of piping it to Haddock when haddocking multiple files. Hmm, sounds not so good :-( but is, of course, not such a big problem. Cheers, Simon Wolfgang ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: class ??? with Haddock
Am Donnerstag, 8. Januar 2004 11:02 schrieben Sie: [...] Anyway, you can use GHC to preprocess your source files before feeding them to Haddock: $ ghc -E -cpp -D__HADDOCK__ Foo.hs -o Foo.raw-hs This only replaces all __HADDOCK__ occurences with 1 but doesn't process #ifdefs. [...] Wolfgang ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: class ??? with Haddock
Am Donnerstag, 8. Januar 2004 11:02 schrieben Sie: [...] Anyway, you can use GHC to preprocess your source files before feeding them to Haddock: $ ghc -E -cpp -D__HADDOCK__ Foo.hs -o Foo.raw-hs This only replaces all __HADDOCK__ occurences with 1 but doesn't process #ifdefs. Are you sure? It works for me, and it's what we use in GHC's libraries. Cheers, Simon ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
RE: class ??? with Haddock
Am Donnerstag, 8. Januar 2004 11:02 schrieben Sie: [...] Anyway, you can use GHC to preprocess your source files before feeding them to Haddock: $ ghc -E -cpp -D__HADDOCK__ Foo.hs -o Foo.raw-hs This only replaces all __HADDOCK__ occurences with 1 but doesn't process #ifdefs. Are you sure? It works for me, and it's what we use in GHC's libraries. One thing I forgot to mention is that you also need to remove the pesky lines beginning with '#' that the C preprocessor leaves behind. Here's what we do in GHC: $ ghc -D__HADDOCK__ -E -cpp Foo.hs -o Foo.tmp $ sed -e 's/^#.*//' Foo.tmp Foo.raw-hs Cheers, Simon ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: class ??? with Haddock
Am Donnerstag, 8. Januar 2004 17:39 schrieb Simon Marlow: [...] $ ghc -E -cpp -D__HADDOCK__ Foo.hs -o Foo.raw-hs This only replaces all __HADDOCK__ occurences with 1 but doesn't process #ifdefs. Are you sure? It works for me, and it's what we use in GHC's libraries. I found the problem, meanwhile. You have to put the #ifdefs etc. at the beginning of the line. Uuhterrible, I'd say. The same holds for cpp -traditional. cpp without -traditional is more tolerant but treats everything beginning with // as a comment and is therefore not usable with Hugs when you need Data.Array. Generally, I'd say that using a C preprocessor for Haskell is a bad idea but, of course, I can imagine that it requires less work to make cpp usable for Haskell than to develop a new preprocessor from scratch. But is using cpp planned to be a long-term solution? Cheers, Simon Wolfgang ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: class ??? with Haddock
Am Donnerstag, 8. Januar 2004 17:44 schrieb Simon Marlow: [...] One thing I forgot to mention is that you also need to remove the pesky lines beginning with '#' that the C preprocessor leaves behind. Here's what we do in GHC: $ ghc -D__HADDOCK__ -E -cpp Foo.hs -o Foo.tmp $ sed -e 's/^#.*//' Foo.tmp Foo.raw-hs I use cpp with option -P to solve this problem. Cheers, Simon Wolfgang ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: class ??? with Haddock
Am Mittwoch, 31. Dezember 2003 17:48 schrieben Sie: Wolfgang Jeltsch wrote: I have a datatype Relation element1 element2 which derives an Eq instance. In the Haddock-generated documentation the instances section of Relation says (Ord element1, Ord element2, ??? element1 element2) = [...]. Why does Haddock generate this mysterious ??? element1 element2 context? Haddock doesn't do any real type inference, it only handles some easy cases for deriving clauses. If you want nice documentation, you have to fake things a little bit (cut-n-paste from my OpenGL stuff): data GLmatrix a = GLmatrix MatrixOrder (ForeignPtr a) #ifdef __HADDOCK__ -- Help Haddock a bit, because it doesn't do any instance inference. instance Eq (GLmatrix a) instance Ord (GLmatrix a) instance Show (GLmatrix a) #else deriving ( Eq, Ord, Show ) #endif How do I instruct Haddock to preprocess the Haskell files. From your mail I thought that Haddock would do so by default but it complains at the first #ifdef it sees. Unfortunately, I didn't find any Haddock option similar to Hugs' -F. Cheers, S. Wolfgang ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: class ??? with Haddock
Wolfgang Jeltsch wrote: does Hugs understand C preprocessor macros? If not, your approach would be bad for me since I try to stay Hugs-compatible. Well, Hugs itself doesn't understand CPP macros (neither does GHC), but you can use Hugs' -Fcmd flag to pipe the source files through cmd before Hugs actually sees them. GHC has two related options, -pgmP cmd and -cpp. FYI: The hierarchical libraries are full of CPP stuff to handle the differences between various platforms and/or Haskell system, but the Hugs distributions usually come with preprocessed versions, so you don't necessarily need cpp. Cheers, S. ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: class ??? with Haddock
Am Mittwoch, 31. Dezember 2003 17:48 schrieb Sven Panne: Wolfgang Jeltsch wrote: I have a datatype Relation element1 element2 which derives an Eq instance. In the Haddock-generated documentation the instances section of Relation says (Ord element1, Ord element2, ??? element1 element2) = [...]. Why does Haddock generate this mysterious ??? element1 element2 context? Haddock doesn't do any real type inference, it only handles some easy cases for deriving clauses. If you want nice documentation, you have to fake things a little bit (cut-n-paste from my OpenGL stuff): data GLmatrix a = GLmatrix MatrixOrder (ForeignPtr a) #ifdef __HADDOCK__ -- Help Haddock a bit, because it doesn't do any instance inference. instance Eq (GLmatrix a) instance Ord (GLmatrix a) instance Show (GLmatrix a) #else deriving ( Eq, Ord, Show ) #endif Hello again, does Hugs understand C preprocessor macros? If not, your approach would be bad for me since I try to stay Hugs-compatible. Cheers, S. Happy New Year! Wolfgang ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell