on db148ff help sign in
rel8/src/Rel8/Column.hs
35 lines 952 B history raw
1{-# language DataKinds #-}
2{-# language TypeFamilies #-}
3{-# language StandaloneKindSignatures #-}
5module Rel8.Column
6 ( Column, Default
7 , TColumn
8 )
9where
11-- base
12import Data.Kind ( Type )
13import Prelude ()
15-- rel8
16import Rel8.Column.Field ( Field )
17import Rel8.FCF ( Eval, Exp )
18import Rel8.Kind.Necessity ( Necessity( Required, Optional ) )
19import qualified Rel8.Schema.Kind as K
22-- | The @Column@ type family should be used to indicate which fields of your
23-- data types are single columns in queries. This type family has special
24-- support when a query is executed, allowing you to use a single data type for
25-- both query data and rows decoded to Haskell.
26type Column :: K.Context -> Type -> Type
27type Column context a = Field context 'Required a
30type Default :: K.Context -> Type -> Type
31type Default context a = Field context 'Optional a
34data TColumn :: K.Context -> Type -> Exp Type
35type instance Eval (TColumn f a) = Column f a