@@ -120,19 +120,17 @@ type family GGConstructable' algebra rep where
122type GGConstruct :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
122type GGConstruct :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
123−type family GGConstruct algebra rep a where
123+type family GGConstruct algebra rep r where
124− GGConstruct 'K.Product rep a = GConstruct TUnreify (Eval (rep (Reify Expr))) a
124+ GGConstruct 'K.Product rep r = GConstruct TUnreify (Eval (rep (Reify Expr))) r -> r
125− GGConstruct 'K.Sum rep a =
126− -- Ideally this would be as follows, but GHC complains about "illegal polymorphic type"
127− -- (forall r. GConstructADT TUnreify (Eval (rep (Reify Expr))) r r) -> a
125+ GGConstruct 'K.Sum rep r = GConstructADT TUnreify (Eval (rep (Reify Expr))) r r
128− GConstructADT TUnreify (Eval (rep (Reify Expr))) a a -> a
131ggconstruct :: forall algebra rep a. GGConstructable algebra rep
128ggconstruct :: forall algebra rep a. GGConstructable algebra rep
132 => (Eval (GGColumns algebra TColumns (Eval (rep (Reify Result)))) (Col Expr) -> a)
129 => (Eval (GGColumns algebra TColumns (Eval (rep (Reify Result)))) (Col Expr) -> a)
133− -> GGConstruct algebra rep a
130+ -> GGConstruct algebra rep a -> a
134−ggconstruct gfromColumns = case algebraSing @algebra of
131+ggconstruct gfromColumns f = case algebraSing @algebra of
135 SProduct ->
132 SProduct ->
136 gtabulate @TUnreify @(Eval (rep (Reify Expr))) @a $
134 gtabulate @TUnreify @(Eval (rep (Reify Expr))) @a $
137 gfromColumns .
135 gfromColumns .
138 hunreify .
136 hunreify .
@@ -143,7 +141,7 @@ ggconstruct gfromColumns = case algebraSing @algebra of
143 @(Col (Reify Expr))
141 @(Col (Reify Expr))
144 @(Eval (rep (Reify Expr)))
142 @(Eval (rep (Reify Expr)))
145 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
143 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
146− SSum -> \f ->
144+ SSum ->
147 gcindex @TUnreify @(Eval (rep (Reify Expr))) @a f $
145 gcindex @TUnreify @(Eval (rep (Reify Expr))) @a f $
148 fmap (gfromColumns . hunreify) $
146 fmap (gfromColumns . hunreify) $
149 gconstructADT
147 gconstructADT
@@ -207,19 +205,20 @@ ggdeconstruct gtoColumns = case algebraSing @algebra of
209type GGInsert :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
207type GGInsert :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
210−type family GGInsert algebra rep a where
208+type family GGInsert algebra rep r where
209+ GGInsert 'K.Product rep r =
211− GGInsert 'K.Product rep a = GConstruct TUnreify (Eval (rep (Reify Insert))) a
210+ GConstruct TUnreify (Eval (rep (Reify Insert))) r -> r
212− GGInsert 'K.Sum rep a =
211+ GGInsert 'K.Sum rep r =
213− -- Ideally this would be as follows, but GHC complains about "illegal polymorphic type"
214− -- (forall r. GConstructADT TUnreify (Eval (rep (Reify Insert))) r r) -> a
212+ GConstructADT TUnreify (Eval (rep (Reify Insert))) r r
215− GConstructADT TUnreify (Eval (rep (Reify Insert))) a a -> a
218gginsert :: forall algebra rep a. GGConstructable algebra rep
215gginsert :: forall algebra rep a. GGConstructable algebra rep
219 => (Eval (GGColumns algebra TColumns (Eval (rep (Reify Result)))) (Col Insert) -> a)
216 => (Eval (GGColumns algebra TColumns (Eval (rep (Reify Result)))) (Col Insert) -> a)
220 -> GGInsert algebra rep a
217 -> GGInsert algebra rep a
221−gginsert gfromColumns = case algebraSing @algebra of
219+gginsert gfromColumns f = case algebraSing @algebra of
222 SProduct ->
220 SProduct ->
223 gtabulate @TUnreify @(Eval (rep (Reify Insert))) @a $
222 gtabulate @TUnreify @(Eval (rep (Reify Insert))) @a $
224 gfromColumns .
223 gfromColumns .
225 hunreify .
224 hunreify .
@@ -230,7 +229,7 @@ gginsert gfromColumns = case algebraSing @algebra of
230 @(Col (Reify Insert))
229 @(Col (Reify Insert))
231 @(Eval (rep (Reify Insert)))
230 @(Eval (rep (Reify Insert)))
232 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
231 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
233− SSum -> \f ->
232+ SSum ->
234 gcindex @TUnreify @(Eval (rep (Reify Insert))) @a f $
233 gcindex @TUnreify @(Eval (rep (Reify Insert))) @a f $
235 fmap (gfromColumns . hunreify) $
234 fmap (gfromColumns . hunreify) $
236 gconstructADT
235 gconstructADT