Embrace -XTypeInType, add -XStarIsType
[ghc.git] / testsuite / tests / th / T14060.hs
1 {-# LANGUAGE DataKinds #-}
2 {-# LANGUAGE ExistentialQuantification #-}
3 {-# LANGUAGE TemplateHaskell #-}
4 {-# LANGUAGE TypeFamilyDependencies #-}
5 {-# LANGUAGE PolyKinds #-}
6 module Main where
7
8 import Data.Kind
9 import Data.Proxy
10 import Language.Haskell.TH hiding (Type)
11
12 -- Anonymous tyvar binder example
13 newtype Foo1 = Foo1 (Proxy '[False, True, False])
14
15 -- Required (dependent) tyvar binder example
16 type family Wurble k (a :: k) :: k
17 newtype Foo2 a = Foo2 (Proxy (Wurble (Maybe a) Nothing))
18
19 -- Non-injective type family example
20 type family Foo3Fam1 (a :: Type) :: Type where
21 Foo3Fam1 a = a
22 type family Foo3Fam2 (a :: Foo3Fam1 b) :: b
23 newtype Foo3 = Foo3 (Proxy (Foo3Fam2 Int))
24
25 -- Injective type family example
26 type family Foo4Fam1 (a :: Type) = (r :: Type) | r -> a where
27 Foo4Fam1 a = a
28 type family Foo4Fam2 (a :: Foo4Fam1 b) :: b
29 newtype Foo4 = Foo4 (Proxy (Foo4Fam2 Int))
30
31 $(return [])
32
33 main :: IO ()
34 main = do
35 putStrLn $(reify ''Foo1 >>= stringE . pprint)
36 putStrLn $(reify ''Foo2 >>= stringE . pprint)
37 putStrLn $(reify ''Foo3 >>= stringE . pprint)
38 putStrLn $(reify ''Foo4 >>= stringE . pprint)