{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
module Opaleye.Field (
Field_,
Field,
FieldNullable,
Nullability(..),
unsafeCoerceField,
Opaleye.Field.null,
isNull,
matchNullable,
fromNullable,
toNullable,
maybeToNullable,
) where
import qualified Opaleye.Column as C
import qualified Opaleye.Internal.PGTypesExternal as T
type family Field_ (a :: Nullability) b
data Nullability = NonNullable | Nullable
type instance Field_ 'NonNullable a = C.Column a
type instance Field_ 'Nullable a = C.Column (C.Nullable a)
type FieldNullable a = Field_ 'Nullable a
type Field a = Field_ 'NonNullable a
null :: FieldNullable a
null :: FieldNullable a
null = FieldNullable a
forall a. Column (Nullable a)
C.null
isNull :: FieldNullable a -> Field T.PGBool
isNull :: FieldNullable a -> Field PGBool
isNull = FieldNullable a -> Field PGBool
forall a. Column (Nullable a) -> Column PGBool
C.isNull
matchNullable :: Field_ 'NonNullable b
-> (Field_ 'NonNullable a -> Field_ 'NonNullable b)
-> Field_ 'Nullable a
-> Field_ 'NonNullable b
matchNullable :: Field_ 'NonNullable b
-> (Field_ 'NonNullable a -> Field_ 'NonNullable b)
-> Field_ 'Nullable a
-> Field_ 'NonNullable b
matchNullable = Field_ 'NonNullable b
-> (Field_ 'NonNullable a -> Field_ 'NonNullable b)
-> Field_ 'Nullable a
-> Field_ 'NonNullable b
forall b a.
Column b
-> (Column a -> Column b) -> Column (Nullable a) -> Column b
C.matchNullable
fromNullable :: Field_ 'NonNullable a
-> Field_ 'Nullable a
-> Field_ 'NonNullable a
fromNullable :: Field_ 'NonNullable a
-> Field_ 'Nullable a -> Field_ 'NonNullable a
fromNullable = Field_ 'NonNullable a
-> Field_ 'Nullable a -> Field_ 'NonNullable a
forall a. Column a -> Column (Nullable a) -> Column a
C.fromNullable
toNullable :: Field_ 'NonNullable a -> Field_ 'Nullable a
toNullable :: Field_ 'NonNullable a -> Field_ 'Nullable a
toNullable = Field_ 'NonNullable a -> Field_ 'Nullable a
forall a b. Column a -> Column b
C.unsafeCoerceColumn
maybeToNullable :: Maybe (Field_ 'NonNullable a)
-> Field_ 'Nullable a
maybeToNullable :: Maybe (Field_ 'NonNullable a) -> Field_ 'Nullable a
maybeToNullable = Maybe (Field_ 'NonNullable a) -> Field_ 'Nullable a
forall a. Maybe (Column a) -> Column (Nullable a)
C.maybeToNullable
unsafeCoerceField :: C.Column a -> C.Column b
unsafeCoerceField :: Column a -> Column b
unsafeCoerceField = Column a -> Column b
forall a b. Column a -> Column b
C.unsafeCoerceColumn