diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2015-06-26 11:40:01 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2015-06-26 17:53:22 +0100 |
commit | 0696fc6d4de28cb589f6c751b8491911a5baf774 (patch) | |
tree | af20b546dbd408fba284cadeeded66f089d11fb7 /testsuite/tests/stranal/should_compile/T10482.hs | |
parent | caf9d427d423a8ff63fd4c5a1332d058004751ff (diff) | |
download | haskell-0696fc6d4de28cb589f6c751b8491911a5baf774.tar.gz |
Improve CPR behavior for strict constructors
When working on Trac #10482 I noticed that we could give constructor
arguments the CPR property if they are use strictly.
This is documented carefully in
Note [CPR in a product case alternative]
and also
Note [Initial CPR for strict binders]
There are a bunch of intersting examples in
Note [CPR examples]
which I have added to the test suite as T10482a.
I also added a test for #10482 itself.
Diffstat (limited to 'testsuite/tests/stranal/should_compile/T10482.hs')
-rw-r--r-- | testsuite/tests/stranal/should_compile/T10482.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/testsuite/tests/stranal/should_compile/T10482.hs b/testsuite/tests/stranal/should_compile/T10482.hs new file mode 100644 index 0000000000..ef7c29c4be --- /dev/null +++ b/testsuite/tests/stranal/should_compile/T10482.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE TypeFamilies #-} +module T10482 where + +data family Foo a +data instance Foo (a, b) = FooPair !(Foo a) !(Foo b) +newtype instance Foo Int = Foo Int + +foo :: Foo ((Int, Int), Int) -> Int -> Int +foo !f k = + if k == 0 then 0 + else if even k then foo f (k-1) + else case f of + FooPair (FooPair (Foo n) _) _ -> n |