Skip to content

Make haddocks consistent for infix constructors

Summary

data Foo
  -- | Docs for Foo1
  = Foo1 Int
  -- | Docs for Foo2
  | Foo2 Int
  -- | Docs for infix constructor
  | Int :* Bool

In this snippet, one would expect each docstring to attach to the corresponding constructor, but the last one actually attaches to the Int argument of the infix constructor. To get the desired behavior, you'd need to do

  -- | Docs for infix constructor
  | (:*) Int Bool

To me, this is surprising behavior, given that the following documents the constructor, as expected:

data Foo = Int :* Bool -- ^ asdf

In the same vein as the exception for -- ^ after a constructor and all its arguments, I think it makes sense to add an exception for -- | before an infix constructor and all its arguments.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information