There is flexible exception handling in Haskell?

Wolfgang Jeltsch wolfgang at
Tue Nov 18 13:24:46 EST 2003

Am Dienstag, 18. November 2003, 02:40 schrieb Bernard James POPE:
> Sometimes you can just encode your exceptional values in some type. It tends
> to be more declarative than throwing/catching exceptions:
>    data Result = Ok Int | ThisError | ThatError String | SomeError Int ...

I think, it's better to combine all the different error cases like:
    data Result = Ok Int | Error error
    data Error = ThisError | ThatError String | SomeError Int ...

It can get cumbersome if you always have to deal with errors explicitely in 
your code instead of just doing your calculations and letting the run-time 
system or whatever deal with the errors, so you might be tempted to use 
exceptions. But have a look at the module Control.Monad.Error. It provides 
you with support for dealing with exceptional situations without using the IO 
monad or special run-time system support.

> [...]


More information about the Haskell-Cafe mailing list