14 Jun
2004
14 Jun
'04
4:41 p.m.
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// Then you can easily write
I can't (easily) write
text c = sqr x + sqr (x+1)
You just can't *catch* this outside the IO monad. --KW 8-) -- Keith Wansbrough <kw217@cl.cam.ac.uk> http://www.cl.cam.ac.uk/users/kw217/ University of Cambridge Computer Laboratory.