Working in Dojo encoding today I tried the following
example :: IO () example = do input <- getLine parsed <- parseOnly parser input ...
where parseOnly :: Parser a -> Either String a (from attoparsec ), of course, the compiler complained that Either .. not IO .. essentially tells me that I am mixing monads.
Of course, this can be solved with
case parseOnly parser input of .. -> ..
which, it seems to me, is ridiculous. I also assume that someone else had this problem before, and the solution, I think, is connected with monad transformers, but I canβt put the last bits together.
It also reminded me of liftIO , but in another way I think it solves the problem of raising the action of the EUT that occurs inside some surrounding monad (more precisely, MonadIO - for example, inside Snap , when one wants to print something before stdout , getting some http )
A more general problem arises for Monad m1 and (other) Monad m2 , how can I do something like
example = do a <- m1Action b <- m2Action ..
haskell monads monad-transformers
epsilonhalbe
source share