class ??? with Haddock
Hello, 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? Wolfgang
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 ------------------------------------------------------------------------ Cheers, S.
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
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' -F<cmd> 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.
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
participants (2)
-
Sven Panne -
Wolfgang Jeltsch