on master help sign in
Add better generic deriving for EqTable, OrdTable and ToExprs
fb21075Shane O'Brien
rel8.cabal+1−4
@@ -106,11 +106,8 @@ library
106 Rel8.Schema.HTable.Maybe
106 Rel8.Schema.HTable.Maybe
107 Rel8.Schema.HTable.NonEmpty
107 Rel8.Schema.HTable.NonEmpty
108 Rel8.Schema.HTable.Nullify
108 Rel8.Schema.HTable.Nullify
109− Rel8.Schema.HTable.Pair
109+ Rel8.Schema.HTable.Product
110− Rel8.Schema.HTable.Quartet
111− Rel8.Schema.HTable.Quintet
112 Rel8.Schema.HTable.These
110 Rel8.Schema.HTable.These
113− Rel8.Schema.HTable.Trio
114 Rel8.Schema.HTable.Type
111 Rel8.Schema.HTable.Type
115 Rel8.Schema.HTable.Vectorize
112 Rel8.Schema.HTable.Vectorize
116 Rel8.Schema.Insert
113 Rel8.Schema.Insert
src/Rel8/Generic/Record.hs+5−1
@@ -18,7 +18,11 @@ where
18-- base
18-- base
19import Data.Kind ( Constraint, Type )
19import Data.Kind ( Constraint, Type )
20import GHC.Generics
20import GHC.Generics
21+ ( Generic, Rep, from, to
22+ , (:+:)( L1, R1 ), (:*:)( (:*:) ), M1( M1 )
23+ , Meta( MetaCons, MetaSel ), D, C, S
24+ )
21−import GHC.TypeLits
25+import GHC.TypeLits ( type (+), AppendSymbol, Div, Mod, Nat, Symbol )
22import Prelude hiding ( Show )
26import Prelude hiding ( Show )
23
27
24
28
src/Rel8/Schema/HKD.hs+4−4
@@ -50,7 +50,7 @@ import Rel8.Schema.Dict ( Dict( Dict ) )
50import Rel8.Schema.Field ( Reify, Reifiable(..), SContext(..), hunreify, hreify )
50import Rel8.Schema.Field ( Reify, Reifiable(..), SContext(..), hunreify, hreify )
51import Rel8.Schema.HTable ( HTable )
51import Rel8.Schema.HTable ( HTable )
52import Rel8.Schema.HTable.Label ( HLabel, hlabel, hunlabel )
52import Rel8.Schema.HTable.Label ( HLabel, hlabel, hunlabel )
53−import Rel8.Schema.HTable.Pair ( HPair( HPair ) )
53+import Rel8.Schema.HTable.Product ( HProduct( HProduct ) )
54import Rel8.Schema.HTable.Type ( HType( HType ) )
54import Rel8.Schema.HTable.Type ( HType( HType ) )
55import Rel8.Schema.Insert ( Insert, Col(..) )
55import Rel8.Schema.Insert ( Insert, Col(..) )
56import qualified Rel8.Schema.Kind as K
56import qualified Rel8.Schema.Kind as K
@@ -159,10 +159,10 @@ instance (KnownSymbol name, Sql DBType a) =>
159
159
160
160
161instance (GTable f, GTable g) => GTable (f :*: g) where
161instance (GTable f, GTable g) => GTable (f :*: g) where
162− toGColumns f (x :*: y) = HPair (toGColumns f x) (toGColumns f y)
162+ toGColumns f (x :*: y) = HProduct (toGColumns f x) (toGColumns f y)
163 {-# INLINABLE toGColumns #-}
163 {-# INLINABLE toGColumns #-}
164
164
165− fromGColumns f (HPair x y) = fromGColumns f x :*: fromGColumns f y
165+ fromGColumns f (HProduct x y) = fromGColumns f x :*: fromGColumns f y
166 {-# INLINABLE fromGColumns #-}
166 {-# INLINABLE fromGColumns #-}
167
167
168
168
@@ -175,7 +175,7 @@ type family GColumns rep where
175 GColumns (M1 C _ f) = GColumns f
175 GColumns (M1 C _ f) = GColumns f
176 GColumns (M1 S ('MetaSel ('Just name) _ _ _) (K1 _ a)) =
176 GColumns (M1 S ('MetaSel ('Just name) _ _ _) (K1 _ a)) =
177 HLabel name (HType a)
177 HLabel name (HType a)
178− GColumns (f :*: g) = HPair (GColumns f) (GColumns g)
178+ GColumns (f :*: g) = HProduct (GColumns f) (GColumns g)
179
179
180
180
181instance (GTable (Rep a), Column1 context f, Labelable context) =>
181instance (GTable (Rep a), Column1 context f, Labelable context) =>
src/Rel8/Schema/HTable.hs+15−15
@@ -35,7 +35,7 @@ import Prelude
35-- rel8
35-- rel8
36import Rel8.Schema.Dict ( Dict )
36import Rel8.Schema.Dict ( Dict )
37import Rel8.Schema.Spec ( Spec, SSpec )
37import Rel8.Schema.Spec ( Spec, SSpec )
38−import Rel8.Schema.HTable.Pair ( HPair( HPair ) )
38+import Rel8.Schema.HTable.Product ( HProduct( HProduct ) )
39import qualified Rel8.Schema.Kind as K
39import qualified Rel8.Schema.Kind as K
40
40
41-- semigroupoids
41-- semigroupoids
@@ -144,30 +144,30 @@ instance HTable table => GHTable context (K1 i (table context)) where
144
144
145
145
146instance (GHTable context a, GHTable context b) => GHTable context (a :*: b) where
146instance (GHTable context a, GHTable context b) => GHTable context (a :*: b) where
147− type GHColumns (a :*: b) = HPair (GHColumns a) (GHColumns b)
147+ type GHColumns (a :*: b) = HProduct (GHColumns a) (GHColumns b)
148− toGHColumns (a :*: b) = HPair (toGHColumns a) (toGHColumns b)
148+ toGHColumns (a :*: b) = HProduct (toGHColumns a) (toGHColumns b)
149− fromGHColumns (HPair a b) = fromGHColumns a :*: fromGHColumns b
149+ fromGHColumns (HProduct a b) = fromGHColumns a :*: fromGHColumns b
150
150
151
151
152−-- | A HField type for indexing into HPair.
152+-- | A HField type for indexing into HProduct.
153−type HPairField :: K.HTable -> K.HTable -> Spec -> Type
153+type HProductField :: K.HTable -> K.HTable -> Spec -> Type
154−data HPairField x y spec
154+data HProductField x y spec
155 = HFst (HField x spec)
155 = HFst (HField x spec)
156 | HSnd (HField y spec)
156 | HSnd (HField y spec)
157
157
158
158
159−instance (HTable x, HTable y) => HTable (HPair x y) where
159+instance (HTable x, HTable y) => HTable (HProduct x y) where
160− type HConstrainTable (HPair x y) c = (HConstrainTable x c, HConstrainTable y c)
160+ type HConstrainTable (HProduct x y) c = (HConstrainTable x c, HConstrainTable y c)
161− type HField (HPair x y) = HPairField x y
161+ type HField (HProduct x y) = HProductField x y
162
162
163− hfield (HPair l r) = \case
163+ hfield (HProduct l r) = \case
164 HFst i -> hfield l i
164 HFst i -> hfield l i
165 HSnd i -> hfield r i
165 HSnd i -> hfield r i
166
166
167− htabulate f = HPair (htabulate (f . HFst)) (htabulate (f . HSnd))
167+ htabulate f = HProduct (htabulate (f . HFst)) (htabulate (f . HSnd))
168− htraverse f (HPair x y) = HPair <$> htraverse f x <.> htraverse f y
168+ htraverse f (HProduct x y) = HProduct <$> htraverse f x <.> htraverse f y
169− hdicts = HPair hdicts hdicts
169+ hdicts = HProduct hdicts hdicts
170− hspecs = HPair hspecs hspecs
170+ hspecs = HProduct hspecs hspecs
171
171
172 {-# INLINABLE hfield #-}
172 {-# INLINABLE hfield #-}
173 {-# INLINABLE htabulate #-}
173 {-# INLINABLE htabulate #-}
src/Rel8/Schema/HTable/Pair.hsdeleted−20
@@ -1,20 +0,0 @@
1−{-# language DataKinds #-}
2−{-# language StandaloneKindSignatures #-}
3−
4−module Rel8.Schema.HTable.Pair
5− ( HPair(..)
6− )
7−where
8−
9−-- base
10−import Prelude ()
11−
12−-- rel8
13−import qualified Rel8.Schema.Kind as K
14−
15−
16−type HPair :: K.HTable -> K.HTable -> K.HTable
17−data HPair fst snd context = HPair
18− { hfst :: fst context
19− , hsnd :: snd context
20− }
src/Rel8/Schema/HTable/Product.hsnew file+17
@@ -0,0 +1,17 @@
1+{-# language DataKinds #-}
2+{-# language StandaloneKindSignatures #-}
3+
4+module Rel8.Schema.HTable.Product
5+ ( HProduct(..)
6+ )
7+where
8+
9+-- base
10+import Prelude ()
11+
12+-- rel8
13+import qualified Rel8.Schema.Kind as K
14+
15+
16+type HProduct :: K.HTable -> K.HTable -> K.HTable
17+data HProduct a b context = HProduct (a context) (b context)
src/Rel8/Schema/HTable/Quartet.hsdeleted−29
@@ -1,29 +0,0 @@
1−{-# language DataKinds #-}
2−{-# language DeriveAnyClass #-}
3−{-# language DeriveGeneric #-}
4−{-# language DerivingStrategies #-}
5−{-# language StandaloneKindSignatures #-}
6−
7−module Rel8.Schema.HTable.Quartet
8− ( HQuartet(..)
9− )
10−where
11−
12−-- base
13−import GHC.Generics ( Generic )
14−import Prelude ()
15−
16−-- rel8
17−import Rel8.Schema.HTable ( HTable )
18−import qualified Rel8.Schema.Kind as K
19−
20−
21−type HQuartet :: K.HTable -> K.HTable -> K.HTable -> K.HTable -> K.HTable
22−data HQuartet w x y z context = HQuartet
23− { hfst :: w context
24− , hsnd :: x context
25− , htrd :: y context
26− , hfrt :: z context
27− }
28− deriving stock Generic
29− deriving anyclass HTable
src/Rel8/Schema/HTable/Quintet.hsdeleted−30
@@ -1,30 +0,0 @@
1−{-# language DataKinds #-}
2−{-# language DeriveAnyClass #-}
3−{-# language DeriveGeneric #-}
4−{-# language DerivingStrategies #-}
5−{-# language StandaloneKindSignatures #-}
6−
7−module Rel8.Schema.HTable.Quintet
8− ( HQuintet(..)
9− )
10−where
11−
12−-- base
13−import GHC.Generics ( Generic )
14−import Prelude ()
15−
16−-- rel8
17−import Rel8.Schema.HTable ( HTable )
18−import qualified Rel8.Schema.Kind as K
19−
20−
21−type HQuintet :: K.HTable -> K.HTable -> K.HTable -> K.HTable -> K.HTable -> K.HTable
22−data HQuintet v w x y z context = HQuintet
23− { hfst :: v context
24− , hsnd :: w context
25− , htrd :: x context
26− , hfrt :: y context
27− , hfft :: z context
28− }
29− deriving stock Generic
30− deriving anyclass HTable
src/Rel8/Schema/HTable/Trio.hsdeleted−28
@@ -1,28 +0,0 @@
1−{-# language DataKinds #-}
2−{-# language DeriveAnyClass #-}
3−{-# language DeriveGeneric #-}
4−{-# language DerivingStrategies #-}
5−{-# language StandaloneKindSignatures #-}
6−
7−module Rel8.Schema.HTable.Trio
8− ( HTrio(..)
9− )
10−where
11−
12−-- base
13−import GHC.Generics ( Generic )
14−import Prelude ()
15−
16−-- rel8
17−import Rel8.Schema.HTable ( HTable )
18−import qualified Rel8.Schema.Kind as K
19−
20−
21−type HTrio :: K.HTable -> K.HTable -> K.HTable -> K.HTable
22−data HTrio x y z context = HTrio
23− { hfst :: x context
24− , hsnd :: y context
25− , htrd :: z context
26− }
27− deriving stock Generic
28− deriving anyclass HTable
src/Rel8/Table.hs+14−94
@@ -47,11 +47,8 @@ import Rel8.Schema.HTable.List ( HListTable )
47import Rel8.Schema.HTable.Maybe ( HMaybeTable(..) )
47import Rel8.Schema.HTable.Maybe ( HMaybeTable(..) )
48import Rel8.Schema.HTable.NonEmpty ( HNonEmptyTable )
48import Rel8.Schema.HTable.NonEmpty ( HNonEmptyTable )
49import Rel8.Schema.HTable.Nullify ( hnulls, hnullify, hunnullify )
49import Rel8.Schema.HTable.Nullify ( hnulls, hnullify, hunnullify )
50−import Rel8.Schema.HTable.Pair ( HPair(..) )
50+import Rel8.Schema.HTable.Product ( HProduct(..) )
51−import Rel8.Schema.HTable.Quartet ( HQuartet(..) )
52−import Rel8.Schema.HTable.Quintet ( HQuintet(..) )
53import Rel8.Schema.HTable.These ( HTheseTable(..) )
51import Rel8.Schema.HTable.These ( HTheseTable(..) )
54−import Rel8.Schema.HTable.Trio ( HTrio(..) )
55import Rel8.Schema.HTable.Type ( HType( HType ) )
52import Rel8.Schema.HTable.Type ( HType( HType ) )
56import Rel8.Schema.HTable.Vectorize ( hvectorize, hunvectorize )
53import Rel8.Schema.HTable.Vectorize ( hvectorize, hunvectorize )
57import qualified Rel8.Schema.Kind as K
54import qualified Rel8.Schema.Kind as K
@@ -112,7 +109,7 @@ type GColumns :: (Type -> Type) -> K.HTable
112type family GColumns rep where
109type family GColumns rep where
113 GColumns (M1 D _ rep) = GColumns rep
110 GColumns (M1 D _ rep) = GColumns rep
114 GColumns (M1 C _ rep) = GColumns rep
111 GColumns (M1 C _ rep) = GColumns rep
115− GColumns (rep1 :*: rep2) = HPair (GColumns rep1) (GColumns rep2)
112+ GColumns (rep1 :*: rep2) = HProduct (GColumns rep1) (GColumns rep2)
116 GColumns (M1 S ('MetaSel ('Just label) _ _ _) (K1 _ a)) =
113 GColumns (M1 S ('MetaSel ('Just label) _ _ _) (K1 _ a)) =
117 HLabel label (Columns a)
114 HLabel label (Columns a)
118
115
@@ -143,10 +140,10 @@ instance GTable context rep => GTable context (M1 C c rep) where
143instance (GTable context rep1, GTable context rep2) =>
140instance (GTable context rep1, GTable context rep2) =>
144 GTable context (rep1 :*: rep2)
141 GTable context (rep1 :*: rep2)
145 where
142 where
146− fromGColumns (HPair a b) =
143+ fromGColumns (HProduct a b) =
147 fromGColumns @context @rep1 a :*: fromGColumns @context @rep2 b
144 fromGColumns @context @rep1 a :*: fromGColumns @context @rep2 b
148 toGColumns (a :*: b) =
145 toGColumns (a :*: b) =
149− HPair (toGColumns @context @rep1 a) (toGColumns @context @rep2 b)
146+ HProduct (toGColumns @context @rep1 a) (toGColumns @context @rep2 b)
150
147
151
148
152instance
149instance
@@ -156,7 +153,8 @@ instance
156 , GColumns (M1 S meta k1) ~ HLabel label (Columns a)
153 , GColumns (M1 S meta k1) ~ HLabel label (Columns a)
157 , meta ~ 'MetaSel ('Just label) _su _ss _ds
154 , meta ~ 'MetaSel ('Just label) _su _ss _ds
158 , k1 ~ K1 i a
155 , k1 ~ K1 i a
156+ )
159− ) => GTable context (M1 S meta k1)
157+ => GTable context (M1 S meta k1)
160 where
158 where
161 fromGColumns = M1 . K1 . fromColumns . hunlabel unlabeler
159 fromGColumns = M1 . K1 . fromColumns . hunlabel unlabeler
162 toGColumns (M1 (K1 a)) = hlabel labeler (toColumns a)
160 toGColumns (M1 (K1 a)) = hlabel labeler (toColumns a)
@@ -286,108 +284,30 @@ instance (Table Result a, Table Result b) => Table Result (These a b) where
286 }
284 }
287
285
288
286
289−instance
290− ( Table context a, Table context b
287+instance (Table context a, Table context b, Labelable context)
291− , Labelable context
292− ) =>
293− Table context (a, b)
288+ => Table context (a, b)
294− where
295− type Columns (a, b) =
296− HPair
297− (HLabel "fst" (Columns a))
298− (HLabel "snd" (Columns b))
299− type Context (a, b) = Context a
300−
301− toColumns (a, b) = HPair
302− { hfst = hlabel labeler $ toColumns a
303− , hsnd = hlabel labeler $ toColumns b
304− }
305− fromColumns (HPair a b) =
306− ( fromColumns $ hunlabel unlabeler a
307− , fromColumns $ hunlabel unlabeler b
308− )
309
289
310
290
311instance
291instance
312 ( Table context a, Table context b, Table context c
292 ( Table context a, Table context b, Table context c
313 , Labelable context
293 , Labelable context
294+ )
314− ) => Table context (a, b, c)
295+ => Table context (a, b, c)
315− where
316− type Columns (a, b, c) =
317− HTrio
318− (HLabel "fst" (Columns a))
319− (HLabel "snd" (Columns b))
320− (HLabel "trd" (Columns c))
321− type Context (a, b, c) = Context a
322−
323− toColumns (a, b, c) = HTrio
324− { hfst = hlabel labeler $ toColumns a
325− , hsnd = hlabel labeler $ toColumns b
326− , htrd = hlabel labeler $ toColumns c
327− }
328− fromColumns (HTrio a b c) =
329− ( fromColumns $ hunlabel unlabeler a
330− , fromColumns $ hunlabel unlabeler b
331− , fromColumns $ hunlabel unlabeler c
332− )
333
296
334
297
335instance
298instance
336 ( Table context a, Table context b, Table context c, Table context d
299 ( Table context a, Table context b, Table context c, Table context d
337 , Labelable context
300 , Labelable context
301+ )
338− ) => Table context (a, b, c, d)
302+ => Table context (a, b, c, d)
339− where
340− type Columns (a, b, c, d) =
341− HQuartet
342− (HLabel "fst" (Columns a))
343− (HLabel "snd" (Columns b))
344− (HLabel "trd" (Columns c))
345− (HLabel "frt" (Columns d))
346− type Context (a, b, c, d) = Context a
347−
348− toColumns (a, b, c, d) = HQuartet
349− { hfst = hlabel labeler $ toColumns a
350− , hsnd = hlabel labeler $ toColumns b
351− , htrd = hlabel labeler $ toColumns c
352− , hfrt = hlabel labeler $ toColumns d
353− }
354− fromColumns (HQuartet a b c d) =
355− ( fromColumns $ hunlabel unlabeler a
356− , fromColumns $ hunlabel unlabeler b
357− , fromColumns $ hunlabel unlabeler c
358− , fromColumns $ hunlabel unlabeler d
359− )
360
303
361
304
362instance
305instance
363 ( Table context a, Table context b, Table context c, Table context d
306 ( Table context a, Table context b, Table context c, Table context d
364 , Table context e
307 , Table context e
365 , Labelable context
308 , Labelable context
309+ )
366− ) => Table context (a, b, c, d, e)
310+ => Table context (a, b, c, d, e)
367− where
368− type Columns (a, b, c, d, e) =
369− HQuintet
370− (HLabel "fst" (Columns a))
371− (HLabel "snd" (Columns b))
372− (HLabel "trd" (Columns c))
373− (HLabel "frt" (Columns d))
374− (HLabel "fft" (Columns e))
375− type Context (a, b, c, d, e) = Context a
376−
377− toColumns (a, b, c, d, e) = HQuintet
378− { hfst = hlabel labeler $ toColumns a
379− , hsnd = hlabel labeler $ toColumns b
380− , htrd = hlabel labeler $ toColumns c
381− , hfrt = hlabel labeler $ toColumns d
382− , hfft = hlabel labeler $ toColumns e
383− }
384− fromColumns (HQuintet a b c d e) =
385− ( fromColumns $ hunlabel unlabeler a
386− , fromColumns $ hunlabel unlabeler b
387− , fromColumns $ hunlabel unlabeler c
388− , fromColumns $ hunlabel unlabeler d
389− , fromColumns $ hunlabel unlabeler e
390− )
391
311
392
312
393type Congruent :: Type -> Type -> Constraint
313type Congruent :: Type -> Type -> Constraint
src/Rel8/Table/Eq.hs+49−40
@@ -9,6 +9,7 @@
9{-# language StandaloneKindSignatures #-}
9{-# language StandaloneKindSignatures #-}
10{-# language TypeApplications #-}
10{-# language TypeApplications #-}
11{-# language TypeFamilies #-}
11{-# language TypeFamilies #-}
12+{-# language TypeOperators #-}
12{-# language UndecidableInstances #-}
13{-# language UndecidableInstances #-}
13{-# language UndecidableSuperClasses #-}
14{-# language UndecidableSuperClasses #-}
14{-# language ViewPatterns #-}
15{-# language ViewPatterns #-}
@@ -23,27 +24,28 @@ import Data.Foldable ( foldl' )
23import Data.Functor.Const ( Const( Const ), getConst )
24import Data.Functor.Const ( Const( Const ), getConst )
24import Data.Kind ( Constraint, Type )
25import Data.Kind ( Constraint, Type )
25import Data.List.NonEmpty ( NonEmpty( (:|) ) )
26import Data.List.NonEmpty ( NonEmpty( (:|) ) )
27+import GHC.Generics ( Rep, (:*:), K1, M1, Meta( MetaSel ), D, C, S )
28+import GHC.TypeLits ( KnownSymbol )
26import Prelude
29import Prelude
27
30
28-- rel8
31-- rel8
29import Rel8.Expr ( Expr, Col(..) )
32import Rel8.Expr ( Expr, Col(..) )
30import Rel8.Expr.Bool ( (||.), (&&.) )
33import Rel8.Expr.Bool ( (||.), (&&.) )
31import Rel8.Expr.Eq ( (==.), (/=.) )
34import Rel8.Expr.Eq ( (==.), (/=.) )
35+import Rel8.Generic.Record ( Record )
32import Rel8.Schema.Context.Label ( hlabeler )
36import Rel8.Schema.Context.Label ( hlabeler )
33import Rel8.Schema.Dict ( Dict( Dict ) )
37import Rel8.Schema.Dict ( Dict( Dict ) )
34import Rel8.Schema.HTable
38import Rel8.Schema.HTable
35 ( HTable, HConstrainTable
39 ( HTable, HConstrainTable
36 , htabulateA, hfield, hdicts
40 , htabulateA, hfield, hdicts
37 )
41 )
38−import Rel8.Schema.HTable.Label ( hlabel )
42+import Rel8.Schema.HTable.Label ( HLabel, hlabel )
39−import Rel8.Schema.HTable.Pair ( HPair(..) )
43+import Rel8.Schema.HTable.Product ( HProduct(..) )
40−import Rel8.Schema.HTable.Quartet ( HQuartet(..) )
44+import Rel8.Schema.HTable.Type ( HType(..) )
41−import Rel8.Schema.HTable.Quintet ( HQuintet(..) )
42−import Rel8.Schema.HTable.Trio ( HTrio(..) )
43import Rel8.Schema.Kind ( Context )
45import Rel8.Schema.Kind ( Context )
44import Rel8.Schema.Null ( Sql )
46import Rel8.Schema.Null ( Sql )
45import Rel8.Schema.Spec.ConstrainDBType ( ConstrainDBType )
47import Rel8.Schema.Spec.ConstrainDBType ( ConstrainDBType )
46−import Rel8.Table ( Table, Columns, toColumns )
48+import Rel8.Table ( Table, Columns, toColumns, GColumns )
47import Rel8.Type.Eq ( DBEq )
49import Rel8.Type.Eq ( DBEq )
48
50
49
51
@@ -54,10 +56,40 @@ type EqTable :: Type -> Constraint
54class Table Expr a => EqTable a where
56class Table Expr a => EqTable a where
55 eqTable :: Columns a (Dict (ConstrainDBType DBEq))
57 eqTable :: Columns a (Dict (ConstrainDBType DBEq))
56
58
57− default eqTable :: ()
59+ default eqTable ::
58− => HConstrainTable (Columns a) (ConstrainDBType DBEq)
60+ ( GColumns (Rep (Record a)) ~ Columns a
61+ , GEqTable (Rep (Record a))
62+ )
59 => Columns a (Dict (ConstrainDBType DBEq))
63 => Columns a (Dict (ConstrainDBType DBEq))
64+ eqTable = geqTable @(Rep (Record a))
65+
66+
67+type GEqTable :: (Type -> Type) -> Constraint
68+class GEqTable rep where
60− eqTable = hdicts @(Columns a) @(ConstrainDBType DBEq)
69+ geqTable :: GColumns rep (Dict (ConstrainDBType DBEq))
70+
71+
72+instance GEqTable rep => GEqTable (M1 D c rep) where
73+ geqTable = geqTable @rep
74+
75+
76+instance GEqTable rep => GEqTable (M1 C c rep) where
77+ geqTable = geqTable @rep
78+
79+
80+instance (GEqTable rep1, GEqTable rep2) => GEqTable (rep1 :*: rep2) where
81+ geqTable = HProduct (geqTable @rep1) (geqTable @rep2)
82+
83+
84+instance
85+ ( EqTable a
86+ , KnownSymbol label
87+ , GColumns (M1 S meta k1) ~ HLabel label (Columns a)
88+ , meta ~ 'MetaSel ('Just label) _su _ss _ds
89+ , k1 ~ K1 i a
90+ ) => GEqTable (M1 S meta k1)
91+ where
92+ geqTable = hlabel hlabeler (eqTable @a)
61
93
62
94
63instance
95instance
@@ -66,6 +98,8 @@ instance
66 , HConstrainTable (Columns (t Expr)) (ConstrainDBType DBEq)
98 , HConstrainTable (Columns (t Expr)) (ConstrainDBType DBEq)
67 )
99 )
68 => EqTable (t f)
100 => EqTable (t f)
101+ where
102+ eqTable = hdicts @(Columns (t f)) @(ConstrainDBType DBEq)
69
103
70
104
71instance
105instance
@@ -74,50 +108,25 @@ instance
74 , HConstrainTable t (ConstrainDBType DBEq)
108 , HConstrainTable t (ConstrainDBType DBEq)
75 )
109 )
76 => EqTable (t f)
110 => EqTable (t f)
111+ where
112+ eqTable = hdicts @(Columns (t f)) @(ConstrainDBType DBEq)
77
113
78
114
79−instance Sql DBEq a => EqTable (Expr a)
115+instance Sql DBEq a => EqTable (Expr a) where
116+ eqTable = HType Dict
80
117
81
118
82−instance (EqTable a, EqTable b) => EqTable (a, b) where
119+instance (EqTable a, EqTable b) => EqTable (a, b)
83− eqTable =
84− HPair
85− { hfst = hlabel hlabeler (eqTable @a)
86− , hsnd = hlabel hlabeler (eqTable @b)
87− }
88
120
89
121
90−instance (EqTable a, EqTable b, EqTable c) => EqTable (a, b, c) where
122+instance (EqTable a, EqTable b, EqTable c) => EqTable (a, b, c)
91− eqTable =
92− HTrio
93− { hfst = hlabel hlabeler (eqTable @a)
94− , hsnd = hlabel hlabeler (eqTable @b)
95− , htrd = hlabel hlabeler (eqTable @c)
96− }
97
123
98
124
99instance (EqTable a, EqTable b, EqTable c, EqTable d) => EqTable (a, b, c, d)
125instance (EqTable a, EqTable b, EqTable c, EqTable d) => EqTable (a, b, c, d)
100− where
101− eqTable =
102− HQuartet
103− { hfst = hlabel hlabeler (eqTable @a)
104− , hsnd = hlabel hlabeler (eqTable @b)
105− , htrd = hlabel hlabeler (eqTable @c)
106− , hfrt = hlabel hlabeler (eqTable @d)
107− }
108
126
109
127
110instance (EqTable a, EqTable b, EqTable c, EqTable d, EqTable e) =>
128instance (EqTable a, EqTable b, EqTable c, EqTable d, EqTable e) =>
111 EqTable (a, b, c, d, e)
129 EqTable (a, b, c, d, e)
112− where
113− eqTable =
114− HQuintet
115− { hfst = hlabel hlabeler (eqTable @a)
116− , hsnd = hlabel hlabeler (eqTable @b)
117− , htrd = hlabel hlabeler (eqTable @c)
118− , hfrt = hlabel hlabeler (eqTable @d)
119− , hfft = hlabel hlabeler (eqTable @e)
120− }
121
130
122
131
123-- | Compare two 'Table's for equality. This corresponds to comparing all
132-- | Compare two 'Table's for equality. This corresponds to comparing all
src/Rel8/Table/Ord.hs+52−39
@@ -2,11 +2,13 @@
2{-# language DataKinds #-}
2{-# language DataKinds #-}
3{-# language DefaultSignatures #-}
3{-# language DefaultSignatures #-}
4{-# language DisambiguateRecordFields #-}
4{-# language DisambiguateRecordFields #-}
5+{-# language FlexibleContexts #-}
5{-# language FlexibleInstances #-}
6{-# language FlexibleInstances #-}
6{-# language ScopedTypeVariables #-}
7{-# language ScopedTypeVariables #-}
7{-# language StandaloneKindSignatures #-}
8{-# language StandaloneKindSignatures #-}
8{-# language TypeApplications #-}
9{-# language TypeApplications #-}
9{-# language TypeFamilies #-}
10{-# language TypeFamilies #-}
11+{-# language TypeOperators #-}
10{-# language UndecidableInstances #-}
12{-# language UndecidableInstances #-}
11{-# language UndecidableSuperClasses #-}
13{-# language UndecidableSuperClasses #-}
12{-# language ViewPatterns #-}
14{-# language ViewPatterns #-}
@@ -19,6 +21,8 @@ where
19-- base
21-- base
20import Data.Functor.Const ( Const( Const ), getConst )
22import Data.Functor.Const ( Const( Const ), getConst )
21import Data.Kind ( Constraint, Type )
23import Data.Kind ( Constraint, Type )
24+import GHC.Generics ( Rep, (:*:), K1, M1, Meta( MetaSel ), D, C, S )
25+import GHC.TypeLits ( KnownSymbol )
22import Prelude hiding ( seq )
26import Prelude hiding ( seq )
23
27
24-- rel8
28-- rel8
@@ -26,21 +30,20 @@ import Rel8.Expr ( Expr, Col(..) )
26import Rel8.Expr.Bool ( (||.), (&&.), false, true )
30import Rel8.Expr.Bool ( (||.), (&&.), false, true )
27import Rel8.Expr.Eq ( (==.) )
31import Rel8.Expr.Eq ( (==.) )
28import Rel8.Expr.Ord ( (<.), (>.) )
32import Rel8.Expr.Ord ( (<.), (>.) )
33+import Rel8.Generic.Record ( Record )
29import Rel8.Schema.Context.Label ( hlabeler )
34import Rel8.Schema.Context.Label ( hlabeler )
30import Rel8.Schema.Dict ( Dict( Dict ) )
35import Rel8.Schema.Dict ( Dict( Dict ) )
31import Rel8.Schema.HTable
36import Rel8.Schema.HTable
32 ( HTable, HConstrainTable
37 ( HTable, HConstrainTable
33 , htabulateA, hfield, hdicts
38 , htabulateA, hfield, hdicts
34 )
39 )
35−import Rel8.Schema.HTable.Label ( hlabel )
40+import Rel8.Schema.HTable.Label ( HLabel, hlabel )
36−import Rel8.Schema.HTable.Pair ( HPair(..) )
41+import Rel8.Schema.HTable.Product ( HProduct(..) )
37−import Rel8.Schema.HTable.Quartet ( HQuartet(..) )
42+import Rel8.Schema.HTable.Type ( HType(..) )
38−import Rel8.Schema.HTable.Quintet ( HQuintet(..) )
39−import Rel8.Schema.HTable.Trio ( HTrio(..) )
40import Rel8.Schema.Kind ( Context )
43import Rel8.Schema.Kind ( Context )
41import Rel8.Schema.Null (Sql)
44import Rel8.Schema.Null (Sql)
42import Rel8.Schema.Spec.ConstrainDBType ( ConstrainDBType )
45import Rel8.Schema.Spec.ConstrainDBType ( ConstrainDBType )
43−import Rel8.Table ( Table, Columns, toColumns )
46+import Rel8.Table ( Table, Columns, toColumns, GColumns )
44import Rel8.Table.Bool ( bool )
47import Rel8.Table.Bool ( bool )
45import Rel8.Table.Eq ( EqTable )
48import Rel8.Table.Eq ( EqTable )
46import Rel8.Type.Eq ( DBEq )
49import Rel8.Type.Eq ( DBEq )
@@ -54,8 +57,41 @@ type OrdTable :: Type -> Constraint
54class EqTable a => OrdTable a where
57class EqTable a => OrdTable a where
55 ordTable :: Columns a (Dict (ConstrainDBType DBOrd))
58 ordTable :: Columns a (Dict (ConstrainDBType DBOrd))
56
59
57− default ordTable :: HConstrainTable (Columns a) (ConstrainDBType DBOrd) => Columns a (Dict (ConstrainDBType DBOrd))
60+ default ordTable ::
58− ordTable = hdicts @(Columns a) @(ConstrainDBType DBOrd)
61+ ( GColumns (Rep (Record a)) ~ Columns a
62+ , GOrdTable (Rep (Record a))
63+ )
64+ => Columns a (Dict (ConstrainDBType DBOrd))
65+ ordTable = gordTable @(Rep (Record a))
66+
67+
68+type GOrdTable :: (Type -> Type) -> Constraint
69+class GOrdTable rep where
70+ gordTable :: GColumns rep (Dict (ConstrainDBType DBOrd))
71+
72+
73+instance GOrdTable rep => GOrdTable (M1 D c rep) where
74+ gordTable = gordTable @rep
75+
76+
77+instance GOrdTable rep => GOrdTable (M1 C c rep) where
78+ gordTable = gordTable @rep
79+
80+
81+instance (GOrdTable rep1, GOrdTable rep2) => GOrdTable (rep1 :*: rep2) where
82+ gordTable = HProduct (gordTable @rep1) (gordTable @rep2)
83+
84+
85+instance
86+ ( OrdTable a
87+ , KnownSymbol label
88+ , GColumns (M1 S meta k1) ~ HLabel label (Columns a)
89+ , meta ~ 'MetaSel ('Just label) _su _ss _ds
90+ , k1 ~ K1 i a
91+ )
92+ => GOrdTable (M1 S meta k1)
93+ where
94+ gordTable = hlabel hlabeler (ordTable @a)
59
95
60
96
61instance
97instance
@@ -65,6 +101,8 @@ instance
65 , HConstrainTable (Columns (t Expr)) (ConstrainDBType DBOrd)
101 , HConstrainTable (Columns (t Expr)) (ConstrainDBType DBOrd)
66 )
102 )
67 => OrdTable (t f)
103 => OrdTable (t f)
104+ where
105+ ordTable = hdicts @(Columns (t f)) @(ConstrainDBType DBOrd)
68
106
69
107
70instance
108instance
@@ -74,50 +112,25 @@ instance
74 , HConstrainTable t (ConstrainDBType DBOrd)
112 , HConstrainTable t (ConstrainDBType DBOrd)
75 )
113 )
76 => OrdTable (t f)
114 => OrdTable (t f)
115+ where
116+ ordTable = hdicts @(Columns (t f)) @(ConstrainDBType DBOrd)
77
117
78
118
79−instance Sql DBOrd a => OrdTable (Expr a)
119+instance Sql DBOrd a => OrdTable (Expr a) where
120+ ordTable = HType Dict
80
121
81
122
82−instance (OrdTable a, OrdTable b) => OrdTable (a, b) where
123+instance (OrdTable a, OrdTable b) => OrdTable (a, b)
83− ordTable =
84− HPair
85− { hfst = hlabel hlabeler (ordTable @a)
86− , hsnd = hlabel hlabeler (ordTable @b)
87− }
88
124
89
125
90−instance (OrdTable a, OrdTable b, OrdTable c) => OrdTable (a, b, c) where
126+instance (OrdTable a, OrdTable b, OrdTable c) => OrdTable (a, b, c)
91− ordTable =
92− HTrio
93− { hfst = hlabel hlabeler (ordTable @a)
94− , hsnd = hlabel hlabeler (ordTable @b)
95− , htrd = hlabel hlabeler (ordTable @c)
96− }
97
127
98
128
99instance (OrdTable a, OrdTable b, OrdTable c, OrdTable d) => OrdTable (a, b, c, d)
129instance (OrdTable a, OrdTable b, OrdTable c, OrdTable d) => OrdTable (a, b, c, d)
100− where
101− ordTable =
102− HQuartet
103− { hfst = hlabel hlabeler (ordTable @a)
104− , hsnd = hlabel hlabeler (ordTable @b)
105− , htrd = hlabel hlabeler (ordTable @c)
106− , hfrt = hlabel hlabeler (ordTable @d)
107− }
108
130
109
131
110instance (OrdTable a, OrdTable b, OrdTable c, OrdTable d, OrdTable e) =>
132instance (OrdTable a, OrdTable b, OrdTable c, OrdTable d, OrdTable e) =>
111 OrdTable (a, b, c, d, e)
133 OrdTable (a, b, c, d, e)
112− where
113− ordTable =
114− HQuintet
115− { hfst = hlabel hlabeler (ordTable @a)
116− , hsnd = hlabel hlabeler (ordTable @b)
117− , htrd = hlabel hlabeler (ordTable @c)
118− , hfrt = hlabel hlabeler (ordTable @d)
119− , hfft = hlabel hlabeler (ordTable @e)
120− }
121
134
122
135
123-- | Test if one 'Table' sorts before another. Corresponds to comparing all
136-- | Test if one 'Table' sorts before another. Corresponds to comparing all
src/Rel8/Table/Serialize.hs+70−57
@@ -1,5 +1,6 @@
1{-# language AllowAmbiguousTypes #-}
1{-# language AllowAmbiguousTypes #-}
2{-# language DataKinds #-}
2{-# language DataKinds #-}
3+{-# language DefaultSignatures #-}
3{-# language DisambiguateRecordFields #-}
4{-# language DisambiguateRecordFields #-}
4{-# language FlexibleContexts #-}
5{-# language FlexibleContexts #-}
5{-# language FlexibleInstances #-}
6{-# language FlexibleInstances #-}
@@ -9,6 +10,7 @@
9{-# language StandaloneKindSignatures #-}
10{-# language StandaloneKindSignatures #-}
10{-# language TypeApplications #-}
11{-# language TypeApplications #-}
11{-# language TypeFamilies #-}
12{-# language TypeFamilies #-}
13+{-# language TypeOperators #-}
12{-# language UndecidableInstances #-}
14{-# language UndecidableInstances #-}
13
15
14module Rel8.Table.Serialize
16module Rel8.Table.Serialize
@@ -23,6 +25,11 @@ where
23import Data.Bifunctor ( bimap )
25import Data.Bifunctor ( bimap )
24import Data.Kind ( Constraint, Type )
26import Data.Kind ( Constraint, Type )
25import Data.List.NonEmpty ( NonEmpty )
27import Data.List.NonEmpty ( NonEmpty )
28+import GHC.Generics
29+ ( Generic, Rep, from, to
30+ , (:*:)( (:*:) ), K1( K1 ), M1( M1 ), Meta( MetaSel ), D, C, S
31+ )
32+import GHC.TypeLits ( KnownSymbol )
26import Prelude
33import Prelude
27
34
28-- hasql
35-- hasql
@@ -31,19 +38,17 @@ import qualified Hasql.Decoders as Hasql
31-- rel8
38-- rel8
32import Rel8.Expr ( Expr, Col(..) )
39import Rel8.Expr ( Expr, Col(..) )
33import Rel8.Expr.Serialize ( slitExpr, sparseValue )
40import Rel8.Expr.Serialize ( slitExpr, sparseValue )
41+import Rel8.Generic.Record ( Record(..) )
34import Rel8.Schema.Context ( Col(..) )
42import Rel8.Schema.Context ( Col(..) )
35import Rel8.Schema.Context.Label ( labeler, unlabeler )
43import Rel8.Schema.Context.Label ( labeler, unlabeler )
36import Rel8.Schema.HTable ( HTable, htabulate, htabulateA, hfield, hspecs )
44import Rel8.Schema.HTable ( HTable, htabulate, htabulateA, hfield, hspecs )
37−import Rel8.Schema.HTable.Label ( hlabel, hunlabel )
45+import Rel8.Schema.HTable.Label ( HLabel, hlabel, hunlabel )
38−import Rel8.Schema.HTable.Quartet ( HQuartet(..) )
46+import Rel8.Schema.HTable.Product ( HProduct(..) )
39−import Rel8.Schema.HTable.Quintet ( HQuintet(..) )
40−import Rel8.Schema.HTable.Pair ( HPair(..) )
41−import Rel8.Schema.HTable.Trio ( HTrio(..) )
42import Rel8.Schema.HTable.Type ( HType(..) )
47import Rel8.Schema.HTable.Type ( HType(..) )
43import Rel8.Schema.Null ( NotNull, Sql )
48import Rel8.Schema.Null ( NotNull, Sql )
44import Rel8.Schema.Result ( Result )
49import Rel8.Schema.Result ( Result )
45import Rel8.Schema.Spec ( SSpec(..), KnownSpec )
50import Rel8.Schema.Spec ( SSpec(..), KnownSpec )
46−import Rel8.Table ( Table, Columns, fromColumns, toColumns )
51+import Rel8.Table ( Table, Columns, fromColumns, toColumns, GColumns )
47import Rel8.Table.Either ( EitherTable )
52import Rel8.Table.Either ( EitherTable )
48import Rel8.Table.List ( ListTable )
53import Rel8.Table.List ( ListTable )
49import Rel8.Table.Maybe ( MaybeTable )
54import Rel8.Table.Maybe ( MaybeTable )
@@ -64,6 +69,59 @@ class Table Expr exprs => ToExprs exprs a where
64 fromResult :: Columns exprs (Col Result) -> a
69 fromResult :: Columns exprs (Col Result) -> a
65 toResult :: a -> Columns exprs (Col Result)
70 toResult :: a -> Columns exprs (Col Result)
66
71
72+ default fromResult ::
73+ ( Generic (Record a)
74+ , GToExprs (Rep (Record exprs)) (Rep (Record a))
75+ , Columns exprs ~ GColumns (Rep (Record exprs))
76+ )
77+ => Columns exprs (Col Result) -> a
78+ fromResult = unrecord . to . gfromResult @(Rep (Record exprs))
79+
80+ default toResult ::
81+ ( Generic (Record a)
82+ , GToExprs (Rep (Record exprs)) (Rep (Record a))
83+ , Columns exprs ~ GColumns (Rep (Record exprs))
84+ )
85+ => a -> Columns exprs (Col Result)
86+ toResult = gtoResult @(Rep (Record exprs)) . from . Record
87+
88+
89+type GToExprs :: (Type -> Type) -> (Type -> Type) -> Constraint
90+class GToExprs exprs rep where
91+ gfromResult :: GColumns exprs (Col Result) -> rep x
92+ gtoResult :: rep x -> GColumns exprs (Col Result)
93+
94+
95+instance GToExprs exprs rep => GToExprs (M1 D c exprs) (M1 D c rep) where
96+ gfromResult = M1 . gfromResult @exprs
97+ gtoResult (M1 a) = gtoResult @exprs a
98+
99+
100+instance GToExprs exprs rep => GToExprs (M1 C c exprs) (M1 C c rep) where
101+ gfromResult = M1 . gfromResult @exprs
102+ gtoResult (M1 a) = gtoResult @exprs a
103+
104+
105+instance (GToExprs exprs1 rep1, GToExprs exprs2 rep2) =>
106+ GToExprs (exprs1 :*: exprs2) (rep1 :*: rep2)
107+ where
108+ gfromResult (HProduct a b) = gfromResult @exprs1 a :*: gfromResult @exprs2 b
109+ gtoResult (a :*: b) = HProduct (gtoResult @exprs1 a) (gtoResult @exprs2 b)
110+
111+
112+instance
113+ ( ToExprs exprs a
114+ , KnownSymbol label
115+ , GColumns (M1 S meta k1) ~ HLabel label (Columns exprs)
116+ , meta ~ 'MetaSel ('Just label) _su _ss _ds
117+ , k1 ~ K1 i exprs
118+ , k1' ~ K1 i a
119+ )
120+ => GToExprs (M1 S meta k1) (M1 S meta k1')
121+ where
122+ gfromResult = M1 . K1 . fromResult @exprs . hunlabel unlabeler
123+ gtoResult (M1 (K1 a)) = hlabel labeler (toResult @exprs a)
124+
67
125
68instance {-# OVERLAPPABLE #-} (Sql DBType a, x ~ Expr a) => ToExprs x a where
126instance {-# OVERLAPPABLE #-} (Sql DBType a, x ~ Expr a) => ToExprs x a where
69 fromResult (HType (Result a)) = a
127 fromResult (HType (Result a)) = a
@@ -127,15 +185,6 @@ instance (ToExprs exprs1 a, ToExprs exprs2 b, x ~ TheseTable exprs1 exprs2) =>
127
185
128instance (ToExprs exprs1 a, ToExprs exprs2 b, x ~ (exprs1, exprs2)) =>
186instance (ToExprs exprs1 a, ToExprs exprs2 b, x ~ (exprs1, exprs2)) =>
129 ToExprs x (a, b)
187 ToExprs x (a, b)
130− where
131− fromResult (HPair a b) =
132− ( fromResult @exprs1 $ hunlabel unlabeler a
133− , fromResult @exprs2 $ hunlabel unlabeler b
134− )
135− toResult (a, b) = HPair
136− { hfst = hlabel labeler $ toResult @exprs1 a
137− , hsnd = hlabel labeler $ toResult @exprs2 b
138− }
139
188
140
189
141instance
190instance
@@ -143,18 +192,8 @@ instance
143 , ToExprs exprs2 b
192 , ToExprs exprs2 b
144 , ToExprs exprs3 c
193 , ToExprs exprs3 c
145 , x ~ (exprs1, exprs2, exprs3)
194 , x ~ (exprs1, exprs2, exprs3)
195+ )
146− ) => ToExprs x (a, b, c)
196+ => ToExprs x (a, b, c)
147− where
148− fromResult (HTrio a b c) =
149− ( fromResult @exprs1 $ hunlabel unlabeler a
150− , fromResult @exprs2 $ hunlabel unlabeler b
151− , fromResult @exprs3 $ hunlabel unlabeler c
152− )
153− toResult (a, b, c) = HTrio
154− { hfst = hlabel labeler $ toResult @exprs1 a
155− , hsnd = hlabel labeler $ toResult @exprs2 b
156− , htrd = hlabel labeler $ toResult @exprs3 c
157− }
158
197
159
198
160instance
199instance
@@ -163,20 +202,8 @@ instance
163 , ToExprs exprs3 c
202 , ToExprs exprs3 c
164 , ToExprs exprs4 d
203 , ToExprs exprs4 d
165 , x ~ (exprs1, exprs2, exprs3, exprs4)
204 , x ~ (exprs1, exprs2, exprs3, exprs4)
205+ )
166− ) => ToExprs x (a, b, c, d)
206+ => ToExprs x (a, b, c, d)
167− where
168− fromResult (HQuartet a b c d) =
169− ( fromResult @exprs1 $ hunlabel unlabeler a
170− , fromResult @exprs2 $ hunlabel unlabeler b
171− , fromResult @exprs3 $ hunlabel unlabeler c
172− , fromResult @exprs4 $ hunlabel unlabeler d
173− )
174− toResult (a, b, c, d) = HQuartet
175− { hfst = hlabel labeler $ toResult @exprs1 a
176− , hsnd = hlabel labeler $ toResult @exprs2 b
177− , htrd = hlabel labeler $ toResult @exprs3 c
178− , hfrt = hlabel labeler $ toResult @exprs4 d
179− }
180
207
181
208
182instance
209instance
@@ -186,22 +213,8 @@ instance
186 , ToExprs exprs4 d
213 , ToExprs exprs4 d
187 , ToExprs exprs5 e
214 , ToExprs exprs5 e
188 , x ~ (exprs1, exprs2, exprs3, exprs4, exprs5)
215 , x ~ (exprs1, exprs2, exprs3, exprs4, exprs5)
216+ )
189− ) => ToExprs x (a, b, c, d, e)
217+ => ToExprs x (a, b, c, d, e)
190− where
191− fromResult (HQuintet a b c d e) =
192− ( fromResult @exprs1 $ hunlabel unlabeler a
193− , fromResult @exprs2 $ hunlabel unlabeler b
194− , fromResult @exprs3 $ hunlabel unlabeler c
195− , fromResult @exprs4 $ hunlabel unlabeler d
196− , fromResult @exprs5 $ hunlabel unlabeler e
197− )
198− toResult (a, b, c, d, e) = HQuintet
199− { hfst = hlabel labeler $ toResult @exprs1 a
200− , hsnd = hlabel labeler $ toResult @exprs2 b
201− , htrd = hlabel labeler $ toResult @exprs3 c
202− , hfrt = hlabel labeler $ toResult @exprs4 d
203− , hfft = hlabel labeler $ toResult @exprs5 e
204− }
205
218
206
219
207instance (HTable t, result ~ Col Result, x ~ t (Col Expr)) =>
220instance (HTable t, result ~ Col Result, x ~ t (Col Expr)) =>