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?
Asked
Active
Viewed 145 times
0

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 Answers
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
-