on master help sign in
Add EqTable and OrdTable instances for HKD
commitfb3d2d9caf1ab6891d0827321133082f2e617b45 authorShane O'Brien <shane.obrien@circuithub.com> dateFri 30 Apr 2021, 18:17 (6 years ago) parent6e42c1e
1 file changed+28−1
src/Rel8/Generic/HKD.hs+28−1
src/Rel8/Generic/HKD.hs+28−1
@@ -33,24 +33,30 @@ import Data.Generic.HKD ( HKD(..), GHKD_ )
3333
3434-- rel8
3535import Rel8.Aggregate ( Col(..) )
36+import Rel8.Expr ( Expr )
3637import Rel8.Schema.Context.Label
3738 ( Labelable
3839 , HLabelable, hlabeler, hunlabeler
3940 )
4041import Rel8.Schema.Dict ( Dict( Dict ) )
41−import Rel8.Schema.HTable ( HTable )
42+import Rel8.Schema.HTable ( HTable, HConstrainTable, hdicts )
4243import Rel8.Schema.HTable.Label ( HLabel, hlabel, hunlabel )
4344import Rel8.Schema.HTable.Product ( HProduct( HProduct ) )
4445import Rel8.Schema.HTable.Type ( HType )
4546import qualified Rel8.Schema.Kind as K
4647import Rel8.Schema.Null ( Sql )
4748import Rel8.Schema.Reify ( NotReify, notReify )
49+import Rel8.Schema.Spec.ConstrainDBType ( ConstrainDBType )
4850import Rel8.Table
4951 ( Table, Columns, Context, fromColumns, toColumns
5052 , reify, unreify
5153 )
54+import Rel8.Table.Eq ( EqTable, eqTable )
55+import Rel8.Table.Ord ( OrdTable, ordTable )
5256import Rel8.Table.Recontextualize ( Recontextualize )
5357import Rel8.Type ( DBType )
58+import Rel8.Type.Eq ( DBEq )
59+import Rel8.Type.Ord ( DBOrd )
5460
5561
5662type Column1Helper :: K.Context -> (Type -> Type) -> Type -> Constraint
@@ -182,6 +188,27 @@ instance
182188 unreify = notReify
183189
184190
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+
185212instance
186213 ( a ~ a'
187214 , GTable (Rep a)