3 import Prelude hiding (catch)
5 import IO hiding (try, catch)
16 ioTest = catchJust userErrors (ioError (userError "wibble"))
17 (\ex -> putStr "user exception caught\n")
20 errorTest = try (evaluate (1 + error "call to 'error'")) >>= \r ->
22 Left exception -> putStr "error call caught\n"
23 Right _ -> error "help!"
25 instance (Show a, Eq a) => Num (Maybe a) where {}
28 noMethodTest = try (evaluate (Just () + Just ())) >>= \ r ->
30 Left (NoMethodError err) -> putStr "no method error\n"
31 Right _ -> error "help!"
34 patMatchTest = catch (case test1 [1..10] of () -> return ())
36 PatternMatchFail err -> putStr err
37 other -> error "help!")
41 guardTest = catch (case test2 of () -> return ())
43 PatternMatchFail 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))