Commit 8f6af346 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Test Trac #7649

parent 9781d940
{-# LANGUAGE ViewPatterns, BangPatterns #-}
module Main where
import Control.Exception
main :: IO ()
main = do print (f False)
print (f True)
print (g undefined) `catchE` \_ -> putStrLn "g exception"
print (h undefined) `catchE` \_ -> putStrLn "h exception"
print (i undefined) `catchE` \_ -> putStrLn "i exception"
putStrLn "Done"
catchE :: IO a -> (ErrorCall -> IO a) -> IO a
catchE = catch
f :: Bool -> String
f (view -> Nothing) = "Got Nothing"
f (view -> Just x) = "Got Just " ++ show x
g :: Bool -> String
g (view -> x) = "g Got something"
h :: Bool -> String
h (view -> !x) = "h Got something"
i :: Bool -> String
i !(view -> x) = "i Got something"
view :: Bool -> Maybe Int
view False = Nothing
view True = Just 5
"Got Nothing"
"Got Just 5"
"g Got something"
h exception
i exception
Done
......@@ -6,4 +6,4 @@ test('strun002', exit_code(1), compile_and_run, [''])
test('strun003', normal, compile_and_run, [''])
test('strun004', normal, compile_and_run, [''])
test('T2756b', normal, compile_and_run, [''])
test('T7649', normal, compile_and_run, [''])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment