-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lenses created by makeLenses should inherit Haddock documentation #614
Comments
Can we actually generate haddocks via |
TH can't generate haddock comments as far as I know - here is the GHC trac - https://ghc.haskell.org/trac/ghc/ticket/5467 |
If you want to document your lens you can disable type signature generation, write type signatures, document them. Not only can TH not generate haddock comments, it can't read them. |
The GHC ticket (5467) mentioned earlier is now apparently closed due to this commit. I'm haven't really implemented anything using TH before, so does that mean it would now be possible to implement this feature in lens? |
It seems it would! It would need a bleeding edge GHC obviously, and we might need to review how we use @glguy's |
Seven years from request to "yeah, we could probably do that now" is not our fastest turn around time yet, I admit. |
Just to be clear, the commit linked above lets you attach Haddock comments to TH-generated declarations, but it does not (AFAICT) let you slurp Haddocks comments from TH quotes. That is to say, GHC won't preserve any Haddock comments one writes in a |
I was hoping that the new |
The comment:
gives me some pause about the viability of that option. |
OK, good to know. In that case, the {-# LANGUAGE TemplateHaskell #-}
module Bug where
import Data.Foldable
import Language.Haskell.TH
-- | Haddocks for 'Foo'.
data Foo =
-- | Haddocks for 'MkFoo'.
MkFoo
{ foo1 :: Int
-- ^ Haddocks for 'foo1'.
, foo2 :: Bool
-- ^ Haddocks for 'foo2'.
}
$(pure [])
$(do let getAndPrint n = getDoc (DeclDoc n) >>= runIO . print
traverse_ getAndPrint [''Foo, 'MkFoo, 'foo1, 'foo2]
pure [])
main :: IO ()
main = pure ()
(I'm not sure what to make of the |
Currently the created lenses don't have any documentation, so if we only export the lens accessors for a datatype and hide the constructors, we lose all documentation about the datatype.
I don't know if this is possible with current Haddock, however.
The text was updated successfully, but these errors were encountered: