mtl
mtl copied to clipboard
How to combine two different `r` `MonadReaders` ?
I wrote some code as below
testa :: (MonadReader Int m, MonadReader Char m, MonadIO m) => m ()
testa = do
i <- ask
c <- ask
liftIO $ do
print (i :: Int)
print (c :: Char)
runTesta :: IO ()
runTesta = flip runReaderT 100 $ flip runReaderT 'H' testa
When I run, it will be appear some errors
Due to the functional dependency on MonadReader
, you can't have any m
with two different environments like that. You'd have to do something like a MonadReader (Char, Int) m
constraint, then ask
would get you both.