blob: 20f338bd1b88e8043ddd279bd044b8e90a6846cb (
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
|
{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
-- This one sent an earlier version of GHC into a
-- loop in the simplifier, because we allowed a RULE
-- to fire on a loop-breaker
--
-- Discovered by Roman L, Nov 09
module Roman where
data T a = T (T a)
type family F a
type instance F (T a) = Wrap (T a)
class B (F a) => C a where
toF :: a -> F a
go :: C a => a -> Int
{-# INLINE go #-}
go x = gow (toF x)
instance C a => C (T a) where
{-# INLINE toF #-}
toF x = Wrap x
newtype Wrap a = Wrap a
class B a where
dummy :: a
gow :: a -> Int
instance C a => B (Wrap a) where
{-# INLINE gow #-}
gow (Wrap x) = go x
dummy = error "urk"
foo :: C a => T a -> Int
foo t = let t' = T t in go t'
|