Maybe I'm doing something stupid here, but I'm getting:
No instance for (MonadException Ti)
arising from a use of `getInputLine'
in the code sample:
module Foo where
import System.Console.Haskeline
import System.Console.Haskeline.MonadException
import Control.Monad.State
import Control.Monad.IO.Class
type Ti = StateT Int IO
action :: String -> Ti ()
action s = do
n <- get
lift $ putStrLn $ show n ++ ": " ++ s
repl :: InputT Ti ()
repl = do
minput <- getInputLine "?"
case minput of
Nothing -> return ()
Just input -> lift (action input) >> repl
Now, System.Console.Haskeline.MonadException
defines
MonadException IO
(MonadIO (StateT s m), MonadException m) => MonadException (StateT s m)
and Control.Monad.IO.Class
:
MonadIO IO
MonadIO m => MonadIO (StateT s m)
So, shouldn't it deduce the instance for Ti
automatically?
There is no instance for the Lazy state transformer, just the strict one. Use import Control.Monad.State.Strict
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With