1{-# language DataKinds #-}
2{-# language DerivingStrategies #-}
4{-# language GeneralizedNewtypeDeriving #-}
5{-# language StandaloneKindSignatures #-}
6{-# language TypeFamilies #-}
8module Rel8.Schema.Context
9 ( Interpretation, Col(..)
16import Data.Functor.Identity ( Identity )
17import Data.Kind ( Constraint )
18import Data.String ( IsString )
22import Rel8.Aggregate ( Aggregate )
23import Rel8.Expr ( Expr )
24import Rel8.Kind.Necessity ( Necessity( Optional, Required ) )
25import qualified Rel8.Schema.Kind as K
26import Rel8.Schema.Spec ( Spec( Spec ) )
29type Interpretation :: K.Context -> Constraint
30class Interpretation context where
31 data Col context :: K.HContext
34instance Interpretation Aggregate where
35 data Col Aggregate _spec where
38 -> Col Aggregate ('Spec labels necessity db a)
41instance Interpretation Expr where
42 data Col Expr _spec where
45 -> Col Expr ('Spec labels necessity db a)
48instance Interpretation Identity where
49 data Col Identity _spec where
50 Result :: a -> Col Identity ('Spec labels necessity db a)
53instance Interpretation Insertion where
54 data Col Insertion _spec where
55 RequiredInsert :: Expr a -> Col Insertion ('Spec labels 'Required db a)
56 OptionalInsert :: Maybe (Expr a) -> Col Insertion ('Spec labels 'Optional db a)
59instance Interpretation Name where
60 data Col Name _spec where
61 NameCol :: String -> Col Name ('Spec labels necessity db a)
64type Insertion :: K.Context
65newtype Insertion a = Insertion (Expr a)
68-- | A @Name@ is the name of a column, as it would be defined in a table's
69-- schema definition. You can construct names by using the @OverloadedStrings@
70-- extension and writing string literals. This is typically done when providing
71-- a 'TableSchema' value.
73newtype Name a = Name String
75 deriving newtype (IsString, Monoid, Semigroup)
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