diff options
Diffstat (limited to 'testsuite/tests/stranal/sigs')
27 files changed, 216 insertions, 193 deletions
diff --git a/testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr b/testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr index 075a819db8..1c944f8520 100644 --- a/testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr +++ b/testsuite/tests/stranal/sigs/BottomFromInnerLambda.stderr @@ -1,20 +1,17 @@ ==================== Strictness signatures ==================== -BottomFromInnerLambda.$trModule: BottomFromInnerLambda.expensive: <1!P(SL)> BottomFromInnerLambda.f: <1!P(SL)> ==================== Cpr signatures ==================== -BottomFromInnerLambda.$trModule: BottomFromInnerLambda.expensive: 1 BottomFromInnerLambda.f: ==================== Strictness signatures ==================== -BottomFromInnerLambda.$trModule: BottomFromInnerLambda.expensive: <1!P(1L)> BottomFromInnerLambda.f: <1!P(1L)> diff --git a/testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr b/testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr index 2ed48eed70..2f7b6376f0 100644 --- a/testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr +++ b/testsuite/tests/stranal/sigs/DmdAnalGADTs.stderr @@ -1,9 +1,5 @@ ==================== Strictness signatures ==================== -DmdAnalGADTs.$tc'A: -DmdAnalGADTs.$tc'B: -DmdAnalGADTs.$tcD: -DmdAnalGADTs.$trModule: DmdAnalGADTs.diverges: b DmdAnalGADTs.f: <1L> DmdAnalGADTs.f': <1L> @@ -14,10 +10,6 @@ DmdAnalGADTs.hasStrSig: <1!P(L)> ==================== Cpr signatures ==================== -DmdAnalGADTs.$tc'A: -DmdAnalGADTs.$tc'B: -DmdAnalGADTs.$tcD: -DmdAnalGADTs.$trModule: DmdAnalGADTs.diverges: b DmdAnalGADTs.f: DmdAnalGADTs.f': 1 @@ -28,10 +20,6 @@ DmdAnalGADTs.hasStrSig: 1 ==================== Strictness signatures ==================== -DmdAnalGADTs.$tc'A: -DmdAnalGADTs.$tc'B: -DmdAnalGADTs.$tcD: -DmdAnalGADTs.$trModule: DmdAnalGADTs.diverges: b DmdAnalGADTs.f: <1L> DmdAnalGADTs.f': <1L> diff --git a/testsuite/tests/stranal/sigs/HyperStrUse.stderr b/testsuite/tests/stranal/sigs/HyperStrUse.stderr index 08caf32af4..23c437158e 100644 --- a/testsuite/tests/stranal/sigs/HyperStrUse.stderr +++ b/testsuite/tests/stranal/sigs/HyperStrUse.stderr @@ -1,18 +1,15 @@ ==================== Strictness signatures ==================== -HyperStrUse.$trModule: HyperStrUse.f: <1!P(1!P(L),A)><1L> ==================== Cpr signatures ==================== -HyperStrUse.$trModule: HyperStrUse.f: 1 ==================== Strictness signatures ==================== -HyperStrUse.$trModule: HyperStrUse.f: <1!P(1!P(L),A)><1L> diff --git a/testsuite/tests/stranal/sigs/NewtypeArity.stderr b/testsuite/tests/stranal/sigs/NewtypeArity.stderr index 45bc691802..7190bedc35 100644 --- a/testsuite/tests/stranal/sigs/NewtypeArity.stderr +++ b/testsuite/tests/stranal/sigs/NewtypeArity.stderr @@ -1,26 +1,17 @@ ==================== Strictness signatures ==================== -Test.$tc'MkT: -Test.$tcT: -Test.$trModule: Test.t: <1!P(L)><1!P(L)> Test.t2: <1!P(L)><1!P(L)> ==================== Cpr signatures ==================== -Test.$tc'MkT: -Test.$tcT: -Test.$trModule: Test.t: 1 Test.t2: 1 ==================== Strictness signatures ==================== -Test.$tc'MkT: -Test.$tcT: -Test.$trModule: Test.t: <1!P(L)><1!P(L)> Test.t2: <1!P(L)><1!P(L)> diff --git a/testsuite/tests/stranal/sigs/StrAnalExample.stderr b/testsuite/tests/stranal/sigs/StrAnalExample.stderr index 80855b392e..08485e735a 100644 --- a/testsuite/tests/stranal/sigs/StrAnalExample.stderr +++ b/testsuite/tests/stranal/sigs/StrAnalExample.stderr @@ -1,18 +1,15 @@ ==================== Strictness signatures ==================== -StrAnalExample.$trModule: StrAnalExample.foo: <1L> ==================== Cpr signatures ==================== -StrAnalExample.$trModule: StrAnalExample.foo: ==================== Strictness signatures ==================== -StrAnalExample.$trModule: StrAnalExample.foo: <1L> diff --git a/testsuite/tests/stranal/sigs/T12370.stderr b/testsuite/tests/stranal/sigs/T12370.stderr index dc7dbdd2e5..3070069a1a 100644 --- a/testsuite/tests/stranal/sigs/T12370.stderr +++ b/testsuite/tests/stranal/sigs/T12370.stderr @@ -1,20 +1,17 @@ ==================== Strictness signatures ==================== -T12370.$trModule: T12370.bar: <1!P(L)><1!P(L)> T12370.foo: <1!P(1!P(L),1!P(L))> ==================== Cpr signatures ==================== -T12370.$trModule: T12370.bar: 1 T12370.foo: 1 ==================== Strictness signatures ==================== -T12370.$trModule: T12370.bar: <1!P(L)><1!P(L)> T12370.foo: <1!P(1!P(L),1!P(L))> diff --git a/testsuite/tests/stranal/sigs/T13331.stderr b/testsuite/tests/stranal/sigs/T13331.stderr index 78cccb7fe4..feebb4eaa1 100644 --- a/testsuite/tests/stranal/sigs/T13331.stderr +++ b/testsuite/tests/stranal/sigs/T13331.stderr @@ -1,27 +1,15 @@ ==================== Strictness signatures ==================== -T13331.$tc'Bin: -T13331.$tc'Tip: -T13331.$tcMap: -T13331.$trModule: T13331.naiveInsertInt: <1L><L><1L> ==================== Cpr signatures ==================== -T13331.$tc'Bin: -T13331.$tc'Tip: -T13331.$tcMap: -T13331.$trModule: T13331.naiveInsertInt: ==================== Strictness signatures ==================== -T13331.$tc'Bin: -T13331.$tc'Tip: -T13331.$tcMap: -T13331.$trModule: T13331.naiveInsertInt: <1L><L><1L> diff --git a/testsuite/tests/stranal/sigs/T13380f.stderr b/testsuite/tests/stranal/sigs/T13380f.stderr index 4b17ceae85..1da38aeeee 100644 --- a/testsuite/tests/stranal/sigs/T13380f.stderr +++ b/testsuite/tests/stranal/sigs/T13380f.stderr @@ -1,6 +1,5 @@ ==================== Strictness signatures ==================== -T13380f.$trModule: T13380f.f: <1!P(L)><1!P(L)><L> T13380f.g: <1!P(L)><ML><L> T13380f.h: <1!P(L)><ML><L> @@ -11,7 +10,6 @@ T13380f.unsafeCall: <L> ==================== Cpr signatures ==================== -T13380f.$trModule: T13380f.f: 1(, 1) T13380f.g: 1(, 1) T13380f.h: 1(, 1) @@ -22,7 +20,6 @@ T13380f.unsafeCall: 1(, 1) ==================== Strictness signatures ==================== -T13380f.$trModule: T13380f.f: <1!P(L)><1!P(L)><L> T13380f.g: <1!P(L)><ML><L> T13380f.h: <1!P(L)><ML><L> diff --git a/testsuite/tests/stranal/sigs/T16197b.stderr b/testsuite/tests/stranal/sigs/T16197b.stderr index ec45df4202..d4c250b44a 100644 --- a/testsuite/tests/stranal/sigs/T16197b.stderr +++ b/testsuite/tests/stranal/sigs/T16197b.stderr @@ -1,30 +1,15 @@ ==================== Strictness signatures ==================== -T16197b.$tc'Box: -T16197b.$tc'T: -T16197b.$tcBox: -T16197b.$tcT: -T16197b.$trModule: T16197b.f: <1!P(L)> ==================== Cpr signatures ==================== -T16197b.$tc'Box: -T16197b.$tc'T: -T16197b.$tcBox: -T16197b.$tcT: -T16197b.$trModule: T16197b.f: 1 ==================== Strictness signatures ==================== -T16197b.$tc'Box: -T16197b.$tc'T: -T16197b.$tcBox: -T16197b.$tcT: -T16197b.$trModule: T16197b.f: <1!P(L)> diff --git a/testsuite/tests/stranal/sigs/T16859.stderr b/testsuite/tests/stranal/sigs/T16859.stderr index 37718134a2..6dd199c07c 100644 --- a/testsuite/tests/stranal/sigs/T16859.stderr +++ b/testsuite/tests/stranal/sigs/T16859.stderr @@ -1,11 +1,5 @@ ==================== Strictness signatures ==================== -T16859.$tc'External: -T16859.$tc'Internal: -T16859.$tc'Name: -T16859.$tcName: -T16859.$tcNameSort: -T16859.$trModule: T16859.bar: <1!A><L> T16859.baz: <1L><1!P(L)><1C1(L)> T16859.buz: <1!P(L,L)> @@ -19,12 +13,6 @@ T16859.n_uniq: <1!P(A,A,L,A)> ==================== Cpr signatures ==================== -T16859.$tc'External: -T16859.$tc'Internal: -T16859.$tc'Name: -T16859.$tcName: -T16859.$tcNameSort: -T16859.$trModule: T16859.bar: 1 T16859.baz: 1 T16859.buz: 1 @@ -38,12 +26,6 @@ T16859.n_uniq: 1 ==================== Strictness signatures ==================== -T16859.$tc'External: -T16859.$tc'Internal: -T16859.$tc'Name: -T16859.$tcName: -T16859.$tcNameSort: -T16859.$trModule: T16859.bar: <1!A><L> T16859.baz: <L><1!P(L)><1C1(L)> T16859.buz: <1!P(L,L)> diff --git a/testsuite/tests/stranal/sigs/T17932.stderr b/testsuite/tests/stranal/sigs/T17932.stderr index dadd60b491..52b365bcc2 100644 --- a/testsuite/tests/stranal/sigs/T17932.stderr +++ b/testsuite/tests/stranal/sigs/T17932.stderr @@ -1,30 +1,15 @@ ==================== Strictness signatures ==================== -T17932.$tc'Options: -T17932.$tc'X: -T17932.$tcOptions: -T17932.$tcX: -T17932.$trModule: T17932.flags: <1!P(1L,1L)> ==================== Cpr signatures ==================== -T17932.$tc'Options: -T17932.$tc'X: -T17932.$tcOptions: -T17932.$tcX: -T17932.$trModule: T17932.flags: ==================== Strictness signatures ==================== -T17932.$tc'Options: -T17932.$tc'X: -T17932.$tcOptions: -T17932.$tcX: -T17932.$trModule: T17932.flags: <1!P(1L,1L)> diff --git a/testsuite/tests/stranal/sigs/T18086.stderr b/testsuite/tests/stranal/sigs/T18086.stderr index 1748a0c145..ce14711025 100644 --- a/testsuite/tests/stranal/sigs/T18086.stderr +++ b/testsuite/tests/stranal/sigs/T18086.stderr @@ -1,20 +1,17 @@ ==================== Strictness signatures ==================== -T18086.$trModule: T18086.m: <L>x T18086.panic: <L>x ==================== Cpr signatures ==================== -T18086.$trModule: T18086.m: b T18086.panic: b ==================== Strictness signatures ==================== -T18086.$trModule: T18086.m: <L>x T18086.panic: <L>x diff --git a/testsuite/tests/stranal/sigs/T18907.stderr b/testsuite/tests/stranal/sigs/T18907.stderr index 9d9aff99c8..235872a8eb 100644 --- a/testsuite/tests/stranal/sigs/T18907.stderr +++ b/testsuite/tests/stranal/sigs/T18907.stderr @@ -1,8 +1,5 @@ ==================== Strictness signatures ==================== -T18907.$tc'H: -T18907.$tcHuge: -T18907.$trModule: T18907.f: <1L> T18907.g: <1P(SL,L,L,L,L)> T18907.h: <1!A><1L> @@ -11,9 +8,6 @@ T18907.m: <1!B>b ==================== Cpr signatures ==================== -T18907.$tc'H: -T18907.$tcHuge: -T18907.$trModule: T18907.f: T18907.g: T18907.h: @@ -22,9 +16,6 @@ T18907.m: b ==================== Strictness signatures ==================== -T18907.$tc'H: -T18907.$tcHuge: -T18907.$trModule: T18907.f: <1L> T18907.g: <1P(SL,L,L,L,L)> T18907.h: <1!A><1L> diff --git a/testsuite/tests/stranal/sigs/T18957.hs b/testsuite/tests/stranal/sigs/T18957.hs index 8f4550696d..b49ed1a4b8 100644 --- a/testsuite/tests/stranal/sigs/T18957.hs +++ b/testsuite/tests/stranal/sigs/T18957.hs @@ -28,5 +28,7 @@ h1 f x = f `seq'` if x < 100 then f x else 200 h2 :: (Int -> Int) -> Int -> Int h2 f x = f `seq` if x < 100 then f x else 200 +-- | The first argument is evaluated lazily and multiple times, but called every +-- time it's evaluated. h3 :: (Int -> Int) -> Int -> Int h3 f x = if x < 100 then f x + f (x+1) else 200 diff --git a/testsuite/tests/stranal/sigs/T18957.stderr b/testsuite/tests/stranal/sigs/T18957.stderr index 3d730ce9fc..04937d4028 100644 --- a/testsuite/tests/stranal/sigs/T18957.stderr +++ b/testsuite/tests/stranal/sigs/T18957.stderr @@ -1,16 +1,14 @@ ==================== Strictness signatures ==================== -T18957.$trModule: -T18957.g: <MCM(L)><1L> +T18957.g: <MC1(L)><1L> T18957.h1: <SCM(L)><1L> T18957.h2: <1CM(L)><1L> -T18957.h3: <L><1L> +T18957.h3: <LCS(L)><1L> T18957.seq': <1A><1L> ==================== Cpr signatures ==================== -T18957.$trModule: T18957.g: T18957.h1: T18957.h2: @@ -20,11 +18,10 @@ T18957.seq': ==================== Strictness signatures ==================== -T18957.$trModule: -T18957.g: <MCM(L)><1L> +T18957.g: <MC1(L)><1L> T18957.h1: <SCM(L)><1L> T18957.h2: <1CM(L)><1L> -T18957.h3: <L><1L> +T18957.h3: <LCS(L)><1L> T18957.seq': <1A><1L> diff --git a/testsuite/tests/stranal/sigs/T19407.stderr b/testsuite/tests/stranal/sigs/T19407.stderr index 8d4045700a..a855d89810 100644 --- a/testsuite/tests/stranal/sigs/T19407.stderr +++ b/testsuite/tests/stranal/sigs/T19407.stderr @@ -1,23 +1,13 @@ ==================== Strictness signatures ==================== -T19407.$tc'Huge: -T19407.$tc'T: -T19407.$tcHuge: -T19407.$tcT: -T19407.$trModule: T19407.f: <SP(1P(1L,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A),ML)> -T19407.g: <1!P(1L,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A)><MP(A,ML)> +T19407.g: <1!P(1L,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A)><MP(A,1L)> T19407.h: <1!P(1L,A)> T19407.n: <1!P(A,1!P(L))> ==================== Cpr signatures ==================== -T19407.$tc'Huge: -T19407.$tc'T: -T19407.$tcHuge: -T19407.$tcT: -T19407.$trModule: T19407.f: T19407.g: T19407.h: @@ -26,13 +16,8 @@ T19407.n: 1 ==================== Strictness signatures ==================== -T19407.$tc'Huge: -T19407.$tc'T: -T19407.$tcHuge: -T19407.$tcT: -T19407.$trModule: T19407.f: <1P(1P(1L,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A),ML)> -T19407.g: <1!P(1L,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A)><MP(A,ML)> +T19407.g: <1!P(1L,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A)><MP(A,1L)> T19407.h: <1!P(1L,A)> T19407.n: <1!P(A,1!P(L))> diff --git a/testsuite/tests/stranal/sigs/T19871.stderr b/testsuite/tests/stranal/sigs/T19871.stderr index f8f465fd82..13e67a2805 100644 --- a/testsuite/tests/stranal/sigs/T19871.stderr +++ b/testsuite/tests/stranal/sigs/T19871.stderr @@ -1,8 +1,5 @@ ==================== Strictness signatures ==================== -T19871.$tc'Huge: -T19871.$tcHuge: -T19871.$trModule: T19871.absent: <1P(1L,ML,A,A,A,A,A,A,A,A,A,A)> T19871.ann: <1P(SL,L,L,L,L,L,L,L,L,L,L,L)> T19871.f1: <1!P(1L,A,A,A,A,A,A,A,A,A,A,A)> @@ -17,16 +14,13 @@ T19871.f6: <1!P(A,A,A,A,A,1L,A,A,A,A,A,A)> T19871.f7: <1!P(A,A,A,A,A,A,1L,A,A,A,A,A)> T19871.f8: <1!P(A,A,A,A,A,A,A,1L,A,A,A,A)> T19871.f9: <1!P(A,A,A,A,A,A,A,A,1L,A,A,A)> -T19871.guarded: <MCM(L)><1P(SL,L,L,L,L,L,L,L,L,L,L,L)> +T19871.guarded: <MC1(L)><1P(SL,L,L,L,L,L,L,L,L,L,L,L)> T19871.sumIO: <1!P(1L)><1!P(L)><L> T19871.update: <1P(SL,L,L,L,L,L,L,L,L,L,L,L)> ==================== Cpr signatures ==================== -T19871.$tc'Huge: -T19871.$tcHuge: -T19871.$trModule: T19871.absent: 1 T19871.ann: 1 T19871.f1: @@ -48,9 +42,6 @@ T19871.update: 1 ==================== Strictness signatures ==================== -T19871.$tc'Huge: -T19871.$tcHuge: -T19871.$trModule: T19871.absent: <1P(1L,ML,A,A,A,A,A,A,A,A,A,A)> T19871.ann: <1P(SL,L,L,L,L,L,L,L,L,L,L,L)> T19871.f1: <1!P(1L,A,A,A,A,A,A,A,A,A,A,A)> @@ -65,7 +56,7 @@ T19871.f6: <1!P(A,A,A,A,A,1L,A,A,A,A,A,A)> T19871.f7: <1!P(A,A,A,A,A,A,1L,A,A,A,A,A)> T19871.f8: <1!P(A,A,A,A,A,A,A,1L,A,A,A,A)> T19871.f9: <1!P(A,A,A,A,A,A,A,A,1L,A,A,A)> -T19871.guarded: <MCM(L)><1P(SL,L,L,L,L,L,L,L,L,L,L,L)> +T19871.guarded: <MC1(L)><1P(SL,L,L,L,L,L,L,L,L,L,L,L)> T19871.sumIO: <1!P(1L)><1!P(L)><L> T19871.update: <1P(SL,L,L,L,L,L,L,L,L,L,L,L)> diff --git a/testsuite/tests/stranal/sigs/T20746.stderr b/testsuite/tests/stranal/sigs/T20746.stderr index b0656cd13d..5be614867a 100644 --- a/testsuite/tests/stranal/sigs/T20746.stderr +++ b/testsuite/tests/stranal/sigs/T20746.stderr @@ -1,21 +1,18 @@ ==================== Strictness signatures ==================== -Foo.$trModule: -Foo.f: <MP(A,MCM(L),A)><L> +Foo.f: <MP(A,1C1(L),A)><L> Foo.foogle: <L><L> ==================== Cpr signatures ==================== -Foo.$trModule: Foo.f: 1 Foo.foogle: 1 ==================== Strictness signatures ==================== -Foo.$trModule: -Foo.f: <MP(A,MCM(L),A)><L> +Foo.f: <MP(A,1C1(L),A)><L> Foo.foogle: <L><L> diff --git a/testsuite/tests/stranal/sigs/T20746b.stderr b/testsuite/tests/stranal/sigs/T20746b.stderr index bd23944c61..7e6fada4e5 100644 --- a/testsuite/tests/stranal/sigs/T20746b.stderr +++ b/testsuite/tests/stranal/sigs/T20746b.stderr @@ -1,20 +1,17 @@ ==================== Strictness signatures ==================== -T20746b.$trModule: T20746b.f: <1L><L><L> T20746b.mightThrow: <L><L> ==================== Cpr signatures ==================== -T20746b.$trModule: T20746b.f: 1 T20746b.mightThrow: 1 ==================== Strictness signatures ==================== -T20746b.$trModule: T20746b.f: <1L><L><L> T20746b.mightThrow: <L><L> diff --git a/testsuite/tests/stranal/sigs/T21081.hs b/testsuite/tests/stranal/sigs/T21081.hs new file mode 100644 index 0000000000..e07ec410bc --- /dev/null +++ b/testsuite/tests/stranal/sigs/T21081.hs @@ -0,0 +1,123 @@ +{-# LANGUAGE BangPatterns #-} + +module T21081 where + +-- | Should put demand `MP(SL,SL)` or `MP(1L,1L)` on `pr`, telling us that `f` +-- will evaluate both components of `pr` whenever it evaluates `pr` lazily. +f :: (Bool, Bool) -> (Bool, Bool) +f pr = (case pr of (a,b) -> a /= b, True) +{-# NOINLINE f #-} +-- | If `f` gets the correct signature, we can case-bind `z` here (not tested) +g :: Int -> (Bool, Bool) +g x = let y = let z = odd x in (z,z) in f y + +-- | Should put demand `LCS(C1(L))` on `f`, telling us that whenever `myfoldl` +-- evaluates `f`, it will also call it at least once (`S`) and then always call +-- it with a second argument (`1`). +-- This in turn allows us to eta-reduce `(\a b -> f a b)` to `f` (not tested, +-- but there's T20040 which tests an even more complicated case). +myfoldl :: (a -> b -> a) -> a -> [b] -> a +myfoldl f z [] = z +myfoldl f !z (x:xs) = myfoldl (\a b -> f a b) (f z x) xs + +-- | Should put demand `LCL(C1(L))` on `f` +blah :: (Int -> Int -> Int) -> Int -> Int +blah f 0 = 0 +blah f 1 = f `seq` 1 +blah f x = f (x+1) (x+2) + f (x+3) (x+4) +{-# NOINLINE blah #-} +-- | It's not safe to eta-reduce the lambda here, because `do_blah undefined` +-- would crash. +do_blah :: (Int -> Int -> Int) -> Int +do_blah f = blah (\a b -> f a b) 1 + +-- | Should put demand `MP(ML,ML)` on `p`, not `MP(L,L)`. +h :: (Int, Int) -> Int -> Int +h p 0 = 0 +h p 1 = fst p +h p y = snd p + y +{-# NOINLINE h #-} +-- | We want to use call-by-name for `a` and `b`, justified by the used-once +-- info on `p` in `h`. +blurg :: Int -> Int +blurg x = + let a = sum [0..x] + b = sum [1..x] + in h (a,b) x + +-- | But we still need `p` to have demand `MP(L,L)` or simply `L` here. +-- NOT `MP(ML,ML)`. This demonstrates that product usage demands stay absolute. +h2 :: (Int, Int) -> Int -> Int +h2 p y = h p y + h p (y+1) +{-# NOINLINE h2 #-} +-- | Otherwise we'd use call-by-name for `a` and `b` here, although they are +-- evaluated multiple times in `h2`. +blurg2 :: Int -> Int +blurg2 x = + let a = sum [0..x] + b = sum [1..x] + in h2 (a,b) x + +-- | Must not put demand `MP(1L,1L)` on `x` (e.g., strict in the components). +-- This demonstrates that `plusDmd` must fall back to `lubSubDemand` when both +-- Demands are lazy. +i :: Bool -> Bool -> (Int, Int) -> Int +i b b' x = (if b then fst x else 3) + (if b' then snd x else 4) + +fst' :: (a,b) -> a +fst' (x,_) = x +{-# NOINLINE fst' #-} + +snd' :: (a,b) -> b +snd' (_,x) = x +{-# NOINLINE snd' #-} + +-- | We want `SP(1L,1L)`, even if neither `fst'` nor `snd'` are strict in both +-- components. This dictates that `plusDmd` has to do `plusSubDemand` when both +-- Demands are strict. Which differs in a crucial way from the situation in `i`! +j :: (Integer, Integer) -> Integer +j p = fst' p + snd' p + + +-- A few examples from a call between Simon and me + +call1 :: (Bool,Bool) -> (Bool, Bool) +call1 x = (x `seq` case x of (a,b) -> a, True) +-- call1 :: <MP(1L,A)> +-- x may not be evald at all, but +-- if `x` is evaluated at all, then +-- then `a` is evaluated exactly once (in total) + +call2 :: (Bool,Bool) -> (Bool, Bool) +call2 x = (x `seq` case x of (a,b) -> a, case x of (a,b) -> a) +-- call2 :: LP(SL,A) +-- If x is evaluated, then `a` is (in total) evaluated +-- maybe as much as twice + +call3 :: (Bool,Bool) -> (Bool, ()) +call3 x = (x `seq` case x of (a,b) -> a, x `seq` ()) +-- call3 :: LP(ML,A) +-- If x is evaluated, then `a` may not be evaluated at all. + +call4 :: (Bool,Bool) -> Bool -> (Bool, Bool) +call4 x y = y `seq` (case x of (a,b) -> a, True) +-- call4 :: <MP(1L,A)><1A> +-- What is demand on x in (call4 x x)? +-- NOT SP(1L,A)!! + +call5 :: (Bool,Bool) -> Bool -> (Bool, ()) +call5 x y = (case x of (a,b) -> a, y `seq` ()) +-- call5 :: <MP(1L,A)><MA> +-- What is demand on x in `snd (call5 x x)`? +-- Not LP(1L,A)!! call5 might evaluate second argument but not first +-- Lub because we might evaluate one OR the other. + +call6 :: (Int,Int) -> (Int,Int) -> Bool -> Int +call6 x y True = 42 +call6 x y False = case y of (a, _) -> case x of (b, _) -> a + b +-- call6 :: <MP(1L)><MP(1L)><1L> +-- What is demand on x in `call6 x x`? +-- Not LP(1L)!! It's LP(SL) +-- call6 might evaluate both its arguments and, in each case +-- evaluate the component once. So the component of x +-- gets evaluated twice. diff --git a/testsuite/tests/stranal/sigs/T21081.stderr b/testsuite/tests/stranal/sigs/T21081.stderr new file mode 100644 index 0000000000..ec7e776ca8 --- /dev/null +++ b/testsuite/tests/stranal/sigs/T21081.stderr @@ -0,0 +1,69 @@ + +==================== Strictness signatures ==================== +T21081.blah: <LCL(C1(L))><1!P(1L)> +T21081.blurg: <S!P(SL)> +T21081.blurg2: <S!P(SL)> +T21081.call1: <MP(1L,A)> +T21081.call2: <LP(SL,A)> +T21081.call3: <LP(ML,A)> +T21081.call4: <MP(1L,A)><1A> +T21081.call5: <MP(1L,A)><MA> +T21081.call6: <MP(1L,A)><MP(1L,A)><1L> +T21081.do_blah: <LCS(C1(L))> +T21081.f: <MP(SL,SL)> +T21081.fst': <1!P(1L,A)> +T21081.g: <ML> +T21081.h: <MP(ML,ML)><1!P(1L)> +T21081.h2: <L><S!P(SL)> +T21081.i: <1L><1L><MP(ML,ML)> +T21081.j: <S!P(1L,1L)> +T21081.myfoldl: <LCS(C1(L))><1L><1L> +T21081.snd': <1!P(A,1L)> + + + +==================== Cpr signatures ==================== +T21081.blah: 1 +T21081.blurg: +T21081.blurg2: 1 +T21081.call1: 1(, 2) +T21081.call2: 1 +T21081.call3: 1 +T21081.call4: 1(, 2) +T21081.call5: 1 +T21081.call6: 1 +T21081.do_blah: 1 +T21081.f: 1(, 2) +T21081.fst': +T21081.g: 1(, 2) +T21081.h: +T21081.h2: 1 +T21081.i: 1 +T21081.j: +T21081.myfoldl: +T21081.snd': + + + +==================== Strictness signatures ==================== +T21081.blah: <LCL(C1(L))><1!P(1L)> +T21081.blurg: <1!P(SL)> +T21081.blurg2: <1!P(SL)> +T21081.call1: <MP(1L,A)> +T21081.call2: <LP(SL,A)> +T21081.call3: <LP(ML,A)> +T21081.call4: <MP(1L,A)><1A> +T21081.call5: <MP(1L,A)><MA> +T21081.call6: <MP(1L,A)><MP(1L,A)><1L> +T21081.do_blah: <LCS(C1(L))> +T21081.f: <MP(SL,SL)> +T21081.fst': <1!P(1L,A)> +T21081.g: <ML> +T21081.h: <MP(ML,ML)><1!P(1L)> +T21081.h2: <L><1!P(SL)> +T21081.i: <1L><1L><MP(ML,ML)> +T21081.j: <1!P(1L,1L)> +T21081.myfoldl: <LCS(C1(L))><1L><1L> +T21081.snd': <1!P(A,1L)> + + diff --git a/testsuite/tests/stranal/sigs/T21119.stderr b/testsuite/tests/stranal/sigs/T21119.stderr index 0a398888d0..dade4dc2a6 100644 --- a/testsuite/tests/stranal/sigs/T21119.stderr +++ b/testsuite/tests/stranal/sigs/T21119.stderr @@ -2,22 +2,16 @@ ==================== Strictness signatures ==================== T21119.$fMyShow(,): <1!A> T21119.$fMyShowInt: <1!A> -T21119.$tc'C:MyShow: -T21119.$tcMyShow: -T21119.$trModule: T21119.get: <1!P(1!P(L),1!P(L))><1!P(L)><1L> T21119.getIO: <1P(1L,ML)><1L><ML><L> -T21119.indexError: <1C1(L)><1!B><S!S><S!S>b -T21119.throwIndexError: <MCM(L)><MA><L><L><L>x +T21119.indexError: <1C1(S)><1!B><S!S><S!S>b +T21119.throwIndexError: <MC1(L)><MA><L><L><L>x ==================== Cpr signatures ==================== T21119.$fMyShow(,): T21119.$fMyShowInt: -T21119.$tc'C:MyShow: -T21119.$tcMyShow: -T21119.$trModule: T21119.get: T21119.getIO: 1 T21119.indexError: b @@ -28,12 +22,9 @@ T21119.throwIndexError: b ==================== Strictness signatures ==================== T21119.$fMyShow(,): <1!A> T21119.$fMyShowInt: <1!A> -T21119.$tc'C:MyShow: -T21119.$tcMyShow: -T21119.$trModule: T21119.get: <1!P(1!P(L),1!P(L))><1!P(L)><1L> T21119.getIO: <1P(1L,ML)><1L><ML><L> -T21119.indexError: <1C1(L)><1!B><S!S><S!S>b -T21119.throwIndexError: <MCM(L)><MA><L><L><L>x +T21119.indexError: <1C1(S)><1!B><S!S><S!S>b +T21119.throwIndexError: <MC1(L)><MA><L><L><L>x diff --git a/testsuite/tests/stranal/sigs/T5075.stderr b/testsuite/tests/stranal/sigs/T5075.stderr index e367385d52..9bc8301440 100644 --- a/testsuite/tests/stranal/sigs/T5075.stderr +++ b/testsuite/tests/stranal/sigs/T5075.stderr @@ -1,14 +1,12 @@ ==================== Strictness signatures ==================== -T5075.$trModule: -T5075.f: <S!P(A,A,SCS(C1(L)),A,A,A,A,A)><LP(A,A,LCL(C1(L)),A,A,A,L)><L> +T5075.f: <S!P(A,A,SCS(C1(L)),A,A,A,A,A)><LP(A,A,LCS(C1(L)),A,A,A,LCS(L))><L> T5075.g: <1L><S!P(L)> T5075.h: <S!P(L)> ==================== Cpr signatures ==================== -T5075.$trModule: T5075.f: 1 T5075.g: 2 T5075.h: @@ -16,8 +14,7 @@ T5075.h: ==================== Strictness signatures ==================== -T5075.$trModule: -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.f: <1P(A,A,SCS(C1(L)),A,A,A,A,A)><LP(A,A,LCS(C1(L)),A,A,A,LCS(L))><L> T5075.g: <1L><S!P(L)> T5075.h: <1!P(L)> diff --git a/testsuite/tests/stranal/sigs/T8569.stderr b/testsuite/tests/stranal/sigs/T8569.stderr index 187047e612..0330cc6b61 100644 --- a/testsuite/tests/stranal/sigs/T8569.stderr +++ b/testsuite/tests/stranal/sigs/T8569.stderr @@ -1,27 +1,15 @@ ==================== Strictness signatures ==================== -T8569.$tc'Rdata: -T8569.$tc'Rint: -T8569.$tcRep: -T8569.$trModule: T8569.addUp: <1L><L> ==================== Cpr signatures ==================== -T8569.$tc'Rdata: -T8569.$tc'Rint: -T8569.$tcRep: -T8569.$trModule: T8569.addUp: ==================== Strictness signatures ==================== -T8569.$tc'Rdata: -T8569.$tc'Rint: -T8569.$tcRep: -T8569.$trModule: T8569.addUp: <1L><L> diff --git a/testsuite/tests/stranal/sigs/T8598.stderr b/testsuite/tests/stranal/sigs/T8598.stderr index 747c6a096b..00542be668 100644 --- a/testsuite/tests/stranal/sigs/T8598.stderr +++ b/testsuite/tests/stranal/sigs/T8598.stderr @@ -1,18 +1,15 @@ ==================== Strictness signatures ==================== -T8598.$trModule: T8598.fun: <1!P(L)> ==================== Cpr signatures ==================== -T8598.$trModule: T8598.fun: 1 ==================== Strictness signatures ==================== -T8598.$trModule: T8598.fun: <1!P(L)> diff --git a/testsuite/tests/stranal/sigs/UnsatFun.stderr b/testsuite/tests/stranal/sigs/UnsatFun.stderr index a9c3ca340a..c659311b22 100644 --- a/testsuite/tests/stranal/sigs/UnsatFun.stderr +++ b/testsuite/tests/stranal/sigs/UnsatFun.stderr @@ -1,18 +1,16 @@ ==================== Strictness signatures ==================== -UnsatFun.$trModule: UnsatFun.f: <1!S><B>b UnsatFun.g: <1!S>b -UnsatFun.g': <ML> +UnsatFun.g': <MS> UnsatFun.g3: <A> UnsatFun.h: <1C1(L)> -UnsatFun.h2: <1L><MCM(L)> +UnsatFun.h2: <1L><MC1(L)> UnsatFun.h3: <1C1(A)> ==================== Cpr signatures ==================== -UnsatFun.$trModule: UnsatFun.f: b UnsatFun.g: UnsatFun.g': @@ -24,13 +22,12 @@ UnsatFun.h3: 1 ==================== Strictness signatures ==================== -UnsatFun.$trModule: UnsatFun.f: <1!S><B>b UnsatFun.g: <1!S>b -UnsatFun.g': <ML> +UnsatFun.g': <MS> UnsatFun.g3: <A> UnsatFun.h: <1C1(L)> -UnsatFun.h2: <1L><MCM(L)> +UnsatFun.h2: <1L><MC1(L)> UnsatFun.h3: <1C1(A)> diff --git a/testsuite/tests/stranal/sigs/all.T b/testsuite/tests/stranal/sigs/all.T index 876d2242d8..3782fa97a6 100644 --- a/testsuite/tests/stranal/sigs/all.T +++ b/testsuite/tests/stranal/sigs/all.T @@ -1,7 +1,7 @@ # This directory contains tests where we annotate functions with expected # type signatures, and verify that these actually those found by the compiler -setTestOpts(extra_hc_opts('-ddump-str-signatures -ddump-cpr-signatures')) +setTestOpts(extra_hc_opts('-ddump-str-signatures -ddump-cpr-signatures -dno-typeable-binds')) # We are testing the result of an optimization, so no use # running them in various runtimes @@ -31,5 +31,5 @@ test('T18907', normal, compile, ['']) test('T13331', normal, compile, ['']) test('T20746', normal, compile, ['']) test('T20746b', normal, compile, ['']) - +test('T21081', normal, compile, ['']) test('T21119', normal, compile, ['']) |