beam-core-0.9.2.1: Type-safe, feature-complete SQL query and manipulation interface for Haskell
Safe Haskell None
Language Haskell2010

Database.Beam.Query.CTE

Synopsis

Documentation

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 .

Instances

Instances details
Monad ( With be db) Source #
Instance details

Defined in Database.Beam.Query.CTE

Methods

(>>=) :: With be db a -> (a -> With be db b) -> With be db b Source #

(>>) :: With be db a -> With be db b -> With be db b Source #

return :: a -> With be db a Source #

Functor ( With be db) Source #
Instance details

Defined in Database.Beam.Query.CTE

Methods

fmap :: (a -> b) -> With be db a -> With be db b Source #

(<$) :: a -> With be db b -> With be db a Source #

IsSql99RecursiveCommonTableExpressionSelectSyntax ( BeamSqlBackendSelectSyntax be) => MonadFix ( With be db) Source #
Instance details

Defined in Database.Beam.Query.CTE

Methods

mfix :: (a -> With be db a) -> With be db a Source #

Applicative ( With be db) Source #
Instance details

Defined in Database.Beam.Query.CTE

Methods

pure :: a -> With be db a Source #

(<*>) :: With be db (a -> b) -> With be db a -> With be db b Source #

liftA2 :: (a -> b -> c) -> With be db a -> With be db b -> With be db c Source #

(*>) :: With be db a -> With be db b -> With be db b Source #

(<*) :: With be db a -> With be db b -> With be db a Source #

data ReusableQ be db res where Source #

Query results that have been introduced into a common table expression via selecting that can be used in future queries with reuse .

Constructors

ReusableQ :: Proxy res -> ( forall s. Proxy s -> Q be db s ( WithRewrittenThread QAnyScope s res)) -> 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) 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 .

reuse :: forall s be db res. ReusableQ be db res -> Q be db s ( WithRewrittenThread QAnyScope s res) Source #

Introduces the result of a previous selecting (a CTE) into a new query