[Haskell] IO, exceptions and error handling
Keith.Wansbrough at cl.cam.ac.uk
Mon Jun 14 12:41:03 EDT 2004
> 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
> sqr x | x < 0 = fail "less than zero"
> | otherwise = return (sqrt x)
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.
Keith Wansbrough <kw217 at cl.cam.ac.uk>
University of Cambridge Computer Laboratory.
More information about the Haskell