简体   繁体   中英

Why does GHC produce the following kind error message?

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?

As Tikhon Jelvis said , this was a bug. Alexis King opened this ticket , which was closed as fixed four months ago.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM