Skip to content

Suggestions from 12087 (fix illegally nested foralls in GADTs) drop some arguments

The issue https://ghc.haskell.org/trac/ghc/ticket/12087 led to GHC suggesting replacements for malformed GADT constructor types. However, it appears that the suggestions are incorrect. Consider the GHCi session:

GHCi, version 8.9.20190312: https://www.haskell.org/ghc/  :? for help
Prelude> :set -XGADTs
Prelude> data D where C :: Int -> forall b . b -> D

<interactive>:14:14: error:
    • GADT constructor type signature cannot contain nested ‘forall’s or contexts
      Suggestion: instead use this type signature: C :: forall b. b -> D
    • In the definition of data constructor ‘C’
      In the data type declaration for ‘D’

It seems that GHC has dropped the Int argument. Should it not suggest C :: forall b . Int -> b -> D ?

Similarly, for data D where C :: forall a . Int -> forall b . b -> D, it suggests C :: forall a b. b -> D rather than C :: forall a b . Int -> b -> D

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