% This file written and placed in the public domain by Ganesh Sittampalam, 2007

\begin{code}
module UnsafeCatch (unsafeCatch) where

import Prelude hiding (catch)
import Control.Exception
import System.IO.Unsafe (unsafePerformIO)

unsafeCatch :: a -> (Exception -> a) -> a
unsafeCatch x f = unsafePerformIO ((x `seq` return x) `catch` (return . f))

\end{code}