[Haskell-cafe] pattern match failure as control structure

Nicolas Pouillard nicolas.pouillard at gmail.com
Tue Nov 10 15:01:24 EST 2009

Excerpts from Dan Mead's message of Tue Nov 10 20:23:26 +0100 2009:
> i think that may be too in depth.
> all i'm trying to do is catch a regular pattern match exception
> On Tue, Nov 10, 2009 at 5:50 AM, Roel van Dijk <vandijk.roel at gmail.com> wrote:
> > Have a look at this recently uploaded package:
> >
> > http://hackage.haskell.org/package/first-class-patterns
> >
> > Examine the "tryMatch" function in particular.

You can do this with Control.Exception.evaluate [1]. However
while it looks like what you want I recommend you to not use
it too often, catching "error" calls is not the best way of using
Haskell. However if this is for debugging purpose or setting up
a global exception catcher for a final product then this is fine.

[1]: http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Exception.html#8

Nicolas Pouillard

More information about the Haskell-Cafe mailing list