on c6ffdab help sign in
rel8/src/Rel8/Schema/Spec.hs
48 lines 984 B 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.Schema.Null ( Nullity, Sql, Unnullify, nullable )
20import Rel8.Type ( DBType, typeInformation )
21import Rel8.Type.Information ( TypeInformation )
24type Spec :: Type
25newtype Spec = Spec Type
28type SSpec :: Spec -> Type
29data SSpec spec where
30 SSpec ::
31 { labels :: [String]
32 , info :: TypeInformation (Unnullify a)
33 , nullity :: Nullity a
34 }
35 -> SSpec ('Spec a)
38type KnownSpec :: Spec -> Constraint
39class KnownSpec spec where
40 specSing :: SSpec spec
43instance Sql DBType a => KnownSpec ('Spec a) where
44 specSing = SSpec
45 { labels = []
46 , info = typeInformation
47 , nullity = nullable
48 }