开发者

Haddock: Document a declaration with inferred type signature?

Consider the following module

{-# LANGUAGE RecordWildCards #-}
module Example (foo, fuh, fon, fuzz) where

import qualified FirstClassModule (Bar(foo,fuh,fon,fuzz), makeBar)

FirstClassModule.Bar {..} = FirstClassModule.makeBar parameter

parameter :: Int
parameter = 15

The intention is that the the module FirstClassModule provides a record type Bar which works a bit like a first class module. Then, the module Example instantiates the module and uses the RecordWildCards extension to bring the names into scope and make them exportable.

When you run Haddock (ve开发者_Go百科rsion 2.8) on this module, it will interfere the type signatures for the foo functions and include them in the API documentation. Now, my question is:

Is there a way to document the resulting names foo, fuh, etc. without writing down their type signatures in the Example module?

I don't want to write the type signatures because in this case because they are boilerplate. If I have to write them down, this module loses its raison d'être.


From the Haddock user manual:

http://www.haskell.org/haddock/doc/html/markup.html#id564988

Note that Haddock doesn't contain a Haskell type system — if you don't write the type signature for a function, then Haddock can't tell what its type is and it won't be included in the documentation.

The documentation is for version 2.8, version 2.9 is the newest.


Actually, I just found out that, as of version 2.9.2, Haddock will infer type signatures for exported functions. Unfortunately, I can't seem to find a way to embellish them with additional documentation.

For instance, the module

module Test (foo) where

foo = "bar"

will produce the type signature

foo :: String

in the documentation, but it seems that I can't add any text to it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜