on 00a36f5 help sign in
rel8/src/Rel8/Schema/Spec.hs
77 lines 1.6 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 , KContext, HKTable
12 , KTable
13 )
14where
16-- base
17import Data.Kind ( Constraint, Type )
18import Prelude ()
20-- rel8
21import Rel8.Kind.Labels ( Labels, SLabels, KnownLabels, labelsSing )
22import Rel8.Kind.Necessity
23 ( Necessity
24 , SNecessity
25 , KnownNecessity, necessitySing
26 )
27import Rel8.Schema.Nullability ( Unnullify, Nullability, Sql, nullabilization )
28import Rel8.Type ( DBType, typeInformation )
29import Rel8.Type.Information ( TypeInformation )
32type Spec :: Type
33data Spec = Spec Labels Necessity Type Type
36type SSpec :: Spec -> Type
37data SSpec spec where
38 SSpec ::
39 { labels :: SLabels labels
40 , necessity :: SNecessity necessity
41 , info :: TypeInformation db
42 , nullability :: Nullability db a
43 }
44 -> SSpec ('Spec labels necessity db a)
47type KnownSpec :: Spec -> Constraint
48class KnownSpec spec where
49 specSing :: SSpec spec
52instance
53 ( KnownLabels labels
54 , KnownNecessity necessity
55 , Sql DBType a
56 , db ~ Unnullify a
57 )
58 => KnownSpec ('Spec labels necessity db a)
59 where
60 specSing = SSpec
61 { labels = labelsSing
62 , necessity = necessitySing
63 , info = typeInformation
64 , nullability = nullabilization
65 }
68type KContext :: Type
69type KContext = Spec -> Type
72type HKTable :: Type
73type HKTable = KContext -> Type
76type KTable :: Type
77type KTable = (Type -> Type) -> Type