on 11bcbbb help sign in
rel8/src/Rel8/Schema/Spec.hs
76 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 ( Nullability, Sql, Unnullify, nullabilization )
28import Rel8.Type ( DBType, typeInformation )
29import Rel8.Type.Information ( TypeInformation )
32type Spec :: Type
33data Spec = Spec Labels Necessity Type
36type SSpec :: Spec -> Type
37data SSpec spec where
38 SSpec ::
39 { labels :: SLabels labels
40 , necessity :: SNecessity necessity
41 , info :: TypeInformation (Unnullify a)
42 , nullability :: Nullability a
43 }
44 -> SSpec ('Spec labels necessity 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 )
57 => KnownSpec ('Spec labels necessity a)
58 where
59 specSing = SSpec
60 { labels = labelsSing
61 , necessity = necessitySing
62 , info = typeInformation
63 , nullability = nullabilization
64 }
67type KContext :: Type
68type KContext = Spec -> Type
71type HKTable :: Type
72type HKTable = KContext -> Type
75type KTable :: Type
76type KTable = (Type -> Type) -> Type