wren-extras-2011.7.13: wren ng thornton's random collection of extras

Portabilityvaguely portable (with CPP)
Stabilityexperimental
Maintainerwren@community.haskell.org

Control.Exception.Extras

Description

This module provides additional combinators for Control.Exception, namely for pure computations.

error throws ErrorCall which is a Control.Monad.Exception, whereas Prelude.catch only catches IOError. Control.Exception is non-Haskell98 and so technically non-portable, but it's supported by all extant compilers as of early 2009.

In GHC 6.10 the switch was made to extensible exceptions, which may not be portable to other compilers. We use CPP to distinguish between the older GHC 6.8 exceptions and the new ones, but we deal with them all the same.

Synopsis

Documentation

safely :: (a -> b) -> a -> Maybe bSource

Apply a function safely, capturing all errors as Nothing. Since we don't look at the exception thrown, this is continuous (and so fairly okay). But since there's no way to catch infinite loops, there's still an indeterminism about catching an exception vs looping forever (so this technically isn't safe in the strictest possible sense).

See also http://www.haskell.org/pipermail/haskell-cafe/2009-March/057778.html