2
votes

I'm having trouble getting haddock to display the field names of my data records. Some of my data types have many different numeric values, so documenting the names is key.

An example data record:

-- | API response container for daily price history
data PriceHistoryResponse = PriceHistoryResponse {
  responseData :: [PriceHistoryResponseData], -- ^ the actual response, list of price entries
  timeTo       :: Maybe Integer, -- ^ latest price returned
  timeFrom     :: Maybe Integer -- ^ earliest price returned
} deriving (Show, Generic)

The data types in question are being exported like so:

  -- more module exports above ..
  , PriceHistoryResponse(..)
  , PriceHistoryResponseData(..)
  -- more below ...

For this definition (and all others like it), the only documentation being generated is the constructor's type signature. No explanations of values involved are generated, however.

A possibly relevant detail is that I have DuplicateRecordFields enabled in this file.

$ stack exec -- haddock --version                                           
Haddock version 2.17.3

Am I making an obvious error, or just missing something? Happy to provide any other information that would be useful.

1
It seems very likely that this is DuplicateRecordFields' fault. Basically, that extension removes all record labels and replaces them with class methods and Haddock has seemingly no way to reverse this process. I was never a fan of that extension; are you sure you need to go that way? Using lens' makeFields on records with unambiguous field names seems so much more versatile to me.leftaroundabout
@leftaroundabout: I'm writing a wrapper for a 3rd party JSON API, and many of the requests and responses have field names that are shared across different endpoints. I suppose I could go the route of making field names unique, it just seems like such an otherwise unnecessary workaround. If I go the route of disambiguating, what's the benefit of using lens? I'm not currently using any lens functionalityaviaviavi
Thanks for the help @leftaroundabout! You were correct!aviaviavi

1 Answers

0
votes

The problem was indeed DuplicateRecordFields. The fields generated just fine when I disambiguated and removed the extension.