
1 Dec
2004
1 Dec
'04
6:11 a.m.
On Tue, 30 Nov 2004 18:36:46 +0000 (UTC), Pavel Zolnikov
[..] 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