@@ -20,7 +20,7 @@
2020-----------------------------------------------------------------------------
2121-- |
2222-- Module : Data.Generics.Product.Internal.HList
23−-- Copyright : (C) 2019 Csongor Kiss
23+-- Copyright : (C) 2018 Csongor Kiss
2424-- License : BSD3
2525-- Maintainer : Csongor Kiss <kiss.csongor.kiss@gmail.com>
2626-- Stability : experimental
@@ -96,7 +96,7 @@ class GIsList
9696instance
9797 ( GIsList l l' as as'
9898 , GIsList r r' bs bs'
99− , Appending as bs cs as' bs' cs'
99+ , Appending HList as bs cs as' bs' cs'
100100 , cs ~ (as ++ bs)
101101 , cs' ~ (as' ++ bs')
102102 ) => GIsList (l :*: r) (l' :*: r') cs cs' where
@@ -118,29 +118,24 @@ instance GIsList U1 U1 '[] '[] where
118118
119119--------------------------------------------------------------------------------
120120-- | as ++ bs === cs
121−class Appending as bs cs as' bs' cs'
122− | as bs cs cs' -> as' bs'
123− , as' bs' cs cs' -> as bs
124− , as bs -> cs
125− , as' bs' -> cs'
126− where
127− appending :: Iso (HList as, HList bs) (HList as', HList bs') (HList cs) (HList cs')
121+class Appending f (as :: [k]) bs cs (as' :: [k]) bs' cs' | as bs cs cs' -> as' bs', as' bs' cs cs' -> as bs, as bs -> cs, as' bs' -> cs' where
122+ appending :: Iso (f as, f bs) (f as', f bs') (f cs) (f cs')
128123
129124-- | [] ++ bs === bs
130−instance Appending '[] bs bs '[] bs' bs' where
131− appending = iso snd (Nil,)
125+instance Appending HList '[] bs bs '[] bs' bs' where
126+ appending = iso (\(_, b) -> b) (Nil,)
132127
133128-- | (a : as) ++ bs === (a : cs)
134129instance
135− Appending as bs cs as' bs' cs' -- as ++ bs == cs
136− => Appending (a ': as) bs (a ': cs) (a' ': as') bs' (a' ': cs') where
130+ Appending HList as bs cs as' bs' cs' -- as ++ bs == cs
131+ => Appending HList (a ': as) bs (a ': cs) (a' ': as') bs' (a' ': cs') where
137132 appending
138133 = pairing (fromIso consing) id -- ((a, as), bs)
139134 . assoc3 -- (a, (as, bs))
140135 . pairing id appending -- (a, cs)
141136 . consing -- (a : cs)
142137
143−singleton :: Iso a b (HList '[a]) (HList '[ b])
138+singleton :: Iso a b (HList '[ a]) (HList '[ b])
144139singleton = iso (:> Nil) (\(x :> _) -> x)
145140
146141consing :: Iso (a, HList as) (b, HList bs) (HList (a ': as)) (HList (b ': bs))
@@ -181,127 +176,127 @@ instance ListTuple () '[] where
181176 tupleToList _ = Nil
182177 listToTuple _ = ()
183178
184−instance ListTuple a '[a] where
185− type ListToTuple '[a] = a
179+instance ListTuple a '[ a] where
180+ type ListToTuple '[ a] = a
186181 tupleToList a
187182 = a :> Nil
188183 listToTuple (a :> Nil)
189184 = a
190185
191−instance ListTuple (a, b) '[a, b] where
192− type ListToTuple '[a, b] = (a, b)
186+instance ListTuple (a, b) '[ a, b] where
187+ type ListToTuple '[ a, b] = (a, b)
193188 tupleToList (a, b)
194189 = a :> b :> Nil
195190 listToTuple (a :> b :> Nil)
196191 = (a, b)
197192
198−instance ListTuple (a, b, c) '[a, b, c] where
199− type ListToTuple '[a, b, c] = (a, b, c)
193+instance ListTuple (a, b, c) '[ a, b, c] where
194+ type ListToTuple '[ a, b, c] = (a, b, c)
200195 tupleToList (a, b, c)
201196 = a :> b :> c :> Nil
202197 listToTuple (a :> b :> c :> Nil)
203198 = (a, b, c)
204199
205−instance ListTuple (a, b, c, d) '[a, b, c, d] where
206− type ListToTuple '[a, b, c, d] = (a, b, c, d)
200+instance ListTuple (a, b, c, d) '[ a, b, c, d] where
201+ type ListToTuple '[ a, b, c, d] = (a, b, c, d)
207202 tupleToList (a, b, c, d)
208203 = a :> b :> c :> d:> Nil
209204 listToTuple (a :> b :> c :> d :> Nil)
210205 = (a, b, c, d)
211206
212−instance ListTuple (a, b, c, d, e) '[a, b, c, d, e] where
213− type ListToTuple '[a, b, c, d, e] = (a, b, c, d, e)
207+instance ListTuple (a, b, c, d, e) '[ a, b, c, d, e] where
208+ type ListToTuple '[ a, b, c, d, e] = (a, b, c, d, e)
214209 tupleToList (a, b, c, d, e)
215210 = a :> b :> c :> d:> e :> Nil
216211 listToTuple (a :> b :> c :> d :> e :> Nil)
217212 = (a, b, c, d, e)
218213
219−instance ListTuple (a, b, c, d, e, f) '[a, b, c, d, e, f] where
220− type ListToTuple '[a, b, c, d, e, f] = (a, b, c, d, e, f)
214+instance ListTuple (a, b, c, d, e, f) '[ a, b, c, d, e, f] where
215+ type ListToTuple '[ a, b, c, d, e, f] = (a, b, c, d, e, f)
221216 tupleToList (a, b, c, d, e, f)
222217 = a :> b :> c :> d:> e :> f :> Nil
223218 listToTuple (a :> b :> c :> d :> e :> f :> Nil)
224219 = (a, b, c, d, e, f)
225220
226−instance ListTuple (a, b, c, d, e, f, g) '[a, b, c, d, e, f, g] where
227− type ListToTuple '[a, b, c, d, e, f, g] = (a, b, c, d, e, f, g)
221+instance ListTuple (a, b, c, d, e, f, g) '[ a, b, c, d, e, f, g] where
222+ type ListToTuple '[ a, b, c, d, e, f, g] = (a, b, c, d, e, f, g)
228223 tupleToList (a, b, c, d, e, f, g)
229224 = a :> b :> c :> d:> e :> f :> g :> Nil
230225 listToTuple (a :> b :> c :> d :> e :> f :> g :> Nil)
231226 = (a, b, c, d, e, f, g)
232227
233−instance ListTuple (a, b, c, d, e, f, g, h) '[a, b, c, d, e, f, g, h] where
234− type ListToTuple '[a, b, c, d, e, f, g, h] = (a, b, c, d, e, f, g, h)
228+instance ListTuple (a, b, c, d, e, f, g, h) '[ a, b, c, d, e, f, g, h] where
229+ type ListToTuple '[ a, b, c, d, e, f, g, h] = (a, b, c, d, e, f, g, h)
235230 tupleToList (a, b, c, d, e, f, g, h)
236231 = a :> b :> c :> d:> e :> f :> g :> h :> Nil
237232 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> Nil)
238233 = (a, b, c, d, e, f, g, h)
239234
240−instance ListTuple (a, b, c, d, e, f, g, h, j) '[a, b, c, d, e, f, g, h, j] where
241− type ListToTuple '[a, b, c, d, e, f, g, h, j] = (a, b, c, d, e, f, g, h, j)
235+instance ListTuple (a, b, c, d, e, f, g, h, j) '[ a, b, c, d, e, f, g, h, j] where
236+ type ListToTuple '[ a, b, c, d, e, f, g, h, j] = (a, b, c, d, e, f, g, h, j)
242237 tupleToList (a, b, c, d, e, f, g, h, j)
243238 = a :> b :> c :> d:> e :> f :> g :> h :> j :> Nil
244239 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> j :> Nil)
245240 = (a, b, c, d, e, f, g, h, j)
246241
247−instance ListTuple (a, b, c, d, e, f, g, h, j, k) '[a, b, c, d, e, f, g, h, j, k] where
248− type ListToTuple '[a, b, c, d, e, f, g, h, j, k] = (a, b, c, d, e, f, g, h, j, k)
242+instance ListTuple (a, b, c, d, e, f, g, h, j, k) '[ a, b, c, d, e, f, g, h, j, k] where
243+ type ListToTuple '[ a, b, c, d, e, f, g, h, j, k] = (a, b, c, d, e, f, g, h, j, k)
249244 tupleToList (a, b, c, d, e, f, g, h, j, k)
250245 = a :> b :> c :> d:> e :> f :> g :> h :> j :> k :> Nil
251246 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> j :> k :> Nil)
252247 = (a, b, c, d, e, f, g, h, j, k)
253248
254−instance ListTuple (a, b, c, d, e, f, g, h, j, k, l) '[a, b, c, d, e, f, g, h, j, k, l] where
255− type ListToTuple '[a, b, c, d, e, f, g, h, j, k, l] = (a, b, c, d, e, f, g, h, j, k, l)
249+instance ListTuple (a, b, c, d, e, f, g, h, j, k, l) '[ a, b, c, d, e, f, g, h, j, k, l] where
250+ type ListToTuple '[ a, b, c, d, e, f, g, h, j, k, l] = (a, b, c, d, e, f, g, h, j, k, l)
256251 tupleToList (a, b, c, d, e, f, g, h, j, k, l)
257252 = a :> b :> c :> d:> e :> f :> g :> h :> j :> k :> l :> Nil
258253 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> j :> k :> l :> Nil)
259254 = (a, b, c, d, e, f, g, h, j, k, l)
260255
261−instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m) '[a, b, c, d, e, f, g, h, j, k, l, m] where
262− type ListToTuple '[a, b, c, d, e, f, g, h, j, k, l, m] = (a, b, c, d, e, f, g, h, j, k, l, m)
256+instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m) '[ a, b, c, d, e, f, g, h, j, k, l, m] where
257+ type ListToTuple '[ a, b, c, d, e, f, g, h, j, k, l, m] = (a, b, c, d, e, f, g, h, j, k, l, m)
263258 tupleToList (a, b, c, d, e, f, g, h, j, k, l, m)
264259 = a :> b :> c :> d:> e :> f :> g :> h :> j :> k :> l :> m :> Nil
265260 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> j :> k :> l :> m :> Nil)
266261 = (a, b, c, d, e, f, g, h, j, k, l, m)
267262
268−instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m, n) '[a, b, c, d, e, f, g, h, j, k, l, m, n] where
269− type ListToTuple '[a, b, c, d, e, f, g, h, j, k, l, m, n] = (a, b, c, d, e, f, g, h, j, k, l, m, n)
263+instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m, n) '[ a, b, c, d, e, f, g, h, j, k, l, m, n] where
264+ type ListToTuple '[ a, b, c, d, e, f, g, h, j, k, l, m, n] = (a, b, c, d, e, f, g, h, j, k, l, m, n)
270265 tupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n)
271266 = a :> b :> c :> d:> e :> f :> g :> h :> j :> k :> l :> m :> n :> Nil
272267 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> j :> k :> l :> m :> n :> Nil)
273268 = (a, b, c, d, e, f, g, h, j, k, l, m, n)
274269
275−instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m, n, o) '[a, b, c, d, e, f, g, h, j, k, l, m, n, o] where
276− type ListToTuple '[a, b, c, d, e, f, g, h, j, k, l, m, n, o] = (a, b, c, d, e, f, g, h, j, k, l, m, n, o)
270+instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m, n, o) '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o] where
271+ type ListToTuple '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o] = (a, b, c, d, e, f, g, h, j, k, l, m, n, o)
277272 tupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o)
278273 = a :> b :> c :> d:> e :> f :> g :> h :> j :> k :> l :> m :> n :> o :> Nil
279274 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> j :> k :> l :> m :> n :> o :> Nil)
280275 = (a, b, c, d, e, f, g, h, j, k, l, m, n, o)
281276
282−instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p) '[a, b, c, d, e, f, g, h, j, k, l, m, n, o, p] where
283− type ListToTuple '[a, b, c, d, e, f, g, h, j, k, l, m, n, o, p] = (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p)
277+instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p) '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o, p] where
278+ type ListToTuple '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o, p] = (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p)
284279 tupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p)
285280 = a :> b :> c :> d:> e :> f :> g :> h :> j :> k :> l :> m :> n :> o :> p :> Nil
286281 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> j :> k :> l :> m :> n :> o :> p :> Nil)
287282 = (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p)
288283
289−instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q) '[a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q] where
290− type ListToTuple '[a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q] = (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q)
284+instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q) '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q] where
285+ type ListToTuple '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q] = (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q)
291286 tupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q)
292287 = a :> b :> c :> d:> e :> f :> g :> h :> j :> k :> l :> m :> n :> o :> p :> q :> Nil
293288 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> j :> k :> l :> m :> n :> o :> p :> q :> Nil)
294289 = (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q)
295290
296−instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r) '[a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r] where
297− type ListToTuple '[a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r] = (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r)
291+instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r) '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r] where
292+ type ListToTuple '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r] = (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r)
298293 tupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r)
299294 = a :> b :> c :> d:> e :> f :> g :> h :> j :> k :> l :> m :> n :> o :> p :> q :> r :> Nil
300295 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> j :> k :> l :> m :> n :> o :> p :> q :> r :> Nil)
301296 = (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r)
302297
303−instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s) '[a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s] where
304− type ListToTuple '[a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s] = (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s)
298+instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s) '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s] where
299+ type ListToTuple '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s] = (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s)
305300 tupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s)
306301 = a :> b :> c :> d:> e :> f :> g :> h :> j :> k :> l :> m :> n :> o :> p :> q :> r :> s :> Nil
307302 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> j :> k :> l :> m :> n :> o :> p :> q :> r :> s :> Nil)
@@ -309,21 +304,21 @@ instance ListTuple (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s) '[a, b
309304
310305type family TupleToList a where
311306 TupleToList () = '[]
312− TupleToList (a, b) = '[a, b]
313− TupleToList (a, b, c) = '[a, b, c]
314− TupleToList (a, b, c, d) = '[a, b, c, d]
315− TupleToList (a, b, c, d, e) = '[a, b, c, d, e]
316− TupleToList (a, b, c, d, e, f) = '[a, b, c, d, e, f]
317− TupleToList (a, b, c, d, e, f, g) = '[a, b, c, d, e, f, g]
318− TupleToList (a, b, c, d, e, f, g, h) = '[a, b, c, d, e, f, g, h]
319− TupleToList (a, b, c, d, e, f, g, h, j) = '[a, b, c, d, e, f, g, h, j]
320− TupleToList (a, b, c, d, e, f, g, h, j, k) = '[a, b, c, d, e, f, g, h, j, k]
321− TupleToList (a, b, c, d, e, f, g, h, j, k, l) = '[a, b, c, d, e, f, g, h, j, k, l]
322− TupleToList (a, b, c, d, e, f, g, h, j, k, l, m) = '[a, b, c, d, e, f, g, h, j, k, l, m]
323− TupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n) = '[a, b, c, d, e, f, g, h, j, k, l, m, n]
324− TupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o) = '[a, b, c, d, e, f, g, h, j, k, l, m, n, o]
325− TupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p) = '[a, b, c, d, e, f, g, h, j, k, l, m, n, o, p]
326− TupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q) = '[a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q]
327− TupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r) = '[a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r]
328− TupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s) = '[a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s]
329− TupleToList a = '[a]
307+ TupleToList (a, b) = '[ a, b]
308+ TupleToList (a, b, c) = '[ a, b, c]
309+ TupleToList (a, b, c, d) = '[ a, b, c, d]
310+ TupleToList (a, b, c, d, e) = '[ a, b, c, d, e]
311+ TupleToList (a, b, c, d, e, f) = '[ a, b, c, d, e, f]
312+ TupleToList (a, b, c, d, e, f, g) = '[ a, b, c, d, e, f, g]
313+ TupleToList (a, b, c, d, e, f, g, h) = '[ a, b, c, d, e, f, g, h]
314+ TupleToList (a, b, c, d, e, f, g, h, j) = '[ a, b, c, d, e, f, g, h, j]
315+ TupleToList (a, b, c, d, e, f, g, h, j, k) = '[ a, b, c, d, e, f, g, h, j, k]
316+ TupleToList (a, b, c, d, e, f, g, h, j, k, l) = '[ a, b, c, d, e, f, g, h, j, k, l]
317+ TupleToList (a, b, c, d, e, f, g, h, j, k, l, m) = '[ a, b, c, d, e, f, g, h, j, k, l, m]
318+ TupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n) = '[ a, b, c, d, e, f, g, h, j, k, l, m, n]
319+ TupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o) = '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o]
320+ TupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p) = '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o, p]
321+ TupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q) = '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q]
322+ TupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r) = '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r]
323+ TupleToList (a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s) = '[ a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s]
324+ TupleToList a = '[ a]