on master help sign in
Add EqTable and OrdTable instances for HKD
fb3d2d9Shane O'Brien
src/Rel8/Generic/HKD.hs+28−1
@@ -33,24 +33,30 @@ import Data.Generic.HKD ( HKD(..), GHKD_ )
33
33
34-- rel8
34-- rel8
35import Rel8.Aggregate ( Col(..) )
35import Rel8.Aggregate ( Col(..) )
36+import Rel8.Expr ( Expr )
36import Rel8.Schema.Context.Label
37import Rel8.Schema.Context.Label
37 ( Labelable
38 ( Labelable
38 , HLabelable, hlabeler, hunlabeler
39 , HLabelable, hlabeler, hunlabeler
39 )
40 )
40import Rel8.Schema.Dict ( Dict( Dict ) )
41import Rel8.Schema.Dict ( Dict( Dict ) )
41−import Rel8.Schema.HTable ( HTable )
42+import Rel8.Schema.HTable ( HTable, HConstrainTable, hdicts )
42import Rel8.Schema.HTable.Label ( HLabel, hlabel, hunlabel )
43import Rel8.Schema.HTable.Label ( HLabel, hlabel, hunlabel )
43import Rel8.Schema.HTable.Product ( HProduct( HProduct ) )
44import Rel8.Schema.HTable.Product ( HProduct( HProduct ) )
44import Rel8.Schema.HTable.Type ( HType )
45import Rel8.Schema.HTable.Type ( HType )
45import qualified Rel8.Schema.Kind as K
46import qualified Rel8.Schema.Kind as K
46import Rel8.Schema.Null ( Sql )
47import Rel8.Schema.Null ( Sql )
47import Rel8.Schema.Reify ( NotReify, notReify )
48import Rel8.Schema.Reify ( NotReify, notReify )
49+import Rel8.Schema.Spec.ConstrainDBType ( ConstrainDBType )
48import Rel8.Table
50import Rel8.Table
49 ( Table, Columns, Context, fromColumns, toColumns
51 ( Table, Columns, Context, fromColumns, toColumns
50 , reify, unreify
52 , reify, unreify
51 )
53 )
54+import Rel8.Table.Eq ( EqTable, eqTable )
55+import Rel8.Table.Ord ( OrdTable, ordTable )
52import Rel8.Table.Recontextualize ( Recontextualize )
56import Rel8.Table.Recontextualize ( Recontextualize )
53import Rel8.Type ( DBType )
57import Rel8.Type ( DBType )
58+import Rel8.Type.Eq ( DBEq )
59+import Rel8.Type.Ord ( DBOrd )
54
60
55
61
56type Column1Helper :: K.Context -> (Type -> Type) -> Type -> Constraint
62type Column1Helper :: K.Context -> (Type -> Type) -> Type -> Constraint
@@ -182,6 +188,27 @@ instance
182 unreify = notReify
188 unreify = notReify
183
189
184
190
191+instance
192+ ( GTable (Rep a)
193+ , f ~ Expr
194+ , HConstrainTable (GColumns (Rep a)) (ConstrainDBType DBEq)
195+ )
196+ => EqTable (HKD a f)
197+ where
198+ eqTable = hdicts @(GColumns (Rep a)) @(ConstrainDBType DBEq)
199+
200+
201+instance
202+ ( GTable (Rep a)
203+ , f ~ Expr
204+ , HConstrainTable (GColumns (Rep a)) (ConstrainDBType DBEq)
205+ , HConstrainTable (GColumns (Rep a)) (ConstrainDBType DBOrd)
206+ )
207+ => OrdTable (HKD a f)
208+ where
209+ ordTable = hdicts @(GColumns (Rep a)) @(ConstrainDBType DBOrd)
210+
211+
185instance
212instance
186 ( a ~ a'
213 ( a ~ a'
187 , GTable (Rep a)
214 , GTable (Rep a)