6

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 (version 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.

Heinrich Apfelmus
  • 11,034
  • 1
  • 39
  • 67

2 Answers2

1

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.

Antoine Latter
  • 1,545
  • 10
  • 13
0

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.

Heinrich Apfelmus
  • 11,034
  • 1
  • 39
  • 67
  • 3
    You can now put a Haddock comment above `foo` and it will work as expected. I'm aware that it has been ~2 years since this answer but you might want to update it. – Mateusz Kowalczyk Jan 13 '14 at 09:48