diff options
Diffstat (limited to 'testsuite/tests/stranal')
-rw-r--r-- | testsuite/tests/stranal/sigs/T5075.hs | 34 | ||||
-rw-r--r-- | testsuite/tests/stranal/sigs/T5075.stderr | 12 |
2 files changed, 36 insertions, 10 deletions
diff --git a/testsuite/tests/stranal/sigs/T5075.hs b/testsuite/tests/stranal/sigs/T5075.hs index c35409aa67..15b1357446 100644 --- a/testsuite/tests/stranal/sigs/T5075.hs +++ b/testsuite/tests/stranal/sigs/T5075.hs @@ -1,11 +1,31 @@ --- | This module currently asserts that we trim CPR for local bindings --- returning a sum. We can hopefully give @loop@ a CPR signature some day, but --- we first have to fix #5075/#16570. +-- | This module currently asserts that we give functions that always return +-- the same constructor of a sum type the CPR property. module T5075 where -- Omission of the type signature is deliberate, otherwise we won't get a join -- point (this is up to the desugarer, not sure why). --- loop :: (Ord a, Num a) => a -> Either a b -loop x = case x < 10 of - True -> Left x - False -> loop (x*2) +-- f :: (Ord a, Num a) => a -> Either a b +f x = case x < 10 of + True -> Left x + False -> f (x*2) + +-- Similarly a join point. Should WW nonetheless +g :: Int -> Int -> Maybe Int +g x y = go x + where + go x = case x < y of + True -> Just x + False -> go (x*2) + +-- Here, go is not a join point, but still should be WW'd for Just. +-- Unfortunately, CPR can't see that (+?) returns Just, so h won't get the CPR +-- property. It probably could by only considering the @Just@ case of the +-- inlined (+?). +h :: Int -> Maybe Int +h x = go x +? go (x+1) + where + Just x +? Just y = Just (x + y) + _ +? _ = Nothing + go z + | z > 10 = Just (x + z) + | otherwise = go (z*2) diff --git a/testsuite/tests/stranal/sigs/T5075.stderr b/testsuite/tests/stranal/sigs/T5075.stderr index e17d5e7c5c..c9625db721 100644 --- a/testsuite/tests/stranal/sigs/T5075.stderr +++ b/testsuite/tests/stranal/sigs/T5075.stderr @@ -1,18 +1,24 @@ ==================== Strictness signatures ==================== T5075.$trModule: -T5075.loop: <SP(A,A,SCS(C1(L)),A,A,A,A,A)><LP(A,A,LCL(C1(L)),A,A,A,L)><L> +T5075.f: <SP(A,A,SCS(C1(L)),A,A,A,A,A)><LP(A,A,LCL(C1(L)),A,A,A,L)><L> +T5075.g: <1P(L)><SP(L)> +T5075.h: <SP(L)> ==================== Cpr signatures ==================== T5075.$trModule: -T5075.loop: +T5075.f: 1 +T5075.g: 2(1) +T5075.h: ==================== Strictness signatures ==================== T5075.$trModule: -T5075.loop: <1P(A,A,SCS(C1(L)),A,A,A,A,A)><LP(A,A,LCL(C1(L)),A,A,A,L)><L> +T5075.f: <1P(A,A,SCS(C1(L)),A,A,A,A,A)><LP(A,A,LCL(C1(L)),A,A,A,L)><L> +T5075.g: <1P(L)><SP(L)> +T5075.h: <1P(L)> |