Embrace -XTypeInType, add -XStarIsType
[ghc.git] / testsuite / tests / perf / compiler / T13035.hs
1 {-# LANGUAGE PolyKinds, DataKinds, TypeOperators, TypeFamilies,
2 GADTs, PartialTypeSignatures #-}
3
4 module T13035 where
5
6 import Data.Kind
7
8 newtype MyAttr a b = MyAttr { _unMyAttr :: MyFun (a b) }
9 type MyRec a b = Rec (MyAttr a) b
10
11 type family MyFun (a :: k1) :: k2
12
13 data GY (a :: k1) (b :: k2) (c :: k1 -> k3) (d :: k1)
14 data GNone (a :: k1)
15
16 type family GYTF a where
17 GYTF (GY a b _ a) = b
18 GYTF (GY _ _ c d) = MyFun (c d)
19
20 type instance MyFun (GY a b c d) = GYTF (GY a b c d)
21
22 type family GNoneTF (a :: k1) :: k2 where
23
24 type instance MyFun (GNone a) = GNoneTF a
25
26 type (a :: k1) =: (b :: k2) = a `GY` b
27 type (a :: j1 -> j2) $ (b :: j1) = a b
28
29 infixr 0 $
30 infixr 9 =:
31
32 data FConst (a :: Type) (b :: Fields)
33 data FApply (a :: Type -> Type -> Type) b c (d :: Fields)
34 data FMap (a :: Type -> Type) b (d :: Fields)
35
36 type instance MyFun (FConst a b) = a
37 type instance MyFun (FApply b c d a) = b (MyFun (c a)) (MyFun (d a))
38 type instance MyFun (FMap b c a) = b (MyFun (c a))
39
40 data Fields = Name
41 | Author
42 | Image
43 | Description
44 | Ingredients
45 | Instructions
46 | CookTime
47 | PrepTime
48 | TotalTime
49 | Yield
50 | Nutrition
51 | Tags
52 | Url
53 | Section
54 | Items
55 | Subsections
56 | Calories
57 | Carbohydrates
58 | Cholesterol
59 | Fat
60 | Fiber
61 | Protien
62 | SaturatedFat
63 | Sodium
64 | Sugar
65 | TransFat
66 | UnsaturatedFat
67 | ServingSize
68
69 data Rec :: (u -> Type) -> [u] -> Type where
70 RNil :: Rec f '[]
71 (:&) :: !(f r) -> !(Rec f rs) -> Rec f (r ': rs)
72
73 data family Sing (a :: k)
74 data instance Sing (z_a6bn :: Fields)
75 = z_a6bn ~ Name => SName |
76 z_a6bn ~ Author => SAuthor |
77 z_a6bn ~ Image => SImage |
78 z_a6bn ~ Description => SDescription |
79 z_a6bn ~ Ingredients => SIngredients |
80 z_a6bn ~ Instructions => SInstructions |
81 z_a6bn ~ CookTime => SCookTime |
82 z_a6bn ~ PrepTime => SPrepTime |
83 z_a6bn ~ TotalTime => STotalTime |
84 z_a6bn ~ Yield => SYield |
85 z_a6bn ~ Nutrition => SNutrition |
86 z_a6bn ~ Tags => STags |
87 z_a6bn ~ Url => SUrl |
88 z_a6bn ~ Section => SSection |
89 z_a6bn ~ Items => SItems |
90 z_a6bn ~ Subsections => SSubsections |
91 z_a6bn ~ Calories => SCalories |
92 z_a6bn ~ Carbohydrates => SCarbohydrates |
93 z_a6bn ~ Cholesterol => SCholesterol |
94 z_a6bn ~ Fat => SFat |
95 z_a6bn ~ Fiber => SFiber |
96 z_a6bn ~ Protien => SProtien |
97 z_a6bn ~ SaturatedFat => SSaturatedFat |
98 z_a6bn ~ Sodium => SSodium |
99 z_a6bn ~ Sugar => SSugar |
100 z_a6bn ~ TransFat => STransFat |
101 z_a6bn ~ UnsaturatedFat => SUnsaturatedFat |
102 z_a6bn ~ ServingSize => SServingSize
103
104 (=::) :: sing f -> MyFun (a f) -> MyAttr a f
105 _ =:: x = MyAttr x
106
107 type NutritionT
108 = Calories =: Maybe Int
109 $ Carbohydrates =: Maybe Int
110 $ Cholesterol =: Maybe Int
111 $ Fat =: Maybe Int
112 $ Fiber =: Maybe Int
113 $ Protien =: Maybe Int
114 $ SaturatedFat =: Maybe Int
115 $ Sodium =: Maybe Int
116 $ Sugar =: Maybe Int
117 $ TransFat =: Maybe Int
118 $ UnsaturatedFat =: Maybe Int
119 $ ServingSize =: String
120 $ GNone
121
122 type NutritionRec = MyRec NutritionT ['Calories, 'Carbohydrates,
123 'Cholesterol, 'Fat, 'Fiber,
124 'Protien, 'SaturatedFat, 'Sodium,
125 'Sugar, 'TransFat, 'UnsaturatedFat,
126 'ServingSize]
127
128 type RecipeT
129 = Name =: String
130 $ Author =: String
131 $ Image =: String
132 $ Description =: String
133 $ CookTime =: Maybe Int
134 $ PrepTime =: Maybe Int
135 $ TotalTime =: Maybe Int
136 $ Yield =: String
137 $ Nutrition =: NutritionRec
138 $ Tags =: [String]
139 $ Url =: String
140 $ GNone
141
142 type RecipeFormatter = FApply (->) (FConst [String]) (FMap IO RecipeT)
143
144 g :: MyRec RecipeFormatter _ --'[ 'Author ] Uncomment to prevent loop
145 g = SAuthor =:: (\a -> return "Hi")
146 :& RNil