
23 Jan
2005
23 Jan
'05
6:06 a.m.
In article <200501230458.57938.jadrian@mat.uc.pt>,
Jorge Adriano Aires
One common example is using MonadPlus for some backtracking algorithm, then instantiatiating it to Maybe or List instance depending on wether you just want one solution or all of them.
Backtracking only works with the first kind, even if you're only interested in the first solution. This must hold: (mplus a b) >>= c = mplus (a >>= c) (b >>= c) My test code is a backtracking example: do b <- mplus (return True) (return False) if b then mzero else return ()
[*] For instance, I've missed Maybe being an instance of MonadError.
You could define your own instance, of course. -- Ashley Yakeley, Seattle WA