on bb078d2 help sign in
rel8/src/Rel8/Schema/Spec.hs
72 lines 1.5 kB history raw
1{-# language DataKinds #-}
2{-# language FlexibleContexts #-}
3{-# language GADTs #-}
4{-# language StandaloneKindSignatures #-}
5{-# language UndecidableInstances #-}
7module Rel8.Schema.Spec
8 ( Spec( Spec )
9 , SSpec( SSpec, labels, necessity, info, nullability )
10 , KnownSpec( specSing )
11 , Context, KTable
12 )
13where
15-- base
16import Data.Kind ( Constraint, Type )
17import Prelude ()
19-- rel8
20import Rel8.Kind.Labels ( Labels, SLabels, KnownLabels, labelsSing )
21import Rel8.Kind.Necessity
22 ( Necessity
23 , SNecessity
24 , KnownNecessity, necessitySing
25 )
26import Rel8.Schema.Nullability ( Unnullify, Nullability, Sql, nullabilization )
27import Rel8.Type ( DBType, typeInformation )
28import Rel8.Type.Information ( TypeInformation )
31type Spec :: Type
32data Spec = Spec Labels Necessity Type Type
35type SSpec :: Spec -> Type
36data SSpec spec where
37 SSpec ::
38 { labels :: SLabels labels
39 , necessity :: SNecessity necessity
40 , info :: TypeInformation db
41 , nullability :: Nullability db a
42 }
43 -> SSpec ('Spec labels necessity db a)
46type KnownSpec :: Spec -> Constraint
47class KnownSpec spec where
48 specSing :: SSpec spec
51instance
52 ( KnownLabels labels
53 , KnownNecessity necessity
54 , Sql DBType a
55 , db ~ Unnullify a
56 )
57 => KnownSpec ('Spec labels necessity db a)
58 where
59 specSing = SSpec
60 { labels = labelsSing
61 , necessity = necessitySing
62 , info = typeInformation
63 , nullability = nullabilization
64 }
67type Context :: Type
68type Context = Spec -> Type
71type KTable :: Type
72type KTable = Context -> Type