Error messages could suggest UnliftedNewtypes in more situations
Consider the following program:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where
import GHC.Exts
newtype T :: TYPE IntRep where
MkT :: Int# -> T
This fails to compile with the following message:
GHCi, version 8.9.0.20190614: https://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug ( Bug.hs, interpreted )
Bug.hs:9:1: error:
• Kind signature on data type declaration has non-* return kind
TYPE 'IntRep
• In the newtype declaration for ‘T’
|
9 | newtype T :: TYPE IntRep where
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
It took me a while before I realized what was wrong: I had simply forgotten to enable UnliftedNewtypes
. I would have been spared some frustration if only GHC had just suggested "Perhaps you intended to use UnliftedNewtypes
", as it usually does whenever one tries to use a feature that is gated on some language extension. This shouldn't be too difficult to arrange.