3 import Prelude hiding (catch)
16 ioTest = catchIO (fail (userError "wibble"))
17 (\ex -> if isUserError ex then putStr "io exception caught\n"
21 errorTest = case getExceptions (1 + error "call to 'error'") of
22 Left exceptions -> putStr "error call caught\n"
23 Right val -> error "help!"
25 instance (Show a, Eq a) => Num (Maybe a) where {}
28 noMethodTest = catch (case Just () + Just () of Nothing -> return ())
29 (\exs -> case unsafePromiseSingleton exs of
30 NoMethodError err -> putStr "no method error\n"
31 other -> error "help!")
34 patMatchTest = catchOne (case test1 [1..10] of () -> return ())
36 PatternMatchFail err -> putStr err
37 other -> error "help!")
41 guardTest = catchOne (case test2 of () -> return ())
43 NonExhaustiveGuards err -> putStr err
44 other -> error "help!")
46 test2 | all (==0) [1] = ()
48 dynTest = catchDyn (case throwDyn (42::Int, (+1)::Int->Int) of () -> return ())
49 (\(i,f) -> let x = f (i::Int) :: Int in putStr (show x))