Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Recursiveness be where
- newtype With be (db :: (Type -> Type) -> Type) a = With {
- runWith :: WriterT (Recursiveness be, [BeamSql99BackendCTESyntax be]) (State Int) a
- data QAnyScope
- data ReusableQ be db res where
- reusableForCTE :: forall be res db. (ThreadRewritable QAnyScope res, Projectible be res, BeamSqlBackend be) => Text -> ReusableQ be db res
- selecting :: forall res be db. (BeamSql99CommonTableExpressionBackend be, HasQBuilder be, Projectible be res, ThreadRewritable QAnyScope res) => Q be db QAnyScope res -> With be db (ReusableQ be db res)
- reuse :: forall s be db res. ReusableQ be db res -> Q be db s (WithRewrittenThread QAnyScope s res)
Documentation
data Recursiveness be where Source #
Nonrecursive :: Recursiveness be | |
Recursive :: IsSql99RecursiveCommonTableExpressionSelectSyntax (BeamSqlBackendSelectSyntax be) => Recursiveness be |
Instances
Semigroup (Recursiveness be) Source # | |
Defined in Database.Beam.Query.CTE (<>) :: Recursiveness be -> Recursiveness be -> Recursiveness be # sconcat :: NonEmpty (Recursiveness be) -> Recursiveness be # stimes :: Integral b => b -> Recursiveness be -> Recursiveness be # | |
Monoid (Recursiveness be) Source # | |
Defined in Database.Beam.Query.CTE mempty :: Recursiveness be # mappend :: Recursiveness be -> Recursiveness be -> Recursiveness be # mconcat :: [Recursiveness be] -> Recursiveness be # |
newtype With be (db :: (Type -> Type) -> Type) a Source #
Monad in which SELECT
statements can be made (via selecting
)
and bound to result names for re-use later. This has the advantage
of only computing each result once. In SQL, this is translated to a
common table expression.
Once introduced, results can be re-used in future queries with reuse
.
With
is also a member of MonadFix
for backends that support
recursive CTEs. In this case, you can use mdo
or rec
notation
(with RecursiveDo
enabled) to bind result values (again, using
reuse
) even before they're introduced.
See further documentation here.
With | |
|
Instances
Monad (With be db) Source # | |
Functor (With be db) Source # | |
IsSql99RecursiveCommonTableExpressionSelectSyntax (BeamSqlBackendSelectSyntax be) => MonadFix (With be db) Source # | |
Defined in Database.Beam.Query.CTE | |
Applicative (With be db) Source # | |
Defined in Database.Beam.Query.CTE |
reusableForCTE :: forall be res db. (ThreadRewritable QAnyScope res, Projectible be res, BeamSqlBackend be) => Text -> ReusableQ be db res Source #
selecting :: forall res be db. (BeamSql99CommonTableExpressionBackend be, HasQBuilder be, Projectible be res, ThreadRewritable QAnyScope res) => Q be db QAnyScope res -> With be db (ReusableQ be db res) Source #
Introduce the result of a query as a result in a common table
expression. The returned value can be used in future queries by
applying reuse
.