0

Can I generate Haddock documentation for hidden members. My use case is that I have a type T that is shown in the signature of some functions. As in e.g. f :: T -> U, g :: T -> U. I'd like users of my library to know what T is used for, but not actually export it. Does it make sense? Is this possible?

fredefox
  • 681
  • 3
  • 11
  • Both `stack haddock` and `cabal new-haddock` have a `--haddock-internal` flag that you could try. – sjakobi Jul 26 '18 at 00:14

1 Answers1

1

One option is to add

{-# OPTIONS_HADDOCK ignore-exports #-}

which will generate Haddock documentation as if there were an empty export list -- i.e., as if everything were exported in the module.

Alternatively, the C preprocessor can be used to hide/show some entries in the Haddock docs. One probably has to invoke haddock with something like this (untested)

haddock --optghc=-cpp --optghc=-DHADDOCK ...

and then, in the haskell source,

{-# LANGUAGE CPP #-}
module M
    ( export1
    , export2
#ifdef HADDOCK
    , notExportedButWeWantDocsAnyway
#endif
    , export3
    ) where
...

(I thought that haddock already defined a macro to witness its presence, but I can't find that in its docs. One can always use a user-defined haddock flag. Or maybe it was this one.)

chi
  • 111,837
  • 3
  • 133
  • 218
  • Thanks for the input. The problem with the module header is if the module (as in my case) is a hidden module as well. Good to know that ignore-exports can be used like this. – fredefox Jul 25 '18 at 13:24
  • @fredefox I have no idea about how one could handle that :-/ – chi Jul 25 '18 at 15:01