[Haskell] Force evaluation

Jules Bean jules at jellybean.co.uk
Mon Dec 6 11:27:42 EST 2004

On 6 Dec 2004, at 15:24, Michael Walter wrote:

> Hi,
> is there a way to force the "full" evaluation of a value (unless seq,
> which only brings the term to WHNF)?
> In my case, I have an algebraic data type Foo,
> and I would like to catch the exceptions that will occur during the
> evaluation of a value of Foo, for something like:
>   foo <- force makeFoo `catch` \e -> defaultFoo

Depending on what kind of exceptions you are working with, you may 
prefer to use the 'MonadError' routines over the 'Either' monad. When 
you work in Either you can be sure that the value has been sufficiently 
evaluated to check whether or not an error occurs.

If you want to catch asynchronous, OS-level exceptions then Either 
isn't good enough.


More information about the Haskell mailing list