on ef91171 help sign in
rel8/src/Rel8/Table/Recontextualize.hs
89 lines 2.2 kB history raw
1{-# language DataKinds #-}
2{-# language FlexibleInstances #-}
3{-# language FunctionalDependencies #-}
4{-# language StandaloneKindSignatures #-}
5{-# language TypeFamilies #-}
6{-# language UndecidableInstances #-}
7{-# language UndecidableSuperClasses #-}
9module Rel8.Table.Recontextualize
10 ( Recontextualize
11 )
12where
14-- base
15import Data.Functor.Identity ( Identity )
16import Data.Kind ( Constraint, Type )
17import Prelude ()
19-- rel8
20import Rel8.Schema.Context ( Col )
21import Rel8.Schema.Context.Label ( Labelable )
22import Rel8.Schema.HTable ( HTable )
23import qualified Rel8.Schema.Kind as K
24import Rel8.Schema.Null ( Sql )
25import Rel8.Table ( Table, Congruent )
26import Rel8.Type ( DBType )
29type Recontextualize :: K.Context -> K.Context -> Type -> Type -> Constraint
30class
31 ( Table from a
32 , Table to b
33 , Congruent a b
34 , Recontextualize from from a a
35 , Recontextualize to to b b
36 , Recontextualize to from b a
37 ) => Recontextualize from to a b
38 | a -> from
39 , b -> to
40 , a to -> b
41 , b from -> a
44instance Sql DBType a => Recontextualize Identity Identity (Identity a) (Identity a)
47instance HTable t => Recontextualize from to (t (Col from)) (t (Col to))
50instance
51 ( Table from (t from)
52 , Table to (t to)
53 , Congruent (t from) (t to)
54 ) => Recontextualize from to (t from) (t to)
57instance
58 ( Recontextualize from to a1 b1
59 , Recontextualize from to a2 b2
60 , Labelable from
61 , Labelable to
62 ) => Recontextualize from to (a1, a2) (b1, b2)
65instance
66 ( Recontextualize from to a1 b1
67 , Recontextualize from to a2 b2
68 , Recontextualize from to a3 b3
69 , Labelable from, Labelable to
70 ) => Recontextualize from to (a1, a2, a3) (b1, b2, b3)
73instance
74 ( Recontextualize from to a1 b1
75 , Recontextualize from to a2 b2
76 , Recontextualize from to a3 b3
77 , Recontextualize from to a4 b4
78 , Labelable from, Labelable to
79 ) => Recontextualize from to (a1, a2, a3, a4) (b1, b2, b3, b4)
82instance
83 ( Recontextualize from to a1 b1
84 , Recontextualize from to a2 b2
85 , Recontextualize from to a3 b3
86 , Recontextualize from to a4 b4
87 , Recontextualize from to a5 b5
88 , Labelable from, Labelable to
89 ) => Recontextualize from to (a1, a2, a3, a4, a5) (b1, b2, b3, b4, b5)