diff options
Diffstat (limited to 'testsuite/tests/codeGen/should_run/cgrun050.hs')
-rw-r--r-- | testsuite/tests/codeGen/should_run/cgrun050.hs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_run/cgrun050.hs b/testsuite/tests/codeGen/should_run/cgrun050.hs new file mode 100644 index 0000000000..7eb2cee05f --- /dev/null +++ b/testsuite/tests/codeGen/should_run/cgrun050.hs @@ -0,0 +1,23 @@ +-- !! Test strict, recursive newtypes +-- This test made a pre-5.02 fall over +-- Reason: the seq arising from the !F didn't see that +-- the represtation of F is a function. + +-- NB It's crucial to compile this test *without* -O +-- The $ then prevents the 'F' from seeing the '\x' +-- and hence makes the evaluation happen at runtime + +module Main ( main ) where + +newtype F = F (Int -> Val) -- NB: F and Val are +data Val = VFn !F | VInt !Int -- mutually recursive + +f :: Val -> Val +f (VFn (F f)) = f 4 + +main = print (f (VFn (F $ (\x -> VInt (x+3))))) + +instance Show Val where + show (VInt n) = show n + + |