summaryrefslogtreecommitdiff
path: root/testsuite/tests/simplCore/should_compile/T13156.hs
blob: 5512787b11405c2bb7f649bd508f81a6c3d048b7 (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
41
42
43
44
45
module T13156 where

f g x = let r :: [a] -> [a]
            r = case g x of True -> reverse . reverse
                            False -> reverse
        in
        r `seq` r `seq` r


{- Expected -ddump-prep looks like this.
   (Case-of-type-lambda an oddity of Core Prep.)

-- RHS size: {terms: 9, types: 9, coercions: 0, joins: 0/0}
T13156.f1 :: forall a. [a] -> [a]
[GblId, Arity=1, Caf=NoCafRefs, Str=<S,1*U>, Unf=OtherCon []]
T13156.f1 =
  \ (@ a) (x [Occ=Once] :: [a]) ->
    case GHC.List.reverse @ a x of sat { __DEFAULT ->
    GHC.List.reverse1 @ a sat (GHC.Types.[] @ a)
    }

-- RHS size: {terms: 17, types: 28, coercions: 0, joins: 0/0}
T13156.f
  :: forall p.
     (p -> GHC.Types.Bool) -> p -> [GHC.Types.Int] -> [GHC.Types.Int]
[GblId,
 Arity=2,
 Caf=NoCafRefs,
 Str=<C(S),1*C(1,U)><L,U>,
 Unf=OtherCon []]
T13156.f =
  \ (@ p)
    (g [Occ=Once!] :: p -> GHC.Types.Bool)
    (x [Occ=Once] :: p) ->
    case \ (@ a) ->
           case g x of {
             GHC.Types.False -> GHC.List.reverse @ a;
             GHC.Types.True -> T13156.f1 @ a
           }
    of r [Dmd=<S,U>]
    { __DEFAULT ->
    case r @ GHC.Types.Any of { __DEFAULT -> r @ GHC.Types.Int }
    }

-}