@@ -2,8 +2,6 @@
2{-# language ConstraintKinds #-}
2{-# language ConstraintKinds #-}
3{-# language DataKinds #-}
3{-# language DataKinds #-}
4{-# language FlexibleContexts #-}
4{-# language FlexibleContexts #-}
5−{-# language FlexibleInstances #-}
6−{-# language MultiParamTypeClasses #-}
7{-# language NamedFieldPuns #-}
5{-# language NamedFieldPuns #-}
8{-# language ScopedTypeVariables #-}
6{-# language ScopedTypeVariables #-}
9{-# language StandaloneKindSignatures #-}
7{-# language StandaloneKindSignatures #-}
@@ -27,7 +25,6 @@ where
27import Data.Bifunctor ( first )
25import Data.Bifunctor ( first )
28import Data.Kind ( Constraint, Type )
26import Data.Kind ( Constraint, Type )
29import Data.List.NonEmpty ( NonEmpty( (:|) ) )
27import Data.List.NonEmpty ( NonEmpty( (:|) ) )
30−import Data.Type.Equality ( (:~:)( Refl ) )
31import GHC.TypeLits ( Symbol )
28import GHC.TypeLits ( Symbol )
32import Prelude
29import Prelude
@@ -38,7 +35,7 @@ import Rel8.Expr.Aggregate ( groupByExpr )
38import Rel8.Expr.Eq ( (==.) )
35import Rel8.Expr.Eq ( (==.) )
39import Rel8.Expr.Null ( nullify, snull, unsafeUnnullify )
36import Rel8.Expr.Null ( nullify, snull, unsafeUnnullify )
40import Rel8.Expr.Serialize ( litExpr )
37import Rel8.Expr.Serialize ( litExpr )
41−import Rel8.FCF ( Eval, Exp )
38+import Rel8.FCF ( Eval, Exp, Id )
42import Rel8.Generic.Construction.ADT
39import Rel8.Generic.Construction.ADT
43 ( GConstructorADT, GMakeableADT, gmakeADT
40 ( GConstructorADT, GMakeableADT, gmakeADT
44 , GConstructableADT
41 , GConstructableADT
@@ -65,11 +62,9 @@ import qualified Rel8.Schema.Kind as K
65import Rel8.Schema.Name ( Col( N ), Name( Name ) )
62import Rel8.Schema.Name ( Col( N ), Name( Name ) )
66import Rel8.Schema.Null ( Nullity( Null, NotNull ) )
63import Rel8.Schema.Null ( Nullity( Null, NotNull ) )
67import Rel8.Schema.Spec ( SSpec( SSpec, nullity, info ) )
64import Rel8.Schema.Spec ( SSpec( SSpec, nullity, info ) )
68−import Rel8.Schema.Reify ( Col( Reify ), Reify, hreify, hunreify )
69−import Rel8.Schema.Result ( Result )
70import Rel8.Table
65import Rel8.Table
71− ( TTable, TColumns, TUnreify
66+ ( TTable, TColumns
72− , Table, fromColumns, toColumns, reify, unreify
67+ , Table, fromColumns, toColumns
74import Rel8.Table.Bool ( case_ )
69import Rel8.Table.Bool ( case_ )
75import Rel8.Type.Tag ( Tag )
70import Rel8.Type.Tag ( Tag )
@@ -78,10 +73,10 @@ import Rel8.Type.Tag ( Tag )
78type GGBuildable :: K.Algebra -> Symbol -> (K.Context -> Exp (Type -> Type)) -> Constraint
73type GGBuildable :: K.Algebra -> Symbol -> (K.Context -> Exp (Type -> Type)) -> Constraint
79type GGBuildable algebra name rep =
74type GGBuildable algebra name rep =
80 ( KnownAlgebra algebra
75 ( KnownAlgebra algebra
81− , Eval (GGColumns algebra TColumns (Eval (rep (Reify Aggregate)))) ~ Eval (GGColumns algebra TColumns (Eval (rep (Reify Result))))
76+ , Eval (GGColumns algebra TColumns (Eval (rep Aggregate))) ~ Eval (GGColumns algebra TColumns (Eval (rep Expr)))
82− , Eval (GGColumns algebra TColumns (Eval (rep (Reify Expr)))) ~ Eval (GGColumns algebra TColumns (Eval (rep (Reify Result))))
77+ , Eval (GGColumns algebra TColumns (Eval (rep Expr))) ~ Eval (GGColumns algebra TColumns (Eval (rep Expr)))
83− , Eval (GGColumns algebra TColumns (Eval (rep (Reify Name)))) ~ Eval (GGColumns algebra TColumns (Eval (rep (Reify Result))))
78+ , Eval (GGColumns algebra TColumns (Eval (rep Name))) ~ Eval (GGColumns algebra TColumns (Eval (rep Expr)))
84− , HTable (Eval (GGColumns algebra TColumns (Eval (rep (Reify Result)))))
79+ , HTable (Eval (GGColumns algebra TColumns (Eval (rep Expr))))
85 , GGBuildable' algebra name rep
80 , GGBuildable' algebra name rep
@@ -89,65 +84,63 @@ type GGBuildable algebra name rep =
89type GGBuildable' :: K.Algebra -> Symbol -> (K.Context -> Exp (Type -> Type)) -> Constraint
84type GGBuildable' :: K.Algebra -> Symbol -> (K.Context -> Exp (Type -> Type)) -> Constraint
90type family GGBuildable' algebra name rep where
85type family GGBuildable' algebra name rep where
91 GGBuildable' 'K.Product name rep =
86 GGBuildable' 'K.Product name rep =
92− ( name ~ GConstructor (Eval (rep (Reify Expr)))
87+ ( name ~ GConstructor (Eval (rep Expr))
93− , Representable TUnreify (Eval (rep (Reify Expr)))
88+ , Representable Id (Eval (rep Expr))
94− , GConstructable (TTable (Reify Expr)) TColumns TUnreify (Col (Reify Expr)) (Eval (rep (Reify Expr)))
89+ , GConstructable (TTable Expr) TColumns Id (Col Expr) (Eval (rep Expr))
96 GGBuildable' 'K.Sum name rep =
91 GGBuildable' 'K.Sum name rep =
97− ( Representable TUnreify (GConstructorADT name (Eval (rep (Reify Expr))))
92+ ( Representable Id (GConstructorADT name (Eval (rep Expr)))
98− , GMakeableADT (TTable (Reify Expr)) TColumns TUnreify (Col (Reify Expr)) name (Eval (rep (Reify Expr)))
93+ , GMakeableADT (TTable Expr) TColumns Id (Col Expr) name (Eval (rep Expr))
102type GGBuild :: K.Algebra -> Symbol -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
97type GGBuild :: K.Algebra -> Symbol -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
103type family GGBuild algebra name rep r where
98type family GGBuild algebra name rep r where
104 GGBuild 'K.Product _name rep r =
99 GGBuild 'K.Product _name rep r =
105− GConstruct TUnreify (Eval (rep (Reify Expr))) r
100+ GConstruct Id (Eval (rep Expr)) r
106 GGBuild 'K.Sum name rep r =
101 GGBuild 'K.Sum name rep r =
107− GConstruct TUnreify (GConstructorADT name (Eval (rep (Reify Expr)))) r
102+ GConstruct Id (GConstructorADT name (Eval (rep Expr))) r
110ggbuild :: forall algebra name rep a. GGBuildable algebra name rep
105ggbuild :: forall algebra name rep a. GGBuildable algebra name rep
111− => (Eval (GGColumns algebra TColumns (Eval (rep (Reify Result)))) (Col Expr) -> a)
106+ => (Eval (GGColumns algebra TColumns (Eval (rep Expr))) (Col Expr) -> a)
112 -> GGBuild algebra name rep a
107 -> GGBuild algebra name rep a
113ggbuild gfromColumns = case algebraSing @algebra of
108ggbuild gfromColumns = case algebraSing @algebra of
114 SProduct ->
109 SProduct ->
115− gtabulate @TUnreify @(Eval (rep (Reify Expr))) @a $
110+ gtabulate @Id @(Eval (rep Expr)) @a $
116 gfromColumns .
111 gfromColumns .
118 gconstruct
112 gconstruct
119− @(TTable (Reify Expr))
113+ @(TTable Expr)
120 @TColumns
114 @TColumns
122− @(Col (Reify Expr))
116+ @(Col Expr)
123− @(Eval (rep (Reify Expr)))
117+ @(Eval (rep Expr))
124− (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
118+ (const toColumns)
126− gtabulate @TUnreify @(GConstructorADT name (Eval (rep (Reify Expr)))) @a $
120+ gtabulate @Id @(GConstructorADT name (Eval (rep Expr))) @a $
127 gfromColumns .
121 gfromColumns .
130− @(TTable (Reify Expr))
123+ @(TTable Expr)
131 @TColumns
124 @TColumns
133− @(Col (Reify Expr))
126+ @(Col Expr)
135− @(Eval (rep (Reify Expr)))
128+ @(Eval (rep Expr))
136− (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
129+ (const toColumns)
137− (\SSpec {info} -> Reify (E (snull info)))
130+ (\SSpec {info} -> E (snull info))
138 (\SSpec {nullity} -> case nullity of
131 (\SSpec {nullity} -> case nullity of
139 Null -> id
132 Null -> id
140− NotNull -> \(Reify (E a)) -> Reify (E (nullify a)))
133+ NotNull -> \(E a) -> E (nullify a))
141− (HType . Reify . E . litExpr)
134+ (HType . E . litExpr)
144type GGConstructable :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Constraint
137type GGConstructable :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Constraint
145type GGConstructable algebra rep =
138type GGConstructable algebra rep =
146 ( KnownAlgebra algebra
139 ( KnownAlgebra algebra
147− , Eval (GGColumns algebra TColumns (Eval (rep (Reify Aggregate)))) ~ Eval (GGColumns algebra TColumns (Eval (rep (Reify Result))))
140+ , Eval (GGColumns algebra TColumns (Eval (rep Aggregate))) ~ Eval (GGColumns algebra TColumns (Eval (rep Expr)))
148− , Eval (GGColumns algebra TColumns (Eval (rep (Reify Expr)))) ~ Eval (GGColumns algebra TColumns (Eval (rep (Reify Result))))
141+ , Eval (GGColumns algebra TColumns (Eval (rep Expr))) ~ Eval (GGColumns algebra TColumns (Eval (rep Expr)))
149− , Eval (GGColumns algebra TColumns (Eval (rep (Reify Name)))) ~ Eval (GGColumns algebra TColumns (Eval (rep (Reify Result))))
142+ , Eval (GGColumns algebra TColumns (Eval (rep Name))) ~ Eval (GGColumns algebra TColumns (Eval (rep Expr)))
150− , HTable (Eval (GGColumns algebra TColumns (Eval (rep (Reify Result)))))
143+ , HTable (Eval (GGColumns algebra TColumns (Eval (rep Expr))))
151 , GGConstructable' algebra rep
144 , GGConstructable' algebra rep
@@ -155,105 +148,100 @@ type GGConstructable algebra rep =
155type GGConstructable' :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Constraint
148type GGConstructable' :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Constraint
156type family GGConstructable' algebra rep where
149type family GGConstructable' algebra rep where
157 GGConstructable' 'K.Product rep =
150 GGConstructable' 'K.Product rep =
158− ( Representable TUnreify (Eval (rep (Reify Aggregate)))
151+ ( Representable Id (Eval (rep Aggregate))
159− , Representable TUnreify (Eval (rep (Reify Expr)))
152+ , Representable Id (Eval (rep Expr))
160− , Representable TUnreify (Eval (rep (Reify Name)))
153+ , Representable Id (Eval (rep Name))
161− , GConstructable (TTable (Reify Aggregate)) TColumns TUnreify (Col (Reify Aggregate)) (Eval (rep (Reify Aggregate)))
154+ , GConstructable (TTable Aggregate) TColumns Id (Col Aggregate) (Eval (rep Aggregate))
162− , GConstructable (TTable (Reify Expr)) TColumns TUnreify (Col (Reify Expr)) (Eval (rep (Reify Expr)))
155+ , GConstructable (TTable Expr) TColumns Id (Col Expr) (Eval (rep Expr))
163− , GConstructable (TTable (Reify Name)) TColumns TUnreify (Col (Reify Name)) (Eval (rep (Reify Name)))
156+ , GConstructable (TTable Name) TColumns Id (Col Name) (Eval (rep Name))
165 GGConstructable' 'K.Sum rep =
158 GGConstructable' 'K.Sum rep =
166− ( RepresentableConstructors TUnreify (Eval (rep (Reify Expr)))
159+ ( RepresentableConstructors Id (Eval (rep Expr))
167− , RepresentableFields TUnreify (Eval (rep (Reify Aggregate)))
160+ , RepresentableFields Id (Eval (rep Aggregate))
168− , RepresentableFields TUnreify (Eval (rep (Reify Expr)))
161+ , RepresentableFields Id (Eval (rep Expr))
169− , RepresentableFields TUnreify (Eval (rep (Reify Name)))
162+ , RepresentableFields Id (Eval (rep Name))
170− , Functor (GConstructors TUnreify (Eval (rep (Reify Expr))))
163+ , Functor (GConstructors Id (Eval (rep Expr)))
171− , GConstructableADT (TTable (Reify Aggregate)) TColumns TUnreify (Col (Reify Aggregate)) (Eval (rep (Reify Aggregate)))
164+ , GConstructableADT (TTable Aggregate) TColumns Id (Col Aggregate) (Eval (rep Aggregate))
172− , GConstructableADT (TTable (Reify Expr)) TColumns TUnreify (Col (Reify Expr)) (Eval (rep (Reify Expr)))
165+ , GConstructableADT (TTable Expr) TColumns Id (Col Expr) (Eval (rep Expr))
173− , GConstructableADT (TTable (Reify Name)) TColumns TUnreify (Col (Reify Name)) (Eval (rep (Reify Name)))
166+ , GConstructableADT (TTable Name) TColumns Id (Col Name) (Eval (rep Name))
177type GGConstruct :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
170type GGConstruct :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
178type family GGConstruct algebra rep r where
171type family GGConstruct algebra rep r where
179− GGConstruct 'K.Product rep r =
172+ GGConstruct 'K.Product rep r = GConstruct Id (Eval (rep Expr)) r -> r
180− GConstruct TUnreify (Eval (rep (Reify Expr))) r -> r
181− GGConstruct 'K.Sum rep r =
182− GConstructADT TUnreify (Eval (rep (Reify Expr))) r r
173+ GGConstruct 'K.Sum rep r = GConstructADT Id (Eval (rep Expr)) r r
185ggconstruct :: forall algebra rep a. GGConstructable algebra rep
176ggconstruct :: forall algebra rep a. GGConstructable algebra rep
186− => (Eval (GGColumns algebra TColumns (Eval (rep (Reify Result)))) (Col Expr) -> a)
177+ => (Eval (GGColumns algebra TColumns (Eval (rep Expr))) (Col Expr) -> a)
187 -> GGConstruct algebra rep a -> a
178 -> GGConstruct algebra rep a -> a
188ggconstruct gfromColumns f = case algebraSing @algebra of
179ggconstruct gfromColumns f = case algebraSing @algebra of
189 SProduct ->
180 SProduct ->
191− gtabulate @TUnreify @(Eval (rep (Reify Expr))) @a $
182+ gtabulate @Id @(Eval (rep Expr)) @a $
192 gfromColumns .
183 gfromColumns .
194 gconstruct
184 gconstruct
195− @(TTable (Reify Expr))
185+ @(TTable Expr)
196 @TColumns
186 @TColumns
198− @(Col (Reify Expr))
188+ @(Col Expr)
199− @(Eval (rep (Reify Expr)))
189+ @(Eval (rep Expr))
200− (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
190+ (const toColumns)
202− gcindex @TUnreify @(Eval (rep (Reify Expr))) @a f $
192+ gcindex @Id @(Eval (rep Expr)) @a f $
203− fmap (gfromColumns . hunreify) $
193+ fmap gfromColumns $
204 gconstructADT
194 gconstructADT
205− @(TTable (Reify Expr))
195+ @(TTable Expr)
206 @TColumns
196 @TColumns
208− @(Col (Reify Expr))
198+ @(Col Expr)
209− @(Eval (rep (Reify Expr)))
199+ @(Eval (rep Expr))
210− (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
200+ (const toColumns)
211− (\SSpec {info} -> Reify (E (snull info)))
201+ (\SSpec {info} -> E (snull info))
212 (\SSpec {nullity} -> case nullity of
202 (\SSpec {nullity} -> case nullity of
213 Null -> id
203 Null -> id
214− NotNull -> \(Reify (E a)) -> Reify (E (nullify a)))
204+ NotNull -> \(E a) -> E (nullify a))
215− (HType . Reify . E . litExpr)
205+ (HType . E . litExpr)
218type GGDeconstruct :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type -> Type
208type GGDeconstruct :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type -> Type
219type family GGDeconstruct algebra rep a r where
209type family GGDeconstruct algebra rep a r where
220 GGDeconstruct 'K.Product rep a r =
210 GGDeconstruct 'K.Product rep a r =
221− GConstruct TUnreify (Eval (rep (Reify Expr))) r -> a -> r
211+ GConstruct Id (Eval (rep Expr)) r -> a -> r
222 GGDeconstruct 'K.Sum rep a r =
212 GGDeconstruct 'K.Sum rep a r =
223− GConstructADT TUnreify (Eval (rep (Reify Expr))) r (a -> r)
213+ GConstructADT Id (Eval (rep Expr)) r (a -> r)
226ggdeconstruct :: forall algebra rep a r. (GGConstructable algebra rep, Table Expr r)
216ggdeconstruct :: forall algebra rep a r. (GGConstructable algebra rep, Table Expr r)
227− => (a -> Eval (GGColumns algebra TColumns (Eval (rep (Reify Result)))) (Col Expr))
217+ => (a -> Eval (GGColumns algebra TColumns (Eval (rep Expr))) (Col Expr))
228 -> GGDeconstruct algebra rep a r
218 -> GGDeconstruct algebra rep a r
229ggdeconstruct gtoColumns = case algebraSing @algebra of
219ggdeconstruct gtoColumns = case algebraSing @algebra of
230 SProduct -> \build ->
220 SProduct -> \build ->
231− gindex @TUnreify @(Eval (rep (Reify Expr))) @r build .
221+ gindex @Id @(Eval (rep Expr)) @r build .
232 gdeconstruct
222 gdeconstruct
233− @(TTable (Reify Expr))
223+ @(TTable Expr)
234 @TColumns
224 @TColumns
236− @(Col (Reify Expr))
226+ @(Col Expr)
237− @(Eval (rep (Reify Expr)))
227+ @(Eval (rep Expr))
238− (\(_ :: proxy x) -> unreify @_ @x Refl . fromColumns) .
228+ (const fromColumns) .
240 gtoColumns
229 gtoColumns
242− gctabulate @TUnreify @(Eval (rep (Reify Expr))) @r @(a -> r) $ \constructors as ->
231+ gctabulate @Id @(Eval (rep Expr)) @r @(a -> r) $ \constructors as ->
244− (HType (Reify (E tag)), cases) =
233+ (HType (E tag), cases) =
245 gdeconstructADT
234 gdeconstructADT
246− @(TTable (Reify Expr))
235+ @(TTable Expr)
247 @TColumns
236 @TColumns
249− @(Col (Reify Expr))
238+ @(Col Expr)
250− @(Eval (rep (Reify Expr)))
239+ @(Eval (rep Expr))
251− (\(_ :: proxy x) -> unreify @_ @x Refl . fromColumns)
240+ (const fromColumns)
252 (\SSpec {nullity} -> case nullity of
241 (\SSpec {nullity} -> case nullity of
253 Null -> id
242 Null -> id
254− NotNull -> \(Reify (E a)) -> Reify (E (unsafeUnnullify a)))
243+ NotNull -> \(E a) -> E (unsafeUnnullify a))
255 constructors $
244 constructors $
257 gtoColumns as
245 gtoColumns as
259 case cases of
247 case cases of
@@ -263,108 +251,102 @@ ggdeconstruct gtoColumns = case algebraSing @algebra of
264type GGName :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
252type GGName :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
265type family GGName algebra rep a where
253type family GGName algebra rep a where
266− GGName 'K.Product rep a = GConstruct TUnreify (Eval (rep (Reify Name))) a
254+ GGName 'K.Product rep a = GConstruct Id (Eval (rep Name)) a
267− GGName 'K.Sum rep a = Name Tag -> GBuildADT TUnreify (Eval (rep (Reify Name))) a
255+ GGName 'K.Sum rep a = Name Tag -> GBuildADT Id (Eval (rep Name)) a
270ggname :: forall algebra rep a. GGConstructable algebra rep
258ggname :: forall algebra rep a. GGConstructable algebra rep
271− => (Eval (GGColumns algebra TColumns (Eval (rep (Reify Result)))) (Col Name) -> a)
259+ => (Eval (GGColumns algebra TColumns (Eval (rep Expr))) (Col Name) -> a)
272 -> GGName algebra rep a
260 -> GGName algebra rep a
273ggname gfromColumns = case algebraSing @algebra of
261ggname gfromColumns = case algebraSing @algebra of
274 SProduct ->
262 SProduct ->
275− gtabulate @TUnreify @(Eval (rep (Reify Name))) @a $
263+ gtabulate @Id @(Eval (rep Name)) @a $
276 gfromColumns .
264 gfromColumns .
278 gconstruct
265 gconstruct
279− @(TTable (Reify Name))
266+ @(TTable Name)
280 @TColumns
267 @TColumns
282− @(Col (Reify Name))
269+ @(Col Name)
283− @(Eval (rep (Reify Name)))
270+ @(Eval (rep Name))
284− (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
271+ (const toColumns)
285 SSum -> \tag ->
272 SSum -> \tag ->
286− gftabulate @TUnreify @(Eval (rep (Reify Name))) @a $
273+ gftabulate @Id @(Eval (rep Name)) @a $
287 gfromColumns .
274 gfromColumns .
289 gbuildADT
275 gbuildADT
290− @(TTable (Reify Name))
276+ @(TTable Name)
291 @TColumns
277 @TColumns
293− @(Col (Reify Name))
279+ @(Col Name)
294− @(Eval (rep (Reify Name)))
280+ @(Eval (rep Name))
295− (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
281+ (const toColumns)
296− (\_ _ (Reify (N (Name a))) -> Reify (N (Name a)))
282+ (\_ _ (N (Name a)) -> N (Name a))
297− (HType (Reify (N tag)))
283+ (HType (N tag))
300type GGAggregate :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
286type GGAggregate :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
301type family GGAggregate algebra rep r where
287type family GGAggregate algebra rep r where
302 GGAggregate 'K.Product rep r =
288 GGAggregate 'K.Product rep r =
303− GConstruct TUnreify (Eval (rep (Reify Aggregate))) r ->
289+ GConstruct Id (Eval (rep Aggregate)) r ->
304− GConstruct TUnreify (Eval (rep (Reify Expr))) r
290+ GConstruct Id (Eval (rep Expr)) r
305 GGAggregate 'K.Sum rep r =
291 GGAggregate 'K.Sum rep r =
306− GBuildADT TUnreify (Eval (rep (Reify Aggregate))) r ->
292+ GBuildADT Id (Eval (rep Aggregate)) r ->
307− GBuildADT TUnreify (Eval (rep (Reify Expr))) r
293+ GBuildADT Id (Eval (rep Expr)) r
310ggaggregate :: forall algebra rep exprs agg. GGConstructable algebra rep
296ggaggregate :: forall algebra rep exprs agg. GGConstructable algebra rep
311− => (Eval (GGColumns algebra TColumns (Eval (rep (Reify Result)))) (Col Aggregate) -> agg)
297+ => (Eval (GGColumns algebra TColumns (Eval (rep Expr))) (Col Aggregate) -> agg)
312− -> (exprs -> Eval (GGColumns algebra TColumns (Eval (rep (Reify Result)))) (Col Expr))
298+ -> (exprs -> Eval (GGColumns algebra TColumns (Eval (rep Expr))) (Col Expr))
313 -> GGAggregate algebra rep agg -> exprs -> agg
299 -> GGAggregate algebra rep agg -> exprs -> agg
314ggaggregate gfromColumns gtoColumns agg es = case algebraSing @algebra of
300ggaggregate gfromColumns gtoColumns agg es = case algebraSing @algebra of
315 SProduct -> flip f exprs $
301 SProduct -> flip f exprs $
316 gfromColumns .
302 gfromColumns .
318 gconstruct
303 gconstruct
319− @(TTable (Reify Aggregate))
304+ @(TTable Aggregate)
320 @TColumns
305 @TColumns
322− @(Col (Reify Aggregate))
307+ @(Col Aggregate)
323− @(Eval (rep (Reify Aggregate)))
308+ @(Eval (rep Aggregate))
324− (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
309+ (const toColumns)
327− gindex @TUnreify @(Eval (rep (Reify Expr))) @agg .
312+ gindex @Id @(Eval (rep Expr)) @agg .
329− gtabulate @TUnreify @(Eval (rep (Reify Aggregate))) @agg
314+ gtabulate @Id @(Eval (rep Aggregate)) @agg
331 gdeconstruct
316 gdeconstruct
332− @(TTable (Reify Expr))
317+ @(TTable Expr)
333 @TColumns
318 @TColumns
335− @(Col (Reify Expr))
320+ @(Col Expr)
336− @(Eval (rep (Reify Expr)))
321+ @(Eval (rep Expr))
337− (\(_ :: proxy x) -> unreify @_ @x Refl . fromColumns) $
322+ (const fromColumns) $
339 gtoColumns es
323 gtoColumns es
340 SSum -> flip f exprs $
324 SSum -> flip f exprs $
341 gfromColumns .
325 gfromColumns .
343 gbuildADT
326 gbuildADT
344− @(TTable (Reify Aggregate))
327+ @(TTable Aggregate)
345 @TColumns
328 @TColumns
347− @(Col (Reify Aggregate))
330+ @(Col Aggregate)
348− @(Eval (rep (Reify Aggregate)))
331+ @(Eval (rep Aggregate))
349− (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
332+ (const toColumns)
350− (\tag' SSpec {nullity} (Reify (A (Aggregate a))) ->
333+ (\tag' SSpec {nullity} (A (Aggregate a)) ->
351− Reify $ A $ Aggregate $ sguard (tag ==. litExpr tag') . snullify nullity <$> a)
334+ A $ Aggregate $ sguard (tag ==. litExpr tag') . snullify nullity <$> a)
352− (HType (Reify (A (groupByExpr tag))))
335+ (HType (A (groupByExpr tag)))
355− gfindex @TUnreify @(Eval (rep (Reify Expr))) @agg .
338+ gfindex @Id @(Eval (rep Expr)) @agg .
357− gftabulate @TUnreify @(Eval (rep (Reify Aggregate))) @agg
340+ gftabulate @Id @(Eval (rep Aggregate)) @agg
358− (HType (Reify (E tag)), exprs) =
341+ (HType (E tag), exprs) =
359 gunbuildADT
342 gunbuildADT
360− @(TTable (Reify Expr))
343+ @(TTable Expr)
361 @TColumns
344 @TColumns
363− @(Col (Reify Expr))
346+ @(Col Expr)
364− @(Eval (rep (Reify Expr)))
347+ @(Eval (rep Expr))
365− (\(_ :: proxy x) -> unreify @_ @x Refl . fromColumns)
348+ (const fromColumns)
366 (\SSpec {nullity} -> case nullity of
349 (\SSpec {nullity} -> case nullity of
367 Null -> id
350 Null -> id
368− NotNull -> \(Reify (E a)) -> Reify (E (unsafeUnnullify a))) $
351+ NotNull -> \(E a) -> E (unsafeUnnullify a)) $
370 gtoColumns es
352 gtoColumns es