14 Jun
2004
14 Jun
'04
10:43 p.m.
On Mon, Jun 14, 2004 at 05:41:03PM +0100, Keith Wansbrough wrote:
Philippa Cowderoy wrote:
The ability to fail doesn't need the do notation, just use of return for success - similar for propagating failure.
I'm not sure I understand. Do you mean writing functions like:
sqr x | x < 0 = fail "less than zero" | otherwise = return (sqrt x)
s/fail/error/ s/return//
better yet, import Control.Monad.Identity sqr' x = runIdentity (sqr x) now sqr' behaves exactly as if you used 'error' and direct code, but the monadic version is still available for those that care about it. John -- John Meacham - ⑆repetae.net⑆john⑈