MonadReader instance not found for RWST
ethul opened this issue · 4 comments
ethul commented
I am not sure why the instance is not being picked up. The state and writer instances work just fine. The following example shows the issue when env <- ask is uncommented.
module Example.RWS where
import Prelude
import Control.Monad.Eff.Console
import Control.Monad.RWS.Trans
import Control.Monad.Reader (ask)
import Control.Monad.State (get)
import Control.Monad.Writer (tell)
import Data.Identity
testRWST :: RWST String (Array String) String Identity String
testRWST = do
tell ["one"]
tell ["two"]
state <- get
tell [state]
-- No instance found for Control.Monad.Reader.Class.MonadReader _39
-- (Control.Monad.RWS.Trans.RWST Prim.String (Prim.Array Prim.String) Prim.String Data.Identity.Identity)
-- env <- ask
pure "a"
main = do
let see = runIdentity $ runRWST testRWST "env" "state"
print see.logMaybe I am missing something here?
garyb commented
I think you need to "do something" with env so a type can be inferred for it, so it's not left as _39.
ethul commented
I think you're right! Sorry about that. Looks like a non issue. Worked with:
env <- ask :: RWST String (Array String) String Identity String
garyb commented
I've been tripped up by that one so many times lately 😄
ethul commented
Definitely just tripped me up! Thanks for the help :)