Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Opaleye.Internal.MaybeFields
Contents
Synopsis
- data MaybeFields fields = MaybeFields {}
- nothingFields :: Default Nullspec a a => MaybeFields a
- nothingFieldsOfTypeOf :: a -> MaybeFields a
- justFields :: a -> MaybeFields a
- maybeFields :: Default IfPP b b => b -> (a -> b) -> MaybeFields a -> b
- matchMaybe :: Default IfPP b b => MaybeFields a -> (Maybe a -> b) -> b
- fromMaybeFields :: Default IfPP b b => b -> MaybeFields b -> b
- maybeFieldsToSelect :: SelectArr (MaybeFields a) a
- catMaybeFields :: SelectArr i (MaybeFields a) -> SelectArr i a
- maybeFieldsExplicit :: IfPP b b' -> b -> (a -> b) -> MaybeFields a -> b'
- fromMaybeFieldsExplicit :: IfPP b b -> b -> MaybeFields b -> b
- nothingFieldsExplicit :: Nullspec a b -> MaybeFields b
- traverseMaybeFields :: SelectArr a b -> SelectArr (MaybeFields a) (MaybeFields b)
- optional :: SelectArr i a -> SelectArr i (MaybeFields a)
- optionalInternal :: (FieldNullable SqlBool -> a -> r) -> Select a -> Select r
- lateralLeftJoinOptional :: SelectArr i a -> SelectArr i b -> ((a, b) -> Field SqlBool) -> SelectArr i (a, MaybeFields b)
- optionalRestrictOptional :: Select a -> SelectArr (a -> Field SqlBool) (MaybeFields a)
- nullableToMaybeFields :: FieldNullable a -> MaybeFields (Field a)
- maybeFieldsToNullable :: MaybeFields (Field a) -> FieldNullable a
- fromFieldsMaybeFields :: FromFields fields haskells -> FromFields (MaybeFields fields) (Maybe haskells)
- productProfunctorMaybeFields :: ProductProfunctor p => p (Field SqlBool) (Field SqlBool) -> p a b -> p (MaybeFields a) (MaybeFields b)
- nullspecMaybeFields :: Nullspec a b -> Nullspec (MaybeFields a) (MaybeFields b)
- unpackspecMaybeFields :: Unpackspec a b -> Unpackspec (MaybeFields a) (MaybeFields b)
- valuesspecMaybeFields :: Valuesspec a b -> Valuesspec (MaybeFields a) (MaybeFields b)
- toFieldsMaybeFields :: Nullspec a b -> ToFields a b -> ToFields (Maybe a) (MaybeFields b)
- ifPPMaybeFields :: IfPP a b -> IfPP (MaybeFields a) (MaybeFields b)
- eqPPMaybeFields :: EqPP a b -> EqPP (MaybeFields a) (MaybeFields b)
- unWithNulls :: ProductProfunctor p => p (Field SqlBool) (Field SqlBool) -> WithNulls p a b -> p (MaybeFields a) (MaybeFields b)
- newtype WithNulls p a b = WithNulls (p (MaybeFields a) b)
- mapMaybeFieldsWithNulls :: ProductProfunctor p => p (Field SqlBool) (Field SqlBool) -> WithNulls p a b -> WithNulls p (MaybeFields a) (MaybeFields b)
- withNullsField :: (IsSqlType a, Profunctor p) => p (Field_ n a) (Field_ n a) -> WithNulls p (Field_ n a) (Field_ n a)
- binaryspecMaybeFields :: WithNulls Binaryspec a b -> Binaryspec (MaybeFields a) (MaybeFields b)
Documentation
data MaybeFields fields Source #
The Opaleye analogue of Maybe
. A value of type
MaybeFields a
either contains a value of type a
, or it contains
nothing.
Constructors
MaybeFields | |
Instances
nothingFields :: Default Nullspec a a => MaybeFields a Source #
The Opaleye analogue of Nothing
.
nothingFieldsOfTypeOf :: a -> MaybeFields a Source #
justFields :: a -> MaybeFields a Source #
maybeFields :: Default IfPP b b => b -> (a -> b) -> MaybeFields a -> b Source #
The Opaleye analogue of maybe
matchMaybe :: Default IfPP b b => MaybeFields a -> (Maybe a -> b) -> b Source #
Use a Haskell \case
expression to pattern match on a
MaybeFields
.
example :: MaybeFields (Field SqlInt4) -> Field SqlInt4 example mf = matchMaybe mf $ \case Nothing -> 0 Just x -> x * 100
fromMaybeFields :: Default IfPP b b => b -> MaybeFields b -> b Source #
The Opaleye analogue of fromMaybe
maybeFieldsToSelect :: SelectArr (MaybeFields a) a Source #
The Opaleye analogue of maybeToList
. Unless you are
using arrow notation you'll probably find catMaybeFields
easier
to use.
catMaybeFields :: SelectArr i (MaybeFields a) -> SelectArr i a Source #
The Opaleye analogue of catMaybes
. Most commonly
you will want to use this at type
catMaybeFields :: Select (MaybeFields a) -> Select a
maybeFieldsExplicit :: IfPP b b' -> b -> (a -> b) -> MaybeFields a -> b' Source #
fromMaybeFieldsExplicit :: IfPP b b -> b -> MaybeFields b -> b Source #
nothingFieldsExplicit :: Nullspec a b -> MaybeFields b Source #
traverseMaybeFields :: SelectArr a b -> SelectArr (MaybeFields a) (MaybeFields b) Source #
optionalInternal :: (FieldNullable SqlBool -> a -> r) -> Select a -> Select r Source #
lateralLeftJoinOptional :: SelectArr i a -> SelectArr i b -> ((a, b) -> Field SqlBool) -> SelectArr i (a, MaybeFields b) Source #
An example to demonstrate how the functionality of (lateral)
LEFT JOIN
can be recovered using optional
.
optionalRestrictOptional :: Select a -> SelectArr (a -> Field SqlBool) (MaybeFields a) Source #
An example to demonstrate how the functionality of
optionalRestrict
can be recovered using optional
.
nullableToMaybeFields :: FieldNullable a -> MaybeFields (Field a) Source #
Convert NULL
to nothingFields
and non-NULL
to a justFields
maybeFieldsToNullable :: MaybeFields (Field a) -> FieldNullable a Source #
Convert nothingFields
to NULL
to a justFields
to non-NULL
fromFieldsMaybeFields :: FromFields fields haskells -> FromFields (MaybeFields fields) (Maybe haskells) Source #
productProfunctorMaybeFields :: ProductProfunctor p => p (Field SqlBool) (Field SqlBool) -> p a b -> p (MaybeFields a) (MaybeFields b) Source #
This is not safe in general because it relies on p not doing
anything observable with the a
s if mfPresent
is false. In
particular, it won't work for
Distinctspec
because it does indeed
look at the mfFields
to check distinctness.
nullspecMaybeFields :: Nullspec a b -> Nullspec (MaybeFields a) (MaybeFields b) Source #
unpackspecMaybeFields :: Unpackspec a b -> Unpackspec (MaybeFields a) (MaybeFields b) Source #
valuesspecMaybeFields :: Valuesspec a b -> Valuesspec (MaybeFields a) (MaybeFields b) Source #
toFieldsMaybeFields :: Nullspec a b -> ToFields a b -> ToFields (Maybe a) (MaybeFields b) Source #
ifPPMaybeFields :: IfPP a b -> IfPP (MaybeFields a) (MaybeFields b) Source #
eqPPMaybeFields :: EqPP a b -> EqPP (MaybeFields a) (MaybeFields b) Source #
unWithNulls :: ProductProfunctor p => p (Field SqlBool) (Field SqlBool) -> WithNulls p a b -> p (MaybeFields a) (MaybeFields b) Source #
This is only safe if d is OK with having nulls passed through it when they claim to be non-null.
newtype WithNulls p a b Source #
Constructors
WithNulls (p (MaybeFields a) b) |
Instances
mapMaybeFieldsWithNulls :: ProductProfunctor p => p (Field SqlBool) (Field SqlBool) -> WithNulls p a b -> WithNulls p (MaybeFields a) (MaybeFields b) Source #
This is only safe if b
is OK with having nulls passed through it
when they claim to be non-null.
withNullsField :: (IsSqlType a, Profunctor p) => p (Field_ n a) (Field_ n a) -> WithNulls p (Field_ n a) (Field_ n a) Source #
This is only safe if col
is OK with having nulls passed through it
when they claim to be non-null.
binaryspecMaybeFields :: WithNulls Binaryspec a b -> Binaryspec (MaybeFields a) (MaybeFields b) Source #
Orphan instances
(Default (Inferrable ToFields) a b, Default Nullspec a b, MaybeFields b ~ maybeFields_b) => Default (Inferrable ToFields) (Maybe a) maybeFields_b Source # | |
Methods def :: Inferrable ToFields (Maybe a) maybeFields_b # |