14 Jun
2004
14 Jun
'04
4:30 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) If so, I don't see how I can use this without either do or >>=: test x = do v1 <- sqr x v2 <- sqr (x+1) return (v1+v2) I can't (easily) write text c = sqr x + sqr (x+1) which was what I was getting at. Tim