@@ -35,8 +35,8 @@ import GHC.TypeLits ( Symbol )
35import Prelude
35import Prelude
38−import Rel8.Aggregate ( Col( Aggregation ), Aggregate )
38+import Rel8.Aggregate ( Col( A ), Aggregate )
39−import Rel8.Expr ( Col( DB ), Expr )
39+import Rel8.Expr ( Col( E ), Expr )
40import Rel8.Expr.Aggregate ( groupByExpr )
40import Rel8.Expr.Aggregate ( groupByExpr )
41import Rel8.Expr.Eq ( (==.) )
41import Rel8.Expr.Eq ( (==.) )
42import Rel8.Expr.Null ( nullify, snull, unsafeUnnullify )
42import Rel8.Expr.Null ( nullify, snull, unsafeUnnullify )
@@ -64,9 +64,9 @@ import qualified Rel8.Kind.Algebra as K
64import Rel8.Schema.Context.Nullify ( runTag )
64import Rel8.Schema.Context.Nullify ( runTag )
65import Rel8.Schema.HTable ( HTable )
65import Rel8.Schema.HTable ( HTable )
66import Rel8.Schema.HTable.Identity ( HIdentity( HType ) )
66import Rel8.Schema.HTable.Identity ( HIdentity( HType ) )
67−import Rel8.Schema.Insert ( Col( InsertCol ), Insert, Insertion(..) )
67+import Rel8.Schema.Insert ( Col( I ), Insert, Insertion(..) )
68import qualified Rel8.Schema.Kind as K
68import qualified Rel8.Schema.Kind as K
69−import Rel8.Schema.Name ( Col( NameCol ), Name( Name ) )
69+import Rel8.Schema.Name ( Col( N ), Name( Name ) )
70import Rel8.Schema.Null ( Nullity( Null, NotNull ) )
70import Rel8.Schema.Null ( Nullity( Null, NotNull ) )
71import Rel8.Schema.Spec ( SSpec( SSpec, nullity, info ) )
71import Rel8.Schema.Spec ( SSpec( SSpec, nullity, info ) )
72import Rel8.Schema.Reify ( Col( Reify ), Reify, hreify, hunreify )
72import Rel8.Schema.Reify ( Col( Reify ), Reify, hreify, hunreify )
@@ -147,11 +147,11 @@ ggbuild gfromColumns = case algebraSing @algebra of
148 @(Eval (rep (Reify Expr)))
148 @(Eval (rep (Reify Expr)))
149 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
149 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
150− (\SSpec {info} -> Reify (DB (snull info)))
150+ (\SSpec {info} -> Reify (E (snull info)))
151 (\SSpec {nullity} -> case nullity of
151 (\SSpec {nullity} -> case nullity of
152 Null -> id
152 Null -> id
153− NotNull -> \(Reify (DB a)) -> Reify (DB (nullify a)))
153+ NotNull -> \(Reify (E a)) -> Reify (E (nullify a)))
154− (HType . Reify . DB . litExpr)
154+ (HType . Reify . E . litExpr)
157type GGInsert :: K.Algebra -> Symbol -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
157type GGInsert :: K.Algebra -> Symbol -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
@@ -189,13 +189,13 @@ gginsert gfromColumns = case algebraSing @algebra of
190 @(Eval (rep (Reify Insert)))
190 @(Eval (rep (Reify Insert)))
191 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
191 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
192− (\SSpec {info} -> Reify $ InsertCol (Insertion (snull info)))
192+ (\SSpec {info} -> Reify $ I (Insertion (snull info)))
193 (\SSpec {nullity} -> case nullity of
193 (\SSpec {nullity} -> case nullity of
194 Null -> id
194 Null -> id
195 NotNull -> \case
195 NotNull -> \case
196− Reify (InsertCol Default) -> Reify (InsertCol Default)
196+ Reify (I Default) -> Reify (I Default)
197− Reify (InsertCol (Insertion a)) -> Reify (InsertCol (Insertion (nullify a))))
197+ Reify (I (Insertion a)) -> Reify (I (Insertion (nullify a))))
198− (HType . Reify . InsertCol . Insertion . litExpr)
198+ (HType . Reify . I . Insertion . litExpr)
201type GGConstructable :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Constraint
201type GGConstructable :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Constraint
@@ -273,11 +273,11 @@ ggconstruct gfromColumns f = case algebraSing @algebra of
273 @(Col (Reify Expr))
273 @(Col (Reify Expr))
274 @(Eval (rep (Reify Expr)))
274 @(Eval (rep (Reify Expr)))
275 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
275 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
276− (\SSpec {info} -> Reify (DB (snull info)))
276+ (\SSpec {info} -> Reify (E (snull info)))
277 (\SSpec {nullity} -> case nullity of
277 (\SSpec {nullity} -> case nullity of
278 Null -> id
278 Null -> id
279− NotNull -> \(Reify (DB a)) -> Reify (DB (nullify a)))
279+ NotNull -> \(Reify (E a)) -> Reify (E (nullify a)))
280− (HType . Reify . DB . litExpr)
280+ (HType . Reify . E . litExpr)
283type GGDeconstruct :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type -> Type
283type GGDeconstruct :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type -> Type
@@ -306,7 +306,7 @@ ggdeconstruct gtoColumns = case algebraSing @algebra of
307 gctabulate @TUnreify @(Eval (rep (Reify Expr))) @r @(a -> r) $ \constructors as ->
307 gctabulate @TUnreify @(Eval (rep (Reify Expr))) @r @(a -> r) $ \constructors as ->
309− (HType (Reify (DB tag)), cases) =
309+ (HType (Reify (E tag)), cases) =
310 gdeconstructADT
310 gdeconstructADT
311 @(TTable (Reify Expr))
311 @(TTable (Reify Expr))
312 @TColumns
312 @TColumns
@@ -316,7 +316,7 @@ ggdeconstruct gtoColumns = case algebraSing @algebra of
316 (\(_ :: proxy x) -> unreify @_ @x Refl . fromColumns)
316 (\(_ :: proxy x) -> unreify @_ @x Refl . fromColumns)
317 (\SSpec {nullity} -> case nullity of
317 (\SSpec {nullity} -> case nullity of
318 Null -> id
318 Null -> id
319− NotNull -> \(Reify (DB a)) -> Reify (DB (unsafeUnnullify a)))
319+ NotNull -> \(Reify (E a)) -> Reify (E (unsafeUnnullify a)))
320 constructors $
320 constructors $
322 gtoColumns as
322 gtoColumns as
@@ -358,8 +358,8 @@ ggname gfromColumns = case algebraSing @algebra of
358 @(Col (Reify Name))
358 @(Col (Reify Name))
359 @(Eval (rep (Reify Name)))
359 @(Eval (rep (Reify Name)))
360 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
360 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
361− (\_ _ (Reify (NameCol a)) -> Reify (NameCol a))
361+ (\_ _ (Reify (N (Name a))) -> Reify (N (Name a)))
362− (HType ((\(Name a) -> Reify (NameCol a)) tag))
362+ (HType (Reify (N tag)))
365type GGAggregate :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
365type GGAggregate :: K.Algebra -> (K.Context -> Exp (Type -> Type)) -> Type -> Type
@@ -418,9 +418,9 @@ ggaggregate gfromColumns gtoColumns agg es = case algebraSing @algebra of
418 @(Col (Reify Expr))
418 @(Col (Reify Expr))
419 @(Eval (rep (Reify Expr)))
419 @(Eval (rep (Reify Expr)))
420 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
420 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
421− (\tag'' SSpec {nullity} (Reify (DB a)) ->
421+ (\tag'' SSpec {nullity} (Reify (E a)) ->
422− Reify $ DB $ runTag nullity (tag ==. litExpr tag'') a)
422+ Reify $ E $ runTag nullity (tag ==. litExpr tag'') a)
423− (HType (Reify (DB tag'))))
423+ (HType (Reify (E tag'))))
424 (groupByExpr tag) .
424 (groupByExpr tag) .
425 gftraverse @TUnreify @(Eval (rep (Reify Expr))) @_ @Aggregate (MaybeApply . Left)
425 gftraverse @TUnreify @(Eval (rep (Reify Expr))) @_ @Aggregate (MaybeApply . Left)
@@ -428,7 +428,7 @@ ggaggregate gfromColumns gtoColumns agg es = case algebraSing @algebra of
428 gfindex @TUnreify @(Eval (rep (Reify Expr))) @(Aggregate a) .
428 gfindex @TUnreify @(Eval (rep (Reify Expr))) @(Aggregate a) .
430 gftabulate @(Compose Aggregate TUnreify) @(Eval (rep (Reify Expr))) @(Aggregate a)
430 gftabulate @(Compose Aggregate TUnreify) @(Eval (rep (Reify Expr))) @(Aggregate a)
431− (HType (Reify (DB tag)), exprs) =
431+ (HType (Reify (E tag)), exprs) =
432 gunbuildADT
432 gunbuildADT
433 @(TTable (Reify Expr))
433 @(TTable (Reify Expr))
434 @TColumns
434 @TColumns
@@ -438,7 +438,7 @@ ggaggregate gfromColumns gtoColumns agg es = case algebraSing @algebra of
438 (\(_ :: proxy x) -> unreify @_ @x Refl . fromColumns)
438 (\(_ :: proxy x) -> unreify @_ @x Refl . fromColumns)
439 (\SSpec {nullity} -> case nullity of
439 (\SSpec {nullity} -> case nullity of
440 Null -> id
440 Null -> id
441− NotNull -> \(Reify (DB a)) -> Reify (DB (unsafeUnnullify a))) $
441+ NotNull -> \(Reify (E a)) -> Reify (E (unsafeUnnullify a))) $
443 gtoColumns es
443 gtoColumns es
@@ -493,15 +493,15 @@ ggaggregate' gfromColumns gtoColumns agg es = case algebraSing @algebra of
493 @(Col (Reify Aggregate))
493 @(Col (Reify Aggregate))
494 @(Eval (rep (Reify Aggregate)))
494 @(Eval (rep (Reify Aggregate)))
495 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
495 (\(_ :: proxy x) -> toColumns . reify @_ @x Refl)
496− (\tag' SSpec {nullity} (Reify (Aggregation a)) ->
496+ (\tag' SSpec {nullity} (Reify (A a)) ->
497− Reify $ Aggregation $ runTag nullity (tag ==. litExpr tag') <$> a)
497+ Reify $ A $ runTag nullity (tag ==. litExpr tag') <$> a)
498− (HType (Reify (Aggregation (groupByExpr tag))))
498+ (HType (Reify (A (groupByExpr tag))))
501 gfindex @TUnreify @(Eval (rep (Reify Expr))) @agg .
501 gfindex @TUnreify @(Eval (rep (Reify Expr))) @agg .
503 gftabulate @TUnreify @(Eval (rep (Reify Aggregate))) @agg
503 gftabulate @TUnreify @(Eval (rep (Reify Aggregate))) @agg
504− (HType (Reify (DB tag)), exprs) =
504+ (HType (Reify (E tag)), exprs) =
505 gunbuildADT
505 gunbuildADT
506 @(TTable (Reify Expr))
506 @(TTable (Reify Expr))
507 @TColumns
507 @TColumns
@@ -511,7 +511,7 @@ ggaggregate' gfromColumns gtoColumns agg es = case algebraSing @algebra of
511 (\(_ :: proxy x) -> unreify @_ @x Refl . fromColumns)
511 (\(_ :: proxy x) -> unreify @_ @x Refl . fromColumns)
512 (\SSpec {nullity} -> case nullity of
512 (\SSpec {nullity} -> case nullity of
513 Null -> id
513 Null -> id
514− NotNull -> \(Reify (DB a)) -> Reify (DB (unsafeUnnullify a))) $
514+ NotNull -> \(Reify (E a)) -> Reify (E (unsafeUnnullify a))) $
516 gtoColumns es
516 gtoColumns es