summaryrefslogtreecommitdiff
path: root/testsuite/tests/perf/compiler/T13035.hs
blob: b8d294def5272d7513dd6c229037e5d389ba649c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
{-# LANGUAGE PolyKinds, DataKinds, TypeOperators, TypeFamilies,
             GADTs, PartialTypeSignatures #-}

module T13035 where

import Data.Kind

newtype MyAttr a b = MyAttr { _unMyAttr :: MyFun (a b) }
type MyRec a b = Rec (MyAttr a) b

type family MyFun (a :: k1) :: k2

data GY (a :: k1) (b :: k2) (c :: k1 -> k3) (d :: k1)
data GNone (a :: k1)

type family GYTF a where
    GYTF (GY a b _ a) = b
    GYTF (GY _ _ c d) = MyFun (c d)

type instance MyFun (GY a b c d) = GYTF (GY a b c d)

type family GNoneTF (a :: k1) :: k2 where

type instance MyFun (GNone a) = GNoneTF a

type (a :: k1) =: (b :: k2) = a `GY` b
type (a :: j1 -> j2) $ (b :: j1) = a b

infixr 0 $
infixr 9 =:

data FConst (a :: Type) (b :: Fields)
data FApply (a :: Type -> Type -> Type) b c (d :: Fields)
data FMap (a :: Type -> Type) b (d :: Fields)

type instance MyFun (FConst a b) = a
type instance MyFun (FApply b c d a) = b (MyFun (c a)) (MyFun (d a))
type instance MyFun (FMap b c a) = b (MyFun (c a))

data Fields = Name
            | Author
            | Image
            | Description
            | Ingredients
            | Instructions
            | CookTime
            | PrepTime
            | TotalTime
            | Yield
            | Nutrition
            | Tags
            | Url
            | Section
            | Items
            | Subsections
            | Calories
            | Carbohydrates
            | Cholesterol
            | Fat
            | Fiber
            | Protien
            | SaturatedFat
            | Sodium
            | Sugar
            | TransFat
            | UnsaturatedFat
            | ServingSize

data Rec :: (u -> Type) -> [u] -> Type where
  RNil :: Rec f '[]
  (:&) :: !(f r) -> !(Rec f rs) -> Rec f (r ': rs)

data family Sing (a :: k)
data instance Sing (z_a6bn :: Fields)
      = z_a6bn ~ Name => SName |
        z_a6bn ~ Author => SAuthor |
        z_a6bn ~ Image => SImage |
        z_a6bn ~ Description => SDescription |
        z_a6bn ~ Ingredients => SIngredients |
        z_a6bn ~ Instructions => SInstructions |
        z_a6bn ~ CookTime => SCookTime |
        z_a6bn ~ PrepTime => SPrepTime |
        z_a6bn ~ TotalTime => STotalTime |
        z_a6bn ~ Yield => SYield |
        z_a6bn ~ Nutrition => SNutrition |
        z_a6bn ~ Tags => STags |
        z_a6bn ~ Url => SUrl |
        z_a6bn ~ Section => SSection |
        z_a6bn ~ Items => SItems |
        z_a6bn ~ Subsections => SSubsections |
        z_a6bn ~ Calories => SCalories |
        z_a6bn ~ Carbohydrates => SCarbohydrates |
        z_a6bn ~ Cholesterol => SCholesterol |
        z_a6bn ~ Fat => SFat |
        z_a6bn ~ Fiber => SFiber |
        z_a6bn ~ Protien => SProtien |
        z_a6bn ~ SaturatedFat => SSaturatedFat |
        z_a6bn ~ Sodium => SSodium |
        z_a6bn ~ Sugar => SSugar |
        z_a6bn ~ TransFat => STransFat |
        z_a6bn ~ UnsaturatedFat => SUnsaturatedFat |
        z_a6bn ~ ServingSize => SServingSize

(=::) :: sing f -> MyFun (a f) -> MyAttr a f
_ =:: x = MyAttr x

type NutritionT
    = Calories       =: Maybe Int
    $ Carbohydrates  =: Maybe Int
    $ Cholesterol    =: Maybe Int
    $ Fat            =: Maybe Int
    $ Fiber          =: Maybe Int
    $ Protien        =: Maybe Int
    $ SaturatedFat   =: Maybe Int
    $ Sodium         =: Maybe Int
    $ Sugar          =: Maybe Int
    $ TransFat       =: Maybe Int
    $ UnsaturatedFat =: Maybe Int
    $ ServingSize    =: String
    $ GNone

type NutritionRec = MyRec NutritionT ['Calories, 'Carbohydrates,
                                      'Cholesterol, 'Fat, 'Fiber,
                                      'Protien, 'SaturatedFat, 'Sodium,
                                      'Sugar, 'TransFat, 'UnsaturatedFat,
                                      'ServingSize]

type RecipeT
    = Name         =: String
    $ Author       =: String
    $ Image        =: String
    $ Description  =: String
    $ CookTime     =: Maybe Int
    $ PrepTime     =: Maybe Int
    $ TotalTime    =: Maybe Int
    $ Yield        =: String
    $ Nutrition    =: NutritionRec
    $ Tags         =: [String]
    $ Url          =: String
    $ GNone

type RecipeFormatter = FApply (->) (FConst [String]) (FMap IO RecipeT)

g :: MyRec RecipeFormatter _ --'[ 'Author ] Uncomment to prevent loop
g = SAuthor =:: (\a -> return "Hi")
    :& RNil