/
Nested.purs
253 lines (218 loc) · 10.4 KB
/
Nested.purs
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
module Data.Functor.Coproduct.Nested where
import Prelude
import Data.Const (Const)
import Data.Either (Either(..))
import Data.Functor.Coproduct (Coproduct(..), coproduct, left, right)
import Data.Newtype (unwrap)
type Coproduct1 a = C2 a (Const Void)
type Coproduct2 a b = C3 a b (Const Void)
type Coproduct3 a b c = C4 a b c (Const Void)
type Coproduct4 a b c d = C5 a b c d (Const Void)
type Coproduct5 a b c d e = C6 a b c d e (Const Void)
type Coproduct6 a b c d e f = C7 a b c d e f (Const Void)
type Coproduct7 a b c d e f g = C8 a b c d e f g (Const Void)
type Coproduct8 a b c d e f g h = C9 a b c d e f g h (Const Void)
type Coproduct9 a b c d e f g h i = C10 a b c d e f g h i (Const Void)
type Coproduct10 a b c d e f g h i j = C11 a b c d e f g h i j (Const Void)
type C2 a z = Coproduct a z
type C3 a b z = Coproduct a (C2 b z)
type C4 a b c z = Coproduct a (C3 b c z)
type C5 a b c d z = Coproduct a (C4 b c d z)
type C6 a b c d e z = Coproduct a (C5 b c d e z)
type C7 a b c d e f z = Coproduct a (C6 b c d e f z)
type C8 a b c d e f g z = Coproduct a (C7 b c d e f g z)
type C9 a b c d e f g h z = Coproduct a (C8 b c d e f g h z)
type C10 a b c d e f g h i z = Coproduct a (C9 b c d e f g h i z)
type C11 a b c d e f g h i j z = Coproduct a (C10 b c d e f g h i j z)
infixr 6 coproduct as <\/>
infixr 6 type Coproduct as <\/>
in1 :: forall a z. a ~> C2 a z
in1 = left
in2 :: forall a b z. b ~> C3 a b z
in2 v = right (left v)
in3 :: forall a b c z. c ~> C4 a b c z
in3 v = right (right (left v))
in4 :: forall a b c d z. d ~> C5 a b c d z
in4 v = right (right (right (left v)))
in5 :: forall a b c d e z. e ~> C6 a b c d e z
in5 v = right (right (right (right (left v))))
in6 :: forall a b c d e f z. f ~> C7 a b c d e f z
in6 v = right (right (right (right (right (left v)))))
in7 :: forall a b c d e f g z. g ~> C8 a b c d e f g z
in7 v = right (right (right (right (right (right (left v))))))
in8 :: forall a b c d e f g h z. h ~> C9 a b c d e f g h z
in8 v = right (right (right (right (right (right (right (left v)))))))
in9 :: forall a b c d e f g h i z. i ~> C10 a b c d e f g h i z
in9 v = right (right (right (right (right (right (right (right (left v))))))))
in10 :: forall a b c d e f g h i j z. j ~> C11 a b c d e f g h i j z
in10 v = right (right (right (right (right (right (right (right (right (left v)))))))))
at1 :: forall r x a z. r -> (a x -> r) -> C2 a z x -> r
at1 b f y = case y of
Coproduct (Left r) -> f r
_ -> b
at2 :: forall r x a b z. r -> (b x -> r) -> C3 a b z x -> r
at2 b f y = case y of
Coproduct (Right (Coproduct (Left r))) -> f r
_ -> b
at3 :: forall r x a b c z. r -> (c x -> r) -> C4 a b c z x -> r
at3 b f y = case y of
Coproduct (Right (Coproduct (Right (Coproduct (Left r))))) -> f r
_ -> b
at4 :: forall r x a b c d z. r -> (d x -> r) -> C5 a b c d z x -> r
at4 b f y = case y of
Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Left r))))))) -> f r
_ -> b
at5 :: forall r x a b c d e z. r -> (e x -> r) -> C6 a b c d e z x -> r
at5 b f y = case y of
Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Left r))))))))) -> f r
_ -> b
at6 :: forall r x a b c d e f z. r -> (f x -> r) -> C7 a b c d e f z x -> r
at6 b f y = case y of
Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Left r))))))))))) -> f r
_ -> b
at7 :: forall r x a b c d e f g z. r -> (g x -> r) -> C8 a b c d e f g z x -> r
at7 b f y = case y of
Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Left r))))))))))))) -> f r
_ -> b
at8 :: forall r x a b c d e f g h z. r -> (h x -> r) -> C9 a b c d e f g h z x -> r
at8 b f y = case y of
Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Left r))))))))))))))) -> f r
_ -> b
at9 :: forall r x a b c d e f g h i z. r -> (i x -> r) -> C10 a b c d e f g h i z x -> r
at9 b f y = case y of
Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Left r))))))))))))))))) -> f r
_ -> b
at10 :: forall r x a b c d e f g h i j z. r -> (j x -> r) -> C11 a b c d e f g h i j z x -> r
at10 b f y = case y of
Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Right (Coproduct (Left r))))))))))))))))))) -> f r
_ -> b
coproduct1 :: forall a. Coproduct1 a ~> a
coproduct1 y = case y of
Coproduct (Left r) -> r
Coproduct (Right _1) -> absurd (unwrap _1)
coproduct2 :: forall r x a b. (a x -> r) -> (b x -> r) -> Coproduct2 a b x -> r
coproduct2 a b y = case y of
Coproduct (Left r) -> a r
Coproduct (Right _1) -> case _1 of
Coproduct (Left r) -> b r
Coproduct (Right _2) -> absurd (unwrap _2)
coproduct3 :: forall r x a b c. (a x -> r) -> (b x -> r) -> (c x -> r) -> Coproduct3 a b c x -> r
coproduct3 a b c y = case y of
Coproduct (Left r) -> a r
Coproduct (Right _1) -> case _1 of
Coproduct (Left r) -> b r
Coproduct (Right _2) -> case _2 of
Coproduct (Left r) -> c r
Coproduct (Right _3) -> absurd (unwrap _3)
coproduct4 :: forall r x a b c d. (a x -> r) -> (b x -> r) -> (c x -> r) -> (d x -> r) -> Coproduct4 a b c d x -> r
coproduct4 a b c d y = case y of
Coproduct (Left r) -> a r
Coproduct (Right _1) -> case _1 of
Coproduct (Left r) -> b r
Coproduct (Right _2) -> case _2 of
Coproduct (Left r) -> c r
Coproduct (Right _3) -> case _3 of
Coproduct (Left r) -> d r
Coproduct (Right _4) -> absurd (unwrap _4)
coproduct5 :: forall r x a b c d e. (a x -> r) -> (b x -> r) -> (c x -> r) -> (d x -> r) -> (e x -> r) -> Coproduct5 a b c d e x -> r
coproduct5 a b c d e y = case y of
Coproduct (Left r) -> a r
Coproduct (Right _1) -> case _1 of
Coproduct (Left r) -> b r
Coproduct (Right _2) -> case _2 of
Coproduct (Left r) -> c r
Coproduct (Right _3) -> case _3 of
Coproduct (Left r) -> d r
Coproduct (Right _4) -> case _4 of
Coproduct (Left r) -> e r
Coproduct (Right _5) -> absurd (unwrap _5)
coproduct6 :: forall r x a b c d e f. (a x -> r) -> (b x -> r) -> (c x -> r) -> (d x -> r) -> (e x -> r) -> (f x -> r) -> Coproduct6 a b c d e f x -> r
coproduct6 a b c d e f y = case y of
Coproduct (Left r) -> a r
Coproduct (Right _1) -> case _1 of
Coproduct (Left r) -> b r
Coproduct (Right _2) -> case _2 of
Coproduct (Left r) -> c r
Coproduct (Right _3) -> case _3 of
Coproduct (Left r) -> d r
Coproduct (Right _4) -> case _4 of
Coproduct (Left r) -> e r
Coproduct (Right _5) -> case _5 of
Coproduct (Left r) -> f r
Coproduct (Right _6) -> absurd (unwrap _6)
coproduct7 :: forall r x a b c d e f g. (a x -> r) -> (b x -> r) -> (c x -> r) -> (d x -> r) -> (e x -> r) -> (f x -> r) -> (g x -> r) -> Coproduct7 a b c d e f g x -> r
coproduct7 a b c d e f g y = case y of
Coproduct (Left r) -> a r
Coproduct (Right _1) -> case _1 of
Coproduct (Left r) -> b r
Coproduct (Right _2) -> case _2 of
Coproduct (Left r) -> c r
Coproduct (Right _3) -> case _3 of
Coproduct (Left r) -> d r
Coproduct (Right _4) -> case _4 of
Coproduct (Left r) -> e r
Coproduct (Right _5) -> case _5 of
Coproduct (Left r) -> f r
Coproduct (Right _6) -> case _6 of
Coproduct (Left r) -> g r
Coproduct (Right _7) -> absurd (unwrap _7)
coproduct8 :: forall r x a b c d e f g h. (a x -> r) -> (b x -> r) -> (c x -> r) -> (d x -> r) -> (e x -> r) -> (f x -> r) -> (g x -> r) -> (h x -> r) -> Coproduct8 a b c d e f g h x -> r
coproduct8 a b c d e f g h y = case y of
Coproduct (Left r) -> a r
Coproduct (Right _1) -> case _1 of
Coproduct (Left r) -> b r
Coproduct (Right _2) -> case _2 of
Coproduct (Left r) -> c r
Coproduct (Right _3) -> case _3 of
Coproduct (Left r) -> d r
Coproduct (Right _4) -> case _4 of
Coproduct (Left r) -> e r
Coproduct (Right _5) -> case _5 of
Coproduct (Left r) -> f r
Coproduct (Right _6) -> case _6 of
Coproduct (Left r) -> g r
Coproduct (Right _7) -> case _7 of
Coproduct (Left r) -> h r
Coproduct (Right _8) -> absurd (unwrap _8)
coproduct9 :: forall r x a b c d e f g h i. (a x -> r) -> (b x -> r) -> (c x -> r) -> (d x -> r) -> (e x -> r) -> (f x -> r) -> (g x -> r) -> (h x -> r) -> (i x -> r) -> Coproduct9 a b c d e f g h i x -> r
coproduct9 a b c d e f g h i y = case y of
Coproduct (Left r) -> a r
Coproduct (Right _1) -> case _1 of
Coproduct (Left r) -> b r
Coproduct (Right _2) -> case _2 of
Coproduct (Left r) -> c r
Coproduct (Right _3) -> case _3 of
Coproduct (Left r) -> d r
Coproduct (Right _4) -> case _4 of
Coproduct (Left r) -> e r
Coproduct (Right _5) -> case _5 of
Coproduct (Left r) -> f r
Coproduct (Right _6) -> case _6 of
Coproduct (Left r) -> g r
Coproduct (Right _7) -> case _7 of
Coproduct (Left r) -> h r
Coproduct (Right _8) -> case _8 of
Coproduct (Left r) -> i r
Coproduct (Right _9) -> absurd (unwrap _9)
coproduct10 :: forall r x a b c d e f g h i j. (a x -> r) -> (b x -> r) -> (c x -> r) -> (d x -> r) -> (e x -> r) -> (f x -> r) -> (g x -> r) -> (h x -> r) -> (i x -> r) -> (j x -> r) -> Coproduct10 a b c d e f g h i j x -> r
coproduct10 a b c d e f g h i j y = case y of
Coproduct (Left r) -> a r
Coproduct (Right _1) -> case _1 of
Coproduct (Left r) -> b r
Coproduct (Right _2) -> case _2 of
Coproduct (Left r) -> c r
Coproduct (Right _3) -> case _3 of
Coproduct (Left r) -> d r
Coproduct (Right _4) -> case _4 of
Coproduct (Left r) -> e r
Coproduct (Right _5) -> case _5 of
Coproduct (Left r) -> f r
Coproduct (Right _6) -> case _6 of
Coproduct (Left r) -> g r
Coproduct (Right _7) -> case _7 of
Coproduct (Left r) -> h r
Coproduct (Right _8) -> case _8 of
Coproduct (Left r) -> i r
Coproduct (Right _9) -> case _9 of
Coproduct (Left r) -> j r
Coproduct (Right _10) -> absurd (unwrap _10)