[Haskell] SOLVED Catching error / making library functions monadic (in failure)

Philip K.F. Hölzenspies p.k.f.holzenspies at utwente.nl
Thu Oct 9 03:51:57 EDT 2008

Dear all,

Thank you very much for your reactions. Neil told me I should have posted this 
in haskell-cafe, so sorry for the inconvenience. Since my problem has since 
been solved, I figured I would send this "thanks all, it's solve" e-mail to 
the list, to close the issue.

The magic answer turned out to be Control.Exception.evaluate as opposed to 
return. This was the problem:

catch (return $ [] !! 0) (error "foo")

(which I had oversimplified by omitting the return) gave

*** Exception: Prelude.(!!): index too large


catch (evaluate $ [] !! 0) (error "foo")


*** Exception: bar

even when unsafePerformIO was applied to it.

Thank you all, but especially the people that suggested this: Martijn & Koen


More information about the Haskell mailing list