pattern match failure as control structure

hey all, is there something special about pattern match exceptions? i'm attempting to catch pattern match failures to use as control for a production system. so i want to be able to do something like catch (head []) (\e -> print "that theres pattern fail!" ) any suggestions?

Have a look at this recently uploaded package: http://hackage.haskell.org/package/first-class-patterns Examine the "tryMatch" function in particular.

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
Have a look at this recently uploaded package:
http://hackage.haskell.org/package/first-class-patterns
Examine the "tryMatch" function in particular.

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
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... -- Nicolas Pouillard http://nicolaspouillard.fr

thanks, i've got it working
i'll probably post the code when i'm done
On Tue, Nov 10, 2009 at 3:01 PM, Nicolas Pouillard
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
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...
-- Nicolas Pouillard http://nicolaspouillard.fr
participants (3)
-
Dan Mead
-
Nicolas Pouillard
-
Roel van Dijk