on bc275dc help sign in
rel8/src/Rel8/Schema/Spec.hs
54 lines 1.1 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, 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.Schema.Null ( Nullity, Sql, Unnullify, nullable )
21import Rel8.Type ( DBType, typeInformation )
22import Rel8.Type.Information ( TypeInformation )
25type Spec :: Type
26data Spec = Spec Labels Type
29type SSpec :: Spec -> Type
30data SSpec spec where
31 SSpec ::
32 { labels :: SLabels labels
33 , info :: TypeInformation (Unnullify a)
34 , nullity :: Nullity a
35 }
36 -> SSpec ('Spec labels a)
39type KnownSpec :: Spec -> Constraint
40class KnownSpec spec where
41 specSing :: SSpec spec
44instance
45 ( KnownLabels labels
46 , Sql DBType a
47 )
48 => KnownSpec ('Spec labels a)
49 where
50 specSing = SSpec
51 { labels = labelsSing
52 , info = typeInformation
53 , nullity = nullable
54 }