{-# language DataKinds #-} {-# language FlexibleContexts #-} {-# language GADTs #-} {-# language StandaloneKindSignatures #-} {-# language UndecidableInstances #-} module Rel8.Schema.Spec ( Spec( Spec ) , SSpec( SSpec, labels, necessity, info, nullability ) , KnownSpec( specSing ) , KContext, HKTable , KTable ) where -- base import Data.Kind ( Constraint, Type ) import Prelude () -- rel8 import Rel8.Kind.Labels ( Labels, SLabels, KnownLabels, labelsSing ) import Rel8.Kind.Necessity ( Necessity , SNecessity , KnownNecessity, necessitySing ) import Rel8.Schema.Nullability ( Unnullify, Nullability, Sql, nullabilization ) import Rel8.Type ( DBType, typeInformation ) import Rel8.Type.Information ( TypeInformation ) type Spec :: Type data Spec = Spec Labels Necessity Type Type type SSpec :: Spec -> Type data SSpec spec where SSpec :: { labels :: SLabels labels , necessity :: SNecessity necessity , info :: TypeInformation db , nullability :: Nullability db a } -> SSpec ('Spec labels necessity db a) type KnownSpec :: Spec -> Constraint class KnownSpec spec where specSing :: SSpec spec instance ( KnownLabels labels , KnownNecessity necessity , Sql DBType a , db ~ Unnullify a ) => KnownSpec ('Spec labels necessity db a) where specSing = SSpec { labels = labelsSing , necessity = necessitySing , info = typeInformation , nullability = nullabilization } type KContext :: Type type KContext = Spec -> Type type HKTable :: Type type HKTable = KContext -> Type type KTable :: Type type KTable = (Type -> Type) -> Type