{-# language DataKinds #-}
{-# language DeriveAnyClass #-}
{-# language DeriveGeneric #-}
{-# language DerivingStrategies #-}
{-# language StandaloneKindSignatures #-}

module Rel8.Schema.HTable.Maybe
  ( HMaybeTable(..)
  )
where

-- base
import GHC.Generics ( Generic )
import Prelude

-- rel8
import Rel8.Schema.HTable ( HTable )
import Rel8.Schema.HTable.Identity ( HIdentity(..) )
import Rel8.Schema.HTable.Label ( HLabel )
import Rel8.Schema.HTable.Nullify ( HNullify )
import qualified Rel8.Schema.Kind as K
import Rel8.Schema.Spec ( Spec( Spec ) )
import Rel8.Type.Tag ( MaybeTag )


type HMaybeTable :: K.HTable -> K.HTable
data HMaybeTable table context = HMaybeTable
  { HMaybeTable table context
-> HIdentity ('Spec '["isJust"] (Maybe MaybeTag)) context
htag :: HIdentity ('Spec '["isJust"] (Maybe MaybeTag)) context
  , HMaybeTable table context -> HLabel "Just" (HNullify table) context
hjust :: HLabel "Just" (HNullify table) context
  }
  deriving stock (forall x.
 HMaybeTable table context -> Rep (HMaybeTable table context) x)
-> (forall x.
    Rep (HMaybeTable table context) x -> HMaybeTable table context)
-> Generic (HMaybeTable table context)
forall x.
Rep (HMaybeTable table context) x -> HMaybeTable table context
forall x.
HMaybeTable table context -> Rep (HMaybeTable table context) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (table :: HTable) (context :: HContext) x.
Rep (HMaybeTable table context) x -> HMaybeTable table context
forall (table :: HTable) (context :: HContext) x.
HMaybeTable table context -> Rep (HMaybeTable table context) x
$cto :: forall (table :: HTable) (context :: HContext) x.
Rep (HMaybeTable table context) x -> HMaybeTable table context
$cfrom :: forall (table :: HTable) (context :: HContext) x.
HMaybeTable table context -> Rep (HMaybeTable table context) x
Generic
  deriving anyclass HMaybeTable table SSpec
(forall (context :: HContext) (spec :: Spec).
 HMaybeTable table context
 -> HField (HMaybeTable table) spec -> context spec)
-> (forall (context :: HContext).
    (forall (spec :: Spec).
     HField (HMaybeTable table) spec -> context spec)
    -> HMaybeTable table context)
-> (forall (m :: * -> *) (f :: HContext) (g :: HContext).
    Apply m =>
    (forall (spec :: Spec). f spec -> m (g spec))
    -> HMaybeTable table f -> m (HMaybeTable table g))
-> (forall (c :: Spec -> Constraint).
    HConstrainTable (HMaybeTable table) c =>
    HMaybeTable table (Dict c))
-> HMaybeTable table SSpec
-> HTable (HMaybeTable table)
forall (m :: * -> *) (f :: HContext) (g :: HContext).
Apply m =>
(forall (spec :: Spec). f spec -> m (g spec))
-> HMaybeTable table f -> m (HMaybeTable table g)
forall (c :: Spec -> Constraint).
HConstrainTable (HMaybeTable table) c =>
HMaybeTable table (Dict c)
forall (context :: HContext).
(forall (spec :: Spec).
 HField (HMaybeTable table) spec -> context spec)
-> HMaybeTable table context
forall (context :: HContext) (spec :: Spec).
HMaybeTable table context
-> HField (HMaybeTable table) spec -> context spec
forall (table :: HTable). HTable table => HMaybeTable table SSpec
forall (table :: HTable) (m :: * -> *) (f :: HContext)
       (g :: HContext).
(HTable table, Apply m) =>
(forall (spec :: Spec). f spec -> m (g spec))
-> HMaybeTable table f -> m (HMaybeTable table g)
forall (table :: HTable) (c :: Spec -> Constraint).
(HTable table, HConstrainTable (HMaybeTable table) c) =>
HMaybeTable table (Dict c)
forall (table :: HTable) (context :: HContext).
HTable table =>
(forall (spec :: Spec).
 HField (HMaybeTable table) spec -> context spec)
-> HMaybeTable table context
forall (table :: HTable) (context :: HContext) (spec :: Spec).
HTable table =>
HMaybeTable table context
-> HField (HMaybeTable table) spec -> context spec
forall (t :: HTable).
(forall (context :: HContext) (spec :: Spec).
 t context -> HField t spec -> context spec)
-> (forall (context :: HContext).
    (forall (spec :: Spec). HField t spec -> context spec)
    -> t context)
-> (forall (m :: * -> *) (f :: HContext) (g :: HContext).
    Apply m =>
    (forall (spec :: Spec). f spec -> m (g spec)) -> t f -> m (t g))
-> (forall (c :: Spec -> Constraint).
    HConstrainTable t c =>
    t (Dict c))
-> t SSpec
-> HTable t
hspecs :: HMaybeTable table SSpec
$chspecs :: forall (table :: HTable). HTable table => HMaybeTable table SSpec
hdicts :: HMaybeTable table (Dict c)
$chdicts :: forall (table :: HTable) (c :: Spec -> Constraint).
(HTable table, HConstrainTable (HMaybeTable table) c) =>
HMaybeTable table (Dict c)
htraverse :: (forall (spec :: Spec). f spec -> m (g spec))
-> HMaybeTable table f -> m (HMaybeTable table g)
$chtraverse :: forall (table :: HTable) (m :: * -> *) (f :: HContext)
       (g :: HContext).
(HTable table, Apply m) =>
(forall (spec :: Spec). f spec -> m (g spec))
-> HMaybeTable table f -> m (HMaybeTable table g)
htabulate :: (forall (spec :: Spec).
 HField (HMaybeTable table) spec -> context spec)
-> HMaybeTable table context
$chtabulate :: forall (table :: HTable) (context :: HContext).
HTable table =>
(forall (spec :: Spec).
 HField (HMaybeTable table) spec -> context spec)
-> HMaybeTable table context
hfield :: HMaybeTable table context
-> HField (HMaybeTable table) spec -> context spec
$chfield :: forall (table :: HTable) (context :: HContext) (spec :: Spec).
HTable table =>
HMaybeTable table context
-> HField (HMaybeTable table) spec -> context spec
HTable