Embrace -XTypeInType, add -XStarIsType
[ghc.git] / testsuite / tests / typecheck / should_run / T12809.hs
1 {-# LANGUAGE DataKinds, PolyKinds, ExplicitForAll, MagicHash, UnboxedTuples,
2 TypeFamilies, GADTs #-}
3
4 module Main where
5
6 import GHC.Exts
7
8 idint :: forall (a :: TYPE IntRep). a -> a
9 idint x = x
10
11 five _ = idint 3# +# idint 2#
12
13 type family F a where
14 F Int = (# Bool, Int# #)
15 F Char = (# Double, Int# #)
16
17 data G a where
18 GInt :: G Int
19 GChar :: G Char
20
21 f :: G a -> F a
22 f GInt = (# True, 3# #)
23 f GChar = (# 3.14, 5# #)
24
25 f' :: G a -> F a
26 f' GInt = (# False, 7# #)
27 f' GChar = (# 2.71829, 11# #)
28
29 g :: (# Bool, Int# #) -> String
30 g (# b, x #) = show b ++ " " ++ show (I# x)
31
32 h :: (# Double, Int# #) -> String
33 h (# d, x #) = show d ++ " " ++ show (I# x)
34
35 cond :: forall (a :: TYPE (TupleRep [LiftedRep, IntRep])). Bool -> a -> a -> a
36 cond True x _ = x
37 cond False _ x = x
38
39 main :: IO ()
40 main = do
41 print (I# (five ()))
42 putStrLn (g (f GInt))
43 putStrLn (g (cond False (f GInt) (f' GInt)))
44 putStrLn (h (cond True (f GChar) (f' GChar)))