1{-# LANGUAGE TypeFamilies #-}
2{-# LANGUAGE AllowAmbiguousTypes #-}  -- 'bar' is ambiguous
3
4module TH_tf2 where
5
6{-
7$( [d| class C a where
8         data T a
9         foo :: Bool -> T a |] )
10
11$( [d| instance C Int where
12         data T Int = TInt Bool
13         foo b = TInt (b && b) |] )
14
15$( [d| instance C Float where
16         data T Float = TFloat {flag :: Bool}
17         foo b = TFloat {flag = b && b} |] )
18-}
19
20class D a where
21         type S a
22         bar :: S a -> Int
23
24instance D Int where
25         type S Int = Bool
26         bar c = if c then 1 else 2
27