Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does GHC produce the following kind error message?

Tags:

haskell

ghc

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?

like image 284
Alexis King Avatar asked Aug 26 '16 18:08

Alexis King


1 Answers

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

like image 195
2 revs Avatar answered Nov 01 '22 14:11

2 revs