on 8bc950e help sign in
rel8/src/Rel8/Table/Lifted.hs
57 lines 1.6 kB history raw
1{-# language ConstrainedClassMethods #-}
2{-# language DataKinds #-}
3{-# language FlexibleContexts #-}
4{-# language FlexibleInstances #-}
5{-# language StandaloneKindSignatures #-}
6{-# language TypeFamilies #-}
8module Rel8.Table.Lifted
9 ( Table1( Columns1, ConstrainContext1, toColumns1, fromColumns1 )
10 , Table2( Columns2, ConstrainContext2, toColumns2, fromColumns2 )
11 )
12where
14-- base
15import Data.Kind ( Constraint, Type )
16import Prelude ()
18-- rel8
19import Rel8.Schema.Context ( Interpretation, Col )
20import Rel8.Schema.HTable ( HTable )
21import qualified Rel8.Schema.Kind as K
24type Table1 :: (Type -> Type) -> Constraint
25class Table1 f where
26 type Columns1 f :: K.HTable -> K.HTable
27 type ConstrainContext1 f :: K.Context -> Constraint
28 type ConstrainContext1 _ = Interpretation
30 toColumns1 :: (ConstrainContext1 f context, HTable t)
31 => (a -> t (Col context))
32 -> f a
33 -> Columns1 f t (Col context)
35 fromColumns1 :: (ConstrainContext1 f context, HTable t)
36 => (t (Col context) -> a)
37 -> Columns1 f t (Col context)
38 -> f a
41type Table2 :: (Type -> Type -> Type) -> Constraint
42class Table2 p where
43 type Columns2 p :: K.HTable -> K.HTable -> K.HTable
44 type ConstrainContext2 p :: K.Context -> Constraint
45 type ConstrainContext2 _ = Interpretation
47 toColumns2 :: (ConstrainContext2 p context, HTable t, HTable u)
48 => (a -> t (Col context))
49 -> (b -> u (Col context))
50 -> p a b
51 -> Columns2 p t u (Col context)
53 fromColumns2 :: (ConstrainContext2 p context, HTable t, HTable u)
54 => (t (Col context) -> a)
55 -> (u (Col context) -> b)
56 -> Columns2 p t u (Col context)
57 -> p a b