on 5e4df50 help sign in
rel8/src/Rel8/Schema/Column.hs
42 lines 1.1 kB history raw
1{-# language DataKinds #-}
2{-# language TypeFamilies #-}
3{-# language StandaloneKindSignatures #-}
5module Rel8.Schema.Column
6 ( Column, Default
7 )
8where
10-- base
11import Data.Kind ( Type )
12import Prelude ()
14-- rel8
15import Rel8.Kind.Necessity ( Necessity( Required, Optional ) )
16import Rel8.Schema.Field ( Field )
17import qualified Rel8.Schema.Kind as K
20type Default :: Type -> Type
21data Default a
24type GetNecessity :: Type -> Necessity
25type family GetNecessity a where
26 GetNecessity (Default _) = 'Optional
27 GetNecessity _ = 'Required
30type UnwrapDefault :: Type -> Type
31type family UnwrapDefault a where
32 UnwrapDefault (Default a) = a
33 UnwrapDefault a = a
36-- | The @Column@ type family should be used to indicate which fields of your
37-- data types are single columns in queries. This type family has special
38-- support when a query is executed, allowing you to use a single data type for
39-- both query data and rows decoded to Haskell.
40type Column :: K.Context -> Type -> Type
41type Column context a =
42 Field context (GetNecessity a) (UnwrapDefault a)