Skip to content

Confusing error message for unused variables in RHS of data family instance

{-# LANGUAGE TypeFamilies #-}
module T23778 where

import Data.Kind

data family D :: Type
data instance forall (d :: Type). D = MkD

On GHC 9.6 I get

    * Type variable `d' is mentioned in the RHS,
        but not bound on the LHS of the family instance

The message was reworded slightly in 9.8 with the error constructor migration, but it's similar:

    * Out of scope type variable `d' in the RHS of a family instance.
        All such variables must be bound on the LHS.

Instead I would expect to get an error that matches the one we get for type family instances

type family F
type instance forall (a :: Type). F = ()
    * Type variable `a' is bound by a forall,
        but not used in the family instance.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information