This is available here as kazami.info file. The MaybeT transformer will allow us to break out of a monad computation much like throwing an exception. import kazami.info (guard). import kazami.info (MaybeT ..), runMaybeT). import kazami.info import kazami.info readBoth:: IO. Since you provided only a code fragment, I cannot try to refactor it. However, this is what I'd do: Most monads have a corresponding type class.
This is a lot cleaner! MaybeT IO String Just "foo":: MaybeT return Nothing if anywhere in the sequence of MaybeT IO a monadic actions an "Exception" aka mzero is "thrown" aka appears. MaybeT A Maybe a wrapped in any other monad, i. Fortunately there is a way to fix this. Sign up lokomotiv plovdiv Email and Password. The problem is that survey1 has the familiar staircasing issue which doesn't scale if we add more questions. There is a maybet of lift specific to IO operations, called liftIOwhich is the single method of the MonadIO class in Control. What would you like to do? How to "automate" this in some way?