on db40580 help sign in
rel8/src/Rel8/Schema/Spec.hs
62 lines 1.4 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, nullity )
10 , KnownSpec( specSing )
11 )
12where
14-- base
15import Data.Kind ( Constraint, Type )
16import Prelude ()
18-- rel8
19import Rel8.Kind.Labels ( Labels, SLabels, KnownLabels, labelsSing )
20import Rel8.Kind.Necessity
21 ( Necessity
22 , SNecessity
23 , KnownNecessity, necessitySing
24 )
25import Rel8.Schema.Null ( Nullity, Sql, Unnullify, nullable )
26import Rel8.Type ( DBType, typeInformation )
27import Rel8.Type.Information ( TypeInformation )
30type Spec :: Type
31data Spec = Spec Labels Necessity Type
34type SSpec :: Spec -> Type
35data SSpec spec where
36 SSpec ::
37 { labels :: SLabels labels
38 , necessity :: SNecessity necessity
39 , info :: TypeInformation (Unnullify a)
40 , nullity :: Nullity a
41 }
42 -> SSpec ('Spec labels necessity a)
45type KnownSpec :: Spec -> Constraint
46class KnownSpec spec where
47 specSing :: SSpec spec
50instance
51 ( KnownLabels labels
52 , KnownNecessity necessity
53 , Sql DBType a
54 )
55 => KnownSpec ('Spec labels necessity a)
56 where
57 specSing = SSpec
58 { labels = labelsSing
59 , necessity = necessitySing
60 , info = typeInformation
61 , nullity = nullable
62 }