summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/simplCore/should_compile/T3772_A.hs
blob: e6b57c98b325f9761e4ef7c6fa21e28ed29db078 (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
46
47
48


module T3772_A where

class DeepSeq a => C a where
-- class C a where
  gen :: Int -> a

instance C Double where
  gen = fromIntegral

instance C a => C [a] where
  {-# INLINE gen #-}
  gen n = replicate n (gen n)

class DeepSeq a where
  deepSeq :: a -> b -> b

instance DeepSeq Double where
  deepSeq = seq

instance DeepSeq a => DeepSeq [a] where
  {-# INLINE deepSeq #-}
  deepSeq xs b = foldr deepSeq b xs

apply :: (C a, DeepSeq b) => Int -> (a -> b) -> ()
{-# INLINE apply #-}
apply n f = f (gen n) `deepSeq` ()


{-
$cdeepSeq :: DeepSeq a -> [a] -> b -> b
-- User INLINE( 3 args )!
$cdeepSeq a (d:DS a) b (x:[a]) (y:b) = ...

$fDeepSeq[] :: DeepSeq a -> DeepSeq [a]
-- DFun (with auto INLINE pragma)
$fDeepSeq[] a d = $cdeepSeq a d |> blah

$cp1 a d :: C a => DeepSep [a]
-- We don't want to eta-expand this, lest
-- $cdeepSeq gets inlined in it!
$cp1 a d = $fDeepSep[] a (scsel a d)

$fC[] :: C a => C [a]
-- DFun
$fC[] a d = MkC ($cp1 a d) ($cgen a d)
-}