[Haskell-cafe] MonadError vs Control.Exception

Станислав Черничкин schernichkin at gmail.com
Sat May 5 01:03:10 CEST 2012

Hi, guys, I'm interested in best practices in using of each approach.
Personally I like MonadError because it is more explicit and
Control.Exception-s becomes really ugly in complex scenarios.

Here an example to illustrate my idea:
All network-conduit functions can raise IOException because of
Socket-related stuff (and actually entire network-conduit is written
to deal with IOException correctry) + Bind-port can raise ErrorCall
(came from error "bindPort: addrs is empty"). User has to deal with
both, but have no evidence on none of them from type signatures or
documentation. Moreover, ErrorCall in this case can be caused by
IOException (we try to bind only available address, we get IOException
exception, we have no more address to try and raise ErrorCall), and I
really don’t understand, why it should be treated in a different way.

So, I hate exceptions, I blame it, I think exceptions is junk came
from OO-world and horrible languages like C# or even more horrible
like Java, and it should be wiped out from Haskell with fire. But it
is only my humble opinion. Reality shows that Haskell provides
extensive support for exceptions, it included in base libraries and
everyone uses it, but MonadError is modest part of mtl, and don’t even
have “bracket” and other useful functions. That is why I’m really
interested in any your ideas and experience on using these approaches.

Cheers, Stasik.

More information about the Haskell-Cafe mailing list