@@ -67,74 +67,87 @@ instance Splittable as bs cs => Splittable (a ': as) bs (a ': cs) where
6767-- * Convert tuples to/from HLists
6868
6969class ListTuple (tuple :: Type) (as :: [Type]) | as -> tuple where
70+ type ListToTuple as :: Type
7071 tupleToList :: tuple -> HList as
7172 listToTuple :: HList as -> tuple
7273
7374instance ListTuple () '[] where
75+ type ListToTuple '[] = ()
7476 tupleToList _ = Nil
7577 listToTuple _ = ()
7678
7779instance ListTuple a '[a] where
80+ type ListToTuple '[a] = a
7881 tupleToList a
7982 = a :> Nil
8083 listToTuple (a :> Nil)
8184 = a
8285
8386instance ListTuple (a, b) '[a, b] where
87+ type ListToTuple '[a, b] = (a, b)
8488 tupleToList (a, b)
8589 = a :> b :> Nil
8690 listToTuple (a :> b :> Nil)
8791 = (a, b)
8892
8993instance ListTuple (a, b, c) '[a, b, c] where
94+ type ListToTuple '[a, b, c] = (a, b, c)
9095 tupleToList (a, b, c)
9196 = a :> b :> c :> Nil
9297 listToTuple (a :> b :> c :> Nil)
9398 = (a, b, c)
9499
95100instance ListTuple (a, b, c, d) '[a, b, c, d] where
101+ type ListToTuple '[a, b, c, d] = (a, b, c, d)
96102 tupleToList (a, b, c, d)
97103 = a :> b :> c :> d:> Nil
98104 listToTuple (a :> b :> c :> d :> Nil)
99105 = (a, b, c, d)
100106
101107instance ListTuple (a, b, c, d, e) '[a, b, c, d, e] where
108+ type ListToTuple '[a, b, c, d, e] = (a, b, c, d, e)
102109 tupleToList (a, b, c, d, e)
103110 = a :> b :> c :> d:> e :> Nil
104111 listToTuple (a :> b :> c :> d :> e :> Nil)
105112 = (a, b, c, d, e)
106113
107114instance ListTuple (a, b, c, d, e, f) '[a, b, c, d, e, f] where
115+ type ListToTuple '[a, b, c, d, e, f] = (a, b, c, d, e, f)
108116 tupleToList (a, b, c, d, e, f)
109117 = a :> b :> c :> d:> e :> f :> Nil
110118 listToTuple (a :> b :> c :> d :> e :> f :> Nil)
111119 = (a, b, c, d, e, f)
112120
113121instance ListTuple (a, b, c, d, e, f, g) '[a, b, c, d, e, f, g] where
122+ type ListToTuple '[a, b, c, d, e, f, g] = (a, b, c, d, e, f, g)
114123 tupleToList (a, b, c, d, e, f, g)
115124 = a :> b :> c :> d:> e :> f :> g :> Nil
116125 listToTuple (a :> b :> c :> d :> e :> f :> g :> Nil)
117126 = (a, b, c, d, e, f, g)
118127
119128instance ListTuple (a, b, c, d, e, f, g, h) '[a, b, c, d, e, f, g, h] where
129+ type ListToTuple '[a, b, c, d, e, f, g, h] = (a, b, c, d, e, f, g, h)
120130 tupleToList (a, b, c, d, e, f, g, h)
121131 = a :> b :> c :> d:> e :> f :> g :> h :> Nil
122132 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> Nil)
123133 = (a, b, c, d, e, f, g, h)
124134
125135instance ListTuple (a, b, c, d, e, f, g, h, j) '[a, b, c, d, e, f, g, h, j] where
136+ type ListToTuple '[a, b, c, d, e, f, g, h, j] = (a, b, c, d, e, f, g, h, j)
126137 tupleToList (a, b, c, d, e, f, g, h, j)
127138 = a :> b :> c :> d:> e :> f :> g :> h :> j :> Nil
128139 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> j :> Nil)
129140 = (a, b, c, d, e, f, g, h, j)
130141
131142instance ListTuple (a, b, c, d, e, f, g, h, j, k) '[a, b, c, d, e, f, g, h, j, k] where
143+ type ListToTuple '[a, b, c, d, e, f, g, h, j, k] = (a, b, c, d, e, f, g, h, j, k)
132144 tupleToList (a, b, c, d, e, f, g, h, j, k)
133145 = a :> b :> c :> d:> e :> f :> g :> h :> j :> k :> Nil
134146 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> j :> k :> Nil)
135147 = (a, b, c, d, e, f, g, h, j, k)
136148
137149instance ListTuple (a, b, c, d, e, f, g, h, j, k, l) '[a, b, c, d, e, f, g, h, j, k, l] where
150+ type ListToTuple '[a, b, c, d, e, f, g, h, j, k, l] = (a, b, c, d, e, f, g, h, j, k, l)
138151 tupleToList (a, b, c, d, e, f, g, h, j, k, l)
139152 = a :> b :> c :> d:> e :> f :> g :> h :> j :> k :> l :> Nil
140153 listToTuple (a :> b :> c :> d :> e :> f :> g :> h :> j :> k :> l :> Nil)
@@ -143,6 +156,7 @@ instance ListTuple (a, b, c, d, e, f, g, h, j, k, l) '[a, b, c, d, e, f, g, h, j
143156--------------------------------------------------------------------------------
144157
145158class GCollectible (f :: Type -> Type) (as :: [Type]) | f -> as where
159+ type GCollect f :: [Type]
146160 gtoCollection :: f x -> HList as
147161 gfromCollection :: HList as -> f x
148162
@@ -152,6 +166,7 @@ instance
152166 , cs ~ (as ++ bs)
153167 , Splittable as bs cs
154168 ) => GCollectible (l :*: r) cs where
169+ type GCollect (l :*: r) = GCollect l ++ GCollect r
155170
156171 gtoCollection (l :*: r)
157172 = gtoCollection l `append` gtoCollection r
@@ -160,14 +175,17 @@ instance
160175 = gfromCollection as :*: gfromCollection bs
161176 where (as, bs) = split cs
162177
163−instance GCollectible (K1 R a) '[a] where
178+instance GCollectible (Rec0 a) '[a] where
179+ type GCollect (Rec0 a) = '[a]
164180 gtoCollection = (:> Nil) . unK1
165181 gfromCollection = K1 . head'
166182
167183instance GCollectible U1 '[] where
184+ type GCollect U1 = '[]
168185 gtoCollection U1 = Nil
169186 gfromCollection Nil = U1
170187
171188instance GCollectible f as => GCollectible (M1 m meta f) as where
189+ type GCollect (M1 m meta f) = GCollect f
172190 gtoCollection = gtoCollection . unM1
173191 gfromCollection = M1 . gfromCollection