@@ -35,8 +35,8 @@ import GHC.TypeLits ( Symbol )
3535import Prelude
3636
3737-- rel8
38−import Rel8.Aggregate ( Col( Aggregation ), Aggregate )
39−import Rel8.Expr ( Col( DB ), Expr )
38+import Rel8.Aggregate ( Col( A ), Aggregate )
39+import Rel8.Expr ( Col( E ), Expr )
4040import Rel8.Expr.Aggregate ( groupByExpr )
4141import Rel8.Expr.Eq ( (==.) )
4242import Rel8.Expr.Null ( nullify, snull, unsafeUnnullify )
@@ -64,9 +64,9 @@ import qualified Rel8.Kind.Algebra as K
6464import Rel8.Schema.Context.Nullify ( runTag )
6565import Rel8.Schema.HTable ( HTable )
6666import Rel8.Schema.HTable.Identity ( HIdentity( HType ) )
67−import Rel8.Schema.Insert ( Col( InsertCol ), Insert, Insertion(..) )
67+import Rel8.Schema.Insert ( Col( I ), Insert, Insertion(..) )
6868import qualified Rel8.Schema.Kind as K
69−import Rel8.Schema.Name ( Col( NameCol ), Name( Name ) )
69+import Rel8.Schema.Name ( Col( N ), Name( Name ) )
7070import Rel8.Schema.Null ( Nullity( Null, NotNull ) )
7171import Rel8.Schema.Spec ( SSpec( SSpec, nullity, info ) )
7272import Rel8.Schema.Reify ( Col( Reify ), Reify, hreify, hunreify )
@@ -147,11 +147,11 @@ ggbuild gfromColumns = case algebraSing @algebra of
147147 @name
148148 @(Eval (rep (Reify Expr)))
149149 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
150− (\SSpec {info} -> Reify (DB (snull info)))
150+ (\SSpec {info} -> Reify (E (snull info)))
151151 (\SSpec {nullity} -> case nullity of
152152 Null -> id
153− NotNull -> \(Reify (DB a)) -> Reify (DB (nullify a)))
154− (HType . Reify . DB . litExpr)
153+ NotNull -> \(Reify (E a)) -> Reify (E (nullify a)))
154+ (HType . Reify . E . litExpr)
155155
156156
157157type GGInsert :: K.Algebra -> Symbol -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
@@ -189,13 +189,13 @@ gginsert gfromColumns = case algebraSing @algebra of
189189 @name
190190 @(Eval (rep (Reify Insert)))
191191 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
192− (\SSpec {info} -> Reify $ InsertCol (Insertion (snull info)))
192+ (\SSpec {info} -> Reify $ I (Insertion (snull info)))
193193 (\SSpec {nullity} -> case nullity of
194194 Null -> id
195195 NotNull -> \case
196− Reify (InsertCol Default) -> Reify (InsertCol Default)
197− Reify (InsertCol (Insertion a)) -> Reify (InsertCol (Insertion (nullify a))))
198− (HType . Reify . InsertCol . Insertion . litExpr)
196+ Reify (I Default) -> Reify (I Default)
197+ Reify (I (Insertion a)) -> Reify (I (Insertion (nullify a))))
198+ (HType . Reify . I . Insertion . litExpr)
199199
200200
201201type GGConstructable :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Constraint
@@ -273,11 +273,11 @@ ggconstruct gfromColumns f = case algebraSing @algebra of
273273 @(Col (Reify Expr))
274274 @(Eval (rep (Reify Expr)))
275275 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
276− (\SSpec {info} -> Reify (DB (snull info)))
276+ (\SSpec {info} -> Reify (E (snull info)))
277277 (\SSpec {nullity} -> case nullity of
278278 Null -> id
279− NotNull -> \(Reify (DB a)) -> Reify (DB (nullify a)))
280− (HType . Reify . DB . litExpr)
279+ NotNull -> \(Reify (E a)) -> Reify (E (nullify a)))
280+ (HType . Reify . E . litExpr)
281281
282282
283283type GGDeconstruct :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type -> Type
@@ -306,7 +306,7 @@ ggdeconstruct gtoColumns = case algebraSing @algebra of
306306 SSum ->
307307 gctabulate @TUnreify @(Eval (rep (Reify Expr))) @r @(a -> r) $ \constructors as ->
308308 let
309− (HType (Reify (DB tag)), cases) =
309+ (HType (Reify (E tag)), cases) =
310310 gdeconstructADT
311311 @(TTable (Reify Expr))
312312 @TColumns
@@ -316,7 +316,7 @@ ggdeconstruct gtoColumns = case algebraSing @algebra of
316316 (\(_ :: proxy x) -> unreify @_ @x Refl . fromColumns)
317317 (\SSpec {nullity} -> case nullity of
318318 Null -> id
319− NotNull -> \(Reify (DB a)) -> Reify (DB (unsafeUnnullify a)))
319+ NotNull -> \(Reify (E a)) -> Reify (E (unsafeUnnullify a)))
320320 constructors $
321321 hreify $
322322 gtoColumns as
@@ -358,8 +358,8 @@ ggname gfromColumns = case algebraSing @algebra of
358358 @(Col (Reify Name))
359359 @(Eval (rep (Reify Name)))
360360 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
361− (\_ _ (Reify (NameCol a)) -> Reify (NameCol a))
362− (HType ((\(Name a) -> Reify (NameCol a)) tag))
361+ (\_ _ (Reify (N (Name a))) -> Reify (N (Name a)))
362+ (HType (Reify (N tag)))
363363
364364
365365type GGAggregate :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
@@ -418,9 +418,9 @@ ggaggregate gfromColumns gtoColumns agg es = case algebraSing @algebra of
418418 @(Col (Reify Expr))
419419 @(Eval (rep (Reify Expr)))
420420 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
421− (\tag'' SSpec {nullity} (Reify (DB a)) ->
422− Reify $ DB $ runTag nullity (tag ==. litExpr tag'') a)
423− (HType (Reify (DB tag'))))
421+ (\tag'' SSpec {nullity} (Reify (E a)) ->
422+ Reify $ E $ runTag nullity (tag ==. litExpr tag'') a)
423+ (HType (Reify (E tag'))))
424424 (groupByExpr tag) .
425425 gftraverse @TUnreify @(Eval (rep (Reify Expr))) @_ @Aggregate (MaybeApply . Left)
426426 where
@@ -428,7 +428,7 @@ ggaggregate gfromColumns gtoColumns agg es = case algebraSing @algebra of
428428 gfindex @TUnreify @(Eval (rep (Reify Expr))) @(Aggregate a) .
429429 agg .
430430 gftabulate @(Compose Aggregate TUnreify) @(Eval (rep (Reify Expr))) @(Aggregate a)
431− (HType (Reify (DB tag)), exprs) =
431+ (HType (Reify (E tag)), exprs) =
432432 gunbuildADT
433433 @(TTable (Reify Expr))
434434 @TColumns
@@ -438,7 +438,7 @@ ggaggregate gfromColumns gtoColumns agg es = case algebraSing @algebra of
438438 (\(_ :: proxy x) -> unreify @_ @x Refl . fromColumns)
439439 (\SSpec {nullity} -> case nullity of
440440 Null -> id
441− NotNull -> \(Reify (DB a)) -> Reify (DB (unsafeUnnullify a))) $
441+ NotNull -> \(Reify (E a)) -> Reify (E (unsafeUnnullify a))) $
442442 hreify $
443443 gtoColumns es
444444
@@ -493,15 +493,15 @@ ggaggregate' gfromColumns gtoColumns agg es = case algebraSing @algebra of
493493 @(Col (Reify Aggregate))
494494 @(Eval (rep (Reify Aggregate)))
495495 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
496− (\tag' SSpec {nullity} (Reify (Aggregation a)) ->
497− Reify $ Aggregation $ runTag nullity (tag ==. litExpr tag') <$> a)
498− (HType (Reify (Aggregation (groupByExpr tag))))
496+ (\tag' SSpec {nullity} (Reify (A a)) ->
497+ Reify $ A $ runTag nullity (tag ==. litExpr tag') <$> a)
498+ (HType (Reify (A (groupByExpr tag))))
499499 where
500500 f =
501501 gfindex @TUnreify @(Eval (rep (Reify Expr))) @agg .
502502 agg .
503503 gftabulate @TUnreify @(Eval (rep (Reify Aggregate))) @agg
504− (HType (Reify (DB tag)), exprs) =
504+ (HType (Reify (E tag)), exprs) =
505505 gunbuildADT
506506 @(TTable (Reify Expr))
507507 @TColumns
@@ -511,7 +511,7 @@ ggaggregate' gfromColumns gtoColumns agg es = case algebraSing @algebra of
511511 (\(_ :: proxy x) -> unreify @_ @x Refl . fromColumns)
512512 (\SSpec {nullity} -> case nullity of
513513 Null -> id
514− NotNull -> \(Reify (DB a)) -> Reify (DB (unsafeUnnullify a))) $
514+ NotNull -> \(Reify (E a)) -> Reify (E (unsafeUnnullify a))) $
515515 hreify $
516516 gtoColumns es
517517