diff --git a/src/Rel8.hs b/src/Rel8.hs index 16a05ec8..2c1d2feb 100644 --- a/src/Rel8.hs +++ b/src/Rel8.hs @@ -60,7 +60,7 @@ module Rel8 -- ** @MaybeTable@ , MaybeTable - , maybeTable, ($?), nothingTable, justTable + , maybeTable, ($?), projectMaybe, nothingTable, justTable , isNothingTable, isJustTable , fromMaybeTable , optional diff --git a/src/Rel8/Table/Maybe.hs b/src/Rel8/Table/Maybe.hs index 2b344289..208d2a60 100644 --- a/src/Rel8/Table/Maybe.hs +++ b/src/Rel8/Table/Maybe.hs @@ -18,6 +18,7 @@ module Rel8.Table.Maybe , isNothingTable, isJustTable , fromMaybeTable , ($?) + , projectMaybe , nameMaybeTable , makeMaybeTable , unsafeFromJustTable @@ -232,6 +233,17 @@ f $? ma@(MaybeTable _ a) = case nullable @b of infixl 4 $? +-- | If a @'MaybeTable' 'Expr'@ contains a single column, it can be +-- projected into a @'Expr' Maybe@. This is a simple application of +-- @('$?')@, provided for readability. +-- +-- @ +-- projectMaybe = (id '$?') +-- @ +projectMaybe :: DBType a => MaybeTable Expr (Expr a) -> Expr (Maybe a) +projectMaybe = (id $?) + + -- | Construct a 'MaybeTable' in the 'Name' context. This can be useful if you -- have a 'MaybeTable' that you are storing in a table and need to construct a -- 'TableSchema'.