haskell / haddock

Haskell Documentation Tool
www.haskell.org/haddock/
BSD 2-Clause "Simplified" License
361 stars 242 forks source link

Private constructor with `NoFieldSelectors` hides all the fields #1607

Closed ruifengx closed 1 month ago

ruifengx commented 11 months ago

Consider the following code:

{-# LANGUAGE NoFieldSelectors #-}
module Test (Point (x, y)) where
data Point = Point { x :: Double, y :: Double }

Haddock does not list the fields x and y in the generated documentation, presumably because the field selector functions are not generated (due to NoFieldSelectors). However, the fields can still be used via sections like (.x), (.y) :: Point -> Double or p.x, p.y :: Double where p :: Point (with OverloadedRecordDot). It's desirable to have Haddock list these fields in the documentation to make them more accessible to the user.

I think a temporary workaround would be to generate the documentation as if the constructor were exported. For the long term, I think it suffice to have a special decoration on the constructor to indicate it is in fact not exported.

Kleidukos commented 1 month ago

Hi, thank you for this ticket, but Haddock now lives full-time in the GHC repository! Read more at https://discourse.haskell.org/t/haddock-now-lives-in-the-ghc-repository/9576.

Let me know if you feel it is still needed, and I'll migrate it. :)