{-# language FlexibleContexts #-}
{-# language MonoLocalBinds #-}
{-# language StandaloneKindSignatures #-}

module Rel8.Schema.Spec
  ( Spec( Spec, labels, info, nullity )
  , specification
  )
where

-- base
import Data.Kind ( Type )
import Prelude

-- rel8
import Rel8.Schema.Null ( Nullity, Sql, Unnullify, nullable )
import Rel8.Type ( DBType, typeInformation )
import Rel8.Type.Information ( TypeInformation )


type Spec :: Type -> Type
data Spec a = Spec
  { Spec a -> [String]
labels :: [String]
  , Spec a -> TypeInformation (Unnullify a)
info :: TypeInformation (Unnullify a)
  , Spec a -> Nullity a
nullity :: Nullity a
  }


specification :: Sql DBType a => Spec a
specification :: Spec a
specification = Spec :: forall a.
[String] -> TypeInformation (Unnullify a) -> Nullity a -> Spec a
Spec
  { labels :: [String]
labels = []
  , info :: TypeInformation (Unnullify a)
info = TypeInformation (Unnullify a)
forall a. DBType a => TypeInformation a
typeInformation
  , nullity :: Nullity a
nullity = Nullity a
forall a. Nullable a => Nullity a
nullable
  }