blob: 2bdd2a679ecd60a674ac71d8727fac2e5d7ff70e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
{-# LANGUAGE GADTs #-}
module DmdAnalGADTs where
-- This tests the effect of different types in branches of a case
data D a where
A :: D Int
B :: D (Int -> Int)
-- Doesn't have the CPR property anymore (#18154), but an expandable unfolding.
-- The point of this test is that f' has the CPR property.
hasCPR :: Int
hasCPR = 1
hasStrSig :: Int -> Int
hasStrSig x = x + 1
diverges :: Int
diverges = diverges
-- The result should not have a CPR property
-- Because we are lub’ing "m" and "<L>m" in the case expression.
f :: D x -> x
f x = case x of
A -> hasCPR
B -> hasStrSig
-- This should have the CPR property
f' :: D Int -> Int
f' x = case x of
A -> hasCPR
-- The result should not be diverging, because one branch is terminating.
-- It should also put a strict, but not hyperstrict demand on x
g :: D x -> x
g x = case x of
A -> diverges
B -> \_ -> diverges
|