[Haskell-cafe] Re: not possible with monad transformers ?

Josef Svenningsson josef.svenningsson at gmail.com
Wed Dec 1 06:11:35 EST 2004


On Tue, 30 Nov 2004 18:36:46 +0000 (UTC), Pavel Zolnikov
<pavelzolnikov at yahoo.com> wrote:
> [..]
> type M2 a = OuptutMonadT Maybe String a
> whenError:: M2 a -> M2 a -> M2 a …
> 
> 1   foo a b = do
> 2      output "before"
> 3      let r = liftM2 (+) a b 
> 4       `whenError` $ reportError "error"
> 5      return r
> 
> whenError combines two computations so that if first fails it will use
> second instead.
> 
FYI, this is what the class MonadPlus is meant for. Check out the
Monad module in the standard library.

/Josef


More information about the Haskell-Cafe mailing list