Given the following program:
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE FlexibleInstances #-}
import Control.Monad.Reader
newtype AppM a = AppM (ReaderT Int IO a)
deriving (Functor, Applicative, Monad, MonadReader)
The MonadReader
deriving declaration should be MonadReader Int
. GHC produces the following error message:
Expecting one more argument to ‘MonadReader’
Expected kind ‘* -> ghc-prim-0.4.0.0:GHC.Prim.Constraint’,
but ‘MonadReader’ has kind ‘*
-> (* -> *) -> ghc-prim-0.4.0.0:GHC.Prim.Constraint’
In the newtype declaration for ‘AppM’
This error message is confusing to me. The kind of MonadReader
is * -> (* -> *) -> GHC.Prim.Constraint
, as the error message states, which makes sense. However, the error message states that it expects kind * -> GHC.Prim.Constraint
, despite the fact that MonadReader Int
is actually of kind (* -> *) -> GHC.Prim.Constraint
.
Given that kinds *
and * -> *
do not match, this error message feels not only misleading to me, but actually incorrect. Is this a bug, or am I overlooking something in this error message?