3 import Prelude hiding (catch)
5 import IO hiding (try, catch)
16 ioTest = catchIO justIoErrors (ioError (userError "wibble"))
17 (\ex -> if isUserError ex then putStr "io exception caught\n"
21 errorTest = tryAll (1 + error "call to 'error'") >>= \r ->
23 Left exception -> putStr "error call caught\n"
24 Right _ -> error "help!"
26 instance (Show a, Eq a) => Num (Maybe a) where {}
29 noMethodTest = tryAll (Just () + Just ()) >>= \ r ->
31 Left (NoMethodError err) -> putStr "no method error\n"
32 Right _ -> error "help!"
35 patMatchTest = catchAllIO (case test1 [1..10] of () -> return ())
37 PatternMatchFail err -> putStr err
38 other -> error "help!")
42 guardTest = catchAllIO (case test2 of () -> return ())
44 PatternMatchFail err -> putStr err
45 other -> error "help!")
47 test2 | all (==0) [1] = ()
49 dynTest = catchDyn (case throwDyn (42::Int, (+1)::Int->Int) of () -> return ())
50 (\(i,f) -> let x = f (i::Int) :: Int in putStr (show x))