tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
958 stars 83 forks source link

GADTs and haddock post-comments #677

Closed ryukzak closed 3 years ago

ryukzak commented 3 years ago

Describe the bug A haddock post-comment works wrong with GADTs.

To Reproduce Input:

data Info a b where
    Cons1 :: a -> Info a b -- ^Cons 1 doc
    Cons2 :: a -> Info a b -- ^Cons 2 doc

Output:

data Info a b where
  Cons1 ::
    a ->
    -- | Cons 1 doc
    Info a b
  Cons2 ::
    a ->
    -- | Cons 2 doc
    Info a b

Expected behavior

data Info a b where
  -- | Cons 1 doc
  Cons1 :: a -> Info a b
  -- | Cons 2 doc
  Cons2 :: a -> Info a b

Environment

amesgen commented 3 years ago

Maybe I am missing something, but I think that this is expected behavior. I created an example library exporting the input and the output, and the haddock of the input is indeed displayed at the return values, not at the constructors.

git clone --branch=gadt-haddock --single-branch https://github.com/amesgen/stuff
cd stuff
cabal haddock
# open the .html file displayed
mrkkrp commented 3 years ago

I think technically those comments are attached to the return type Info a b, not to the data constructors.