Skip to content

Define Rel8.Table.Maybe.projectMaybe and export it #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Rel8.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module Rel8

-- ** @MaybeTable@
, MaybeTable
, maybeTable, ($?), nothingTable, justTable
, maybeTable, ($?), projectMaybe, nothingTable, justTable
, isNothingTable, isJustTable
, fromMaybeTable
, optional
Expand Down
12 changes: 12 additions & 0 deletions src/Rel8/Table/Maybe.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module Rel8.Table.Maybe
, isNothingTable, isJustTable
, fromMaybeTable
, ($?)
, projectMaybe
, nameMaybeTable
, makeMaybeTable
, unsafeFromJustTable
Expand Down Expand Up @@ -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'.
Expand Down