on 669b262 help sign in
rel8/src/Rel8/Schema/Spec.hs
71 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 ( Nullability, Nullabilizes, 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 , DBType db
55 , Nullabilizes db a
56 ) => KnownSpec ('Spec labels necessity db a)
57 where
58 specSing = SSpec
59 { labels = labelsSing
60 , necessity = necessitySing
61 , info = typeInformation
62 , nullability = nullabilization
63 }
66type Context :: Type
67type Context = Spec -> Type
70type KTable :: Type
71type KTable = Context -> Type