Fix #11287.
[ghc.git] / testsuite / tests / th / T8884.hs
1 {-# LANGUAGE TemplateHaskell, TypeFamilies, PolyKinds #-}
2
3 module T8884 where
4
5 import Language.Haskell.TH
6 import System.IO
7
8 type family Foo a = r | r -> a where
9 Foo x = x
10
11 type family Baz (a :: k) = (r :: k) | r -> a
12 type instance Baz x = x
13
14 $( do FamilyI foo@(ClosedTypeFamilyD (TypeFamilyHead _ tvbs1 res1 m_kind1) eqs1)
15 [] <- reify ''Foo
16 FamilyI baz@(OpenTypeFamilyD (TypeFamilyHead _ tvbs2 res2 m_kind2))
17 [inst@(TySynInstD _ eqn2)] <- reify ''Baz
18 runIO $ putStrLn $ pprint foo
19 runIO $ putStrLn $ pprint baz
20 runIO $ putStrLn $ pprint inst
21 runIO $ hFlush stdout
22 return [ ClosedTypeFamilyD
23 (TypeFamilyHead (mkName "Foo'") tvbs1 res1 m_kind1) eqs1
24 , OpenTypeFamilyD
25 (TypeFamilyHead (mkName "Baz'") tvbs2 res2 m_kind2)
26 , TySynInstD (mkName "Baz'") eqn2 ] )