diff options
author | Joachim Breitner <mail@joachim-breitner.de> | 2013-12-09 17:45:48 +0000 |
---|---|---|
committer | Joachim Breitner <mail@joachim-breitner.de> | 2013-12-09 17:45:48 +0000 |
commit | 08d21c45eddb412dd3568a46dbbdce55fb5be831 (patch) | |
tree | a6d4187c57f180cafb90091b9f053b55e7053ddb /testsuite/tests/stranal/sigs/UnsatFun.hs | |
parent | 9e84e1325d1aa182688f0ab23bb894aca177c4dd (diff) | |
download | haskell-08d21c45eddb412dd3568a46dbbdce55fb5be831.tar.gz |
Demand Analyser testcase: Unsaturated functions
Diffstat (limited to 'testsuite/tests/stranal/sigs/UnsatFun.hs')
-rw-r--r-- | testsuite/tests/stranal/sigs/UnsatFun.hs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/testsuite/tests/stranal/sigs/UnsatFun.hs b/testsuite/tests/stranal/sigs/UnsatFun.hs new file mode 100644 index 0000000000..23ba6426cd --- /dev/null +++ b/testsuite/tests/stranal/sigs/UnsatFun.hs @@ -0,0 +1,29 @@ +module UnsatFun where + +-- Here we test how a partially applied function (f x) +-- with a bottom result affects the strictness signature +-- when used strictly (g) and lazily (g') +-- +-- In both cases, the parameter x should not be absent + +f :: Int -> Int -> Int +f x y = error (show x) +{-# NOINLINE f #-} + +h :: (Int -> Int) -> Int +h f = f 2 +{-# NOINLINE h #-} + +h2 :: Bool -> (Int -> Int) -> Int +h2 True _ = 0 +h2 False f = f 2 +{-# NOINLINE h2 #-} + +-- Should get a bottom result +g :: Int -> Int +g x = let f' = f x + in h f' + +g2 :: Int -> Int +g2 x = let f' = f x + in h2 True f' |