Skip to content

Kind Signatures on data instances

There's a comment in compiler/typecheck/TcInstDcls.hs that reads:

The "header" is the part other than the data constructors themselves

e.g. data instance D [a] :: * -> * = ...

Here the "header" is the bit before the "=" sign

What's weird is that you cannot actually compile code that this example suggests is valid. Consider this:

{-# language TypeFamilies #-}
  
module BadSig where

data family Bar a :: *
data instance Bar Int :: * = Bool

It fails on GHC 8.6.2 with:

bad_sig.hs:6:28: error:
    parse error on input ‘=’
    Perhaps you need a 'let' in a 'do' block?
    e.g. 'let x = 5' instead of 'x = 5'
  |
6 | data instance Bar Int :: * = Bool
  |                            ^

Oddly, GHC will accept the instance if the body is missing:

{-# language TypeFamilies #-}
  
module BadSig where

data family Bar a :: *
data instance Bar Int :: *

It is not clear to me whether or not this one should be accepted, but that is beside the point. The first example should certainly be accepted. It should also be accepted with TYPE 'LiftedRep instead of *, but it fails with the same parser error when given that kind signature as well.

Trac metadata
Trac field Value
Version 8.6.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information