I want use InputT (ReaderT Int IO) a
with MonadReader Int
.
I write below code to make instance MonadReader on InputT
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
module HaskelineMonadReader where
import Control.Monad.Reader
import System.Console.Haskeline
instance MonadReader r m => MonadReader r (InputT m) where
ask = lift ask
local = mapInputT . local
main :: IO ()
main = putStrLn "HI"
But I get this type error.
HaskelineMonadReader.hs:11:13:
Couldn't match type ‘m0 a0 -> m0 a0’ with ‘forall b. m b -> m b’
Expected type: (m0 a0 -> m0 a0) -> InputT m a -> InputT m a
Actual type: (forall b. m b -> m b) -> InputT m a -> InputT m a
Relevant bindings include
local :: (r -> r) -> InputT m a -> InputT m a
(bound at HaskelineMonadReader.hs:11:5)
In the first argument of ‘(.)’, namely ‘mapInputT’
In the expression: mapInputT . local
How can I fix this error.
Full source code is here
This compiles:
Update
Here is the error message:
So it appears that the expected type is more general because the
m0
does not have to be the same asm
. In the actual type them
inm b
must be the same as them
inm a
.