{-# language FlexibleContexts #-}
{-# language NamedFieldPuns #-}
{-# language TypeFamilies #-}
module Rel8.Table.Undefined
( undefined
)
where
import Prelude hiding ( undefined )
import Rel8.Expr ( Expr, Col( E ) )
import Rel8.Expr.Null ( snull, unsafeUnnullify )
import Rel8.Schema.HTable ( htabulate, hfield, hspecs )
import Rel8.Schema.Null ( Nullity( Null, NotNull ) )
import Rel8.Schema.Spec ( SSpec(..) )
import Rel8.Table ( Table, fromColumns )
undefined :: Table Expr a => a
undefined :: a
undefined = Columns a (Col Expr) -> a
forall (context :: Context) a.
Table context a =>
Columns a (Col context) -> a
fromColumns (Columns a (Col Expr) -> a) -> Columns a (Col Expr) -> a
forall a b. (a -> b) -> a -> b
$ (forall (spec :: Spec). HField (Columns a) spec -> Col Expr spec)
-> Columns a (Col Expr)
forall (t :: HTable) (context :: HContext).
HTable t =>
(forall (spec :: Spec). HField t spec -> context spec) -> t context
htabulate ((forall (spec :: Spec). HField (Columns a) spec -> Col Expr spec)
-> Columns a (Col Expr))
-> (forall (spec :: Spec).
HField (Columns a) spec -> Col Expr spec)
-> Columns a (Col Expr)
forall a b. (a -> b) -> a -> b
$ \HField (Columns a) spec
field -> case Columns a SSpec -> HField (Columns a) spec -> SSpec spec
forall (t :: HTable) (context :: HContext) (spec :: Spec).
HTable t =>
t context -> HField t spec -> context spec
hfield Columns a SSpec
forall (t :: HTable). HTable t => t SSpec
hspecs HField (Columns a) spec
field of
SSpec {Nullity a
nullity :: forall (labels :: Labels) (necessity :: Necessity) a.
SSpec ('Spec labels necessity a) -> Nullity a
nullity :: Nullity a
nullity, TypeInformation (Unnullify a)
info :: forall (labels :: Labels) (necessity :: Necessity) a.
SSpec ('Spec labels necessity a) -> TypeInformation (Unnullify a)
info :: TypeInformation (Unnullify a)
info} -> case Nullity a
nullity of
Nullity a
Null -> Expr (Maybe a) -> Col Expr ('Spec labels necessity (Maybe a))
forall a (labels :: Labels) (necessity :: Necessity).
Expr a -> Col Expr ('Spec labels necessity a)
E (TypeInformation a -> Expr (Maybe a)
forall a. TypeInformation a -> Expr (Maybe a)
snull TypeInformation a
TypeInformation (Unnullify a)
info)
Nullity a
NotNull -> Expr a -> Col Expr ('Spec labels necessity a)
forall a (labels :: Labels) (necessity :: Necessity).
Expr a -> Col Expr ('Spec labels necessity a)
E (Expr (Maybe a) -> Expr a
forall a. Expr (Maybe a) -> Expr a
unsafeUnnullify (TypeInformation a -> Expr (Maybe a)
forall a. TypeInformation a -> Expr (Maybe a)
snull TypeInformation a
TypeInformation (Unnullify a)
info))