[Haskell-cafe] Newbie: Is it possible to catch _|_ ?

Jon Cast jcast at ou.edu
Tue Apr 6 14:33:06 EDT 2004

Russ Lewis <spamhole-2001-07-16 at deming-os.org> wrote:

> Another newbie question: Is it possible to catch _|_ - that is, to 
> encounter it, handle it and continue?  I'm assuming that you all are 
> going to say no, since I can't figure out any way to do this and retain 
> the functional nature of Haskell.

This isn't possible in a deterministic language, for several reasons.
The IO monad, however, is non-deterministic, and its `catch' function
can be used to catch any _|_ value that can be caught, specifically
those arising from calls to throw, error, and certain infinite loops.
It is non-deterministic, though, so it won't catch all _|_s, nor will it
give any guarantee as to which _|_ it will catch (for example, in error
3 + throw (DynException (toDynamic False)) it's indeterminate whether
error's return value or throw's return value will ultimately be caught.

Jon Cast

More information about the Haskell-Cafe mailing list