简体   繁体   中英

Generate Haddock for hidden members

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 eg 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?

One option is to add

{-# OPTIONS_HADDOCK ignore-exports #-}

which will generate Haddock documentation as if there were an empty export list -- ie, 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 .)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM