1{-# language DataKinds #-}
2{-# language FlexibleContexts #-}
3{-# language FlexibleInstances #-}
4{-# language FunctionalDependencies #-}
5{-# language StandaloneKindSignatures #-}
6{-# language TypeFamilies #-}
7{-# language UndecidableInstances #-}
8{-# language UndecidableSuperClasses #-}
10module Rel8.Table.Recontextualize
20import Data.Functor.Identity ( Identity )
21import Data.Kind ( Constraint, Type )
25import Rel8.Aggregate ( Aggregate )
26import Rel8.Expr ( Expr )
27import Rel8.Opaque ( Opaque, Opaque1 )
28import Rel8.Schema.Context ( Col(..), Insertion, Name )
29import Rel8.Schema.Context.Label ( Labelable )
30import Rel8.Schema.HTable ( HTable )
31import qualified Rel8.Schema.Kind as K
32import Rel8.Schema.Nullability ( Sql )
33import Rel8.Schema.Spec ( KnownSpec )
34import Rel8.Table ( Table, Congruent )
35import Rel8.Type ( DBType )
38type Recontextualize :: K.Context -> K.Context -> Type -> Type -> Constraint
43 , Recontextualize from from a a
44 , Recontextualize to to b b
45 , Recontextualize to from b a
46 ) => Recontextualize from to a b
53instance KnownSpec spec =>
54 Recontextualize from to (Col from spec) (Col to spec)
57instance Sql DBType a =>
58 Recontextualize Aggregate Aggregate (Aggregate (Expr a)) (Aggregate (Expr a))
61instance Sql DBType a =>
62 Recontextualize Aggregate Expr (Aggregate (Expr a)) (Expr a)
65instance Sql DBType a =>
66 Recontextualize Aggregate Identity (Aggregate (Expr a)) (Identity a)
69instance Sql DBType a =>
70 Recontextualize Aggregate Insertion (Aggregate (Expr a)) (Insertion a)
73instance Sql DBType a =>
74 Recontextualize Aggregate Name (Aggregate (Expr a)) (Name a)
77instance Sql DBType a =>
78 Recontextualize Expr Aggregate (Expr a) (Aggregate (Expr a))
81instance Sql DBType a => Recontextualize Expr Expr (Expr a) (Expr a)
84instance Sql DBType a => Recontextualize Expr Identity (Expr a) (Identity a)
87instance Sql DBType a => Recontextualize Expr Insertion (Expr a) (Insertion a)
90instance Sql DBType a => Recontextualize Expr Name (Expr a) (Name a)
93instance Sql DBType a =>
94 Recontextualize Identity Aggregate (Identity a) (Aggregate (Expr a))
97instance Sql DBType a => Recontextualize Identity Expr (Identity a) (Expr a)
100instance Sql DBType a => Recontextualize Identity Identity (Identity a) (Identity a)
103instance Sql DBType a =>
104 Recontextualize Identity Insertion (Identity a) (Insertion a)
107instance Sql DBType a => Recontextualize Identity Name (Identity a) (Name a)
110instance Sql DBType a =>
111 Recontextualize Insertion Aggregate (Insertion a) (Aggregate (Expr a))
114instance Sql DBType a => Recontextualize Insertion Expr (Insertion a) (Expr a)
117instance Sql DBType a =>
118 Recontextualize Insertion Identity (Insertion a) (Identity a)
121instance Sql DBType a => Recontextualize Insertion Insertion (Insertion a) (Insertion a)
124instance Sql DBType a => Recontextualize Insertion Name (Insertion a) (Name a)
127instance Sql DBType a =>
128 Recontextualize Name Aggregate (Name a) (Aggregate (Expr a))
131instance Sql DBType a => Recontextualize Name Expr (Name a) (Expr a)
134instance Sql DBType a => Recontextualize Name Identity (Name a) (Identity a)
137instance Sql DBType a => Recontextualize Name Insertion (Name a) (Insertion a)
140instance Sql DBType a => Recontextualize Name Name (Name a) (Name a)
143instance Recontextualize from to (Opaque1 from a) (Opaque1 to a)
146instance HTable t => Recontextualize from to (t (Col from)) (t (Col to))
150 ( Table from (t from)
152 , Congruent (t from) (t to)
153 ) => Recontextualize from to (t from) (t to)
157 ( Recontextualize from to a1 b1
158 , Recontextualize from to a2 b2
161 ) => Recontextualize from to (a1, a2) (b1, b2)
165 ( Recontextualize from to a1 b1
166 , Recontextualize from to a2 b2
167 , Recontextualize from to a3 b3
168 , Labelable from, Labelable to
169 ) => Recontextualize from to (a1, a2, a3) (b1, b2, b3)
173 ( Recontextualize from to a1 b1
174 , Recontextualize from to a2 b2
175 , Recontextualize from to a3 b3
176 , Recontextualize from to a4 b4
177 , Labelable from, Labelable to
178 ) => Recontextualize from to (a1, a2, a3, a4) (b1, b2, b3, b4)
182 ( Recontextualize from to a1 b1
183 , Recontextualize from to a2 b2
184 , Recontextualize from to a3 b3
185 , Recontextualize from to a4 b4
186 , Recontextualize from to a5 b5
187 , Labelable from, Labelable to
188 ) => Recontextualize from to (a1, a2, a3, a4, a5) (b1, b2, b3, b4, b5)
191-- | @Aggregates a b@ means that the columns in @a@ are all 'Aggregate' 'Expr's
192-- for the columns in @b@.
193type Aggregates :: Type -> Type -> Constraint
194class Recontextualize Aggregate Expr aggregates exprs => Aggregates aggregates exprs
195instance Recontextualize Aggregate Expr aggregates exprs => Aggregates aggregates exprs
196instance {-# OVERLAPPING #-} Aggregates (Opaque1 Aggregate Opaque) (Opaque1 Expr Opaque)
199type Encodes :: Type -> Type -> Constraint
200class Recontextualize Identity Expr a exprs => Encodes a exprs
201instance Recontextualize Identity Expr a exprs => Encodes a exprs
202instance {-# OVERLAPPING #-} Encodes (Opaque1 Identity Opaque) (Opaque1 Expr Opaque)
205-- | @Inserts a b@ means that the columns in @a@ are compatible for inserting
206-- with the table @b@.
207type Inserts :: Type -> Type -> Constraint
208class Recontextualize Expr Insertion exprs inserts => Inserts exprs inserts
209instance Recontextualize Expr Insertion exprs inserts => Inserts exprs inserts
210instance {-# OVERLAPPING #-} Inserts (Opaque1 Expr Opaque) (Opaque1 Insertion Opaque)
213-- | @Selects a b@ means that @a@ is a schema (i.e., a 'Table' of 'Name's) for
214-- the 'Expr' columns in @b@.
215type Selects :: Type -> Type -> Constraint
216class Recontextualize Name Expr names exprs => Selects names exprs
217instance Recontextualize Name Expr names exprs => Selects names exprs
218instance {-# OVERLAPPING #-} Selects (Opaque1 Name Opaque) (Opaque1 Expr Opaque)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list