beam-core-0.7.2.0: Type-safe, feature-complete SQL query and manipulation interface for Haskell

Safe HaskellNone
LanguageHaskell2010

Database.Beam.Query.Types

Synopsis

Documentation

data Q syntax (db :: (* -> *) -> *) s a Source #

The type of queries over the database db returning results of type a. The s argument is a threading argument meant to restrict cross-usage of QExprs. syntax represents the SQL syntax that this query is building.

Instances

Monad (Q syntax db s) Source # 

Methods

(>>=) :: Q syntax db s a -> (a -> Q syntax db s b) -> Q syntax db s b #

(>>) :: Q syntax db s a -> Q syntax db s b -> Q syntax db s b #

return :: a -> Q syntax db s a #

fail :: String -> Q syntax db s a #

Functor (Q syntax db s) Source # 

Methods

fmap :: (a -> b) -> Q syntax db s a -> Q syntax db s b #

(<$) :: a -> Q syntax db s b -> Q syntax db s a #

Applicative (Q syntax db s) Source # 

Methods

pure :: a -> Q syntax db s a #

(<*>) :: Q syntax db s (a -> b) -> Q syntax db s a -> Q syntax db s b #

liftA2 :: (a -> b -> c) -> Q syntax db s a -> Q syntax db s b -> Q syntax db s c #

(*>) :: Q syntax db s a -> Q syntax db s b -> Q syntax db s b #

(<*) :: Q syntax db s a -> Q syntax db s b -> Q syntax db s a #

type QExpr = QGenExpr QValueContext Source #

QExprs represent expressions not containing aggregates.

newtype QGenExpr context syntax s t Source #

The type of lifted beam expressions that will yield the haskell type t.

context is a type-level representation of the types of expressions this can contain. For example, QAggregateContext represents expressions that may contain aggregates, and QWindowingContext represents expressions that may contain OVER.

syntax is the expression syntax being built (usually a type that implements IsSql92ExpressionSyntax at least, but not always).

s is a state threading parameter that prevents QExprs from incompatible sources to be combined. For example, this is used to prevent monadic joins from depending on the result of previous joins (so-called LATERAL joins).

Constructors

QExpr (TablePrefix -> syntax) 

Instances

(Beamable t, contextPredicate context) => ProjectibleWithPredicate contextPredicate syntax (t (Nullable (QGenExpr context syntax s))) Source # 

Methods

project' :: Monad m => Proxy (* -> Constraint) contextPredicate -> (forall context0. contextPredicate context0 => Proxy * context0 -> WithExprContext syntax -> m (WithExprContext syntax)) -> t (Nullable (QGenExpr context syntax s)) -> m (t (Nullable (QGenExpr context syntax s))) Source #

(Beamable t, contextPredicate context) => ProjectibleWithPredicate contextPredicate syntax (t (QGenExpr context syntax s)) Source # 

Methods

project' :: Monad m => Proxy (* -> Constraint) contextPredicate -> (forall context0. contextPredicate context0 => Proxy * context0 -> WithExprContext syntax -> m (WithExprContext syntax)) -> t (QGenExpr context syntax s) -> m (t (QGenExpr context syntax s)) Source #

contextPredicate context => ProjectibleWithPredicate contextPredicate syntax (QGenExpr context syntax s a) Source # 

Methods

project' :: Monad m => Proxy (* -> Constraint) contextPredicate -> (forall context0. contextPredicate context0 => Proxy * context0 -> WithExprContext syntax -> m (WithExprContext syntax)) -> QGenExpr context syntax s a -> m (QGenExpr context syntax s a) Source #

Beamable tbl => ThreadRewritable s (tbl (Nullable (QGenExpr ctxt syntax s))) Source # 

Associated Types

type WithRewrittenThread s s' (tbl (Nullable (QGenExpr ctxt syntax s))) :: * Source #

Methods

rewriteThread :: Proxy * s' -> tbl (Nullable (QGenExpr ctxt syntax s)) -> WithRewrittenThread s s' (tbl (Nullable (QGenExpr ctxt syntax s))) Source #

Beamable tbl => ThreadRewritable s (tbl (QGenExpr ctxt syntax s)) Source # 

Associated Types

type WithRewrittenThread s s' (tbl (QGenExpr ctxt syntax s)) :: * Source #

Methods

rewriteThread :: Proxy * s' -> tbl (QGenExpr ctxt syntax s) -> WithRewrittenThread s s' (tbl (QGenExpr ctxt syntax s)) Source #

(IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) Bool, Beamable t) => SqlDeconstructMaybe syntax (t (Nullable (QGenExpr ctxt syntax s))) (t (QGenExpr ctxt syntax s)) s Source # 

Methods

isJust_ :: t (Nullable (QGenExpr ctxt syntax s)) -> QGenExpr ctxt syntax s Bool Source #

isNothing_ :: t (Nullable (QGenExpr ctxt syntax s)) -> QGenExpr ctxt syntax s Bool Source #

maybe_ :: QGenExpr ctxt syntax s y -> (t (QGenExpr ctxt syntax s) -> QGenExpr ctxt syntax s y) -> t (Nullable (QGenExpr ctxt syntax s)) -> QGenExpr ctxt syntax s y Source #

SqlOrderable syntax (QOrd syntax s a) Source # 

Methods

makeSQLOrdering :: QOrd syntax s a -> [WithExprContext syntax]

ThreadRewritable s (QGenExpr ctxt syntax s a) Source # 

Associated Types

type WithRewrittenThread s s' (QGenExpr ctxt syntax s a) :: * Source #

Methods

rewriteThread :: Proxy * s' -> QGenExpr ctxt syntax s a -> WithRewrittenThread s s' (QGenExpr ctxt syntax s a) Source #

IsSql92ExpressionSyntax syntax => SqlDeconstructMaybe syntax (QGenExpr ctxt syntax s (Maybe x)) (QGenExpr ctxt syntax s x) s Source # 

Methods

isJust_ :: QGenExpr ctxt syntax s (Maybe x) -> QGenExpr ctxt syntax s Bool Source #

isNothing_ :: QGenExpr ctxt syntax s (Maybe x) -> QGenExpr ctxt syntax s Bool Source #

maybe_ :: QGenExpr ctxt syntax s y -> (QGenExpr ctxt syntax s x -> QGenExpr ctxt syntax s y) -> QGenExpr ctxt syntax s (Maybe x) -> QGenExpr ctxt syntax s y Source #

Beamable tbl => ContextRewritable (tbl (Nullable (QGenExpr old syntax s))) Source # 

Associated Types

type WithRewrittenContext (tbl (Nullable (QGenExpr old syntax s))) ctxt :: * Source #

Methods

rewriteContext :: Proxy * ctxt -> tbl (Nullable (QGenExpr old syntax s)) -> WithRewrittenContext (tbl (Nullable (QGenExpr old syntax s))) ctxt Source #

Beamable tbl => ContextRewritable (tbl (QGenExpr old syntax s)) Source # 

Associated Types

type WithRewrittenContext (tbl (QGenExpr old syntax s)) ctxt :: * Source #

Methods

rewriteContext :: Proxy * ctxt -> tbl (QGenExpr old syntax s) -> WithRewrittenContext (tbl (QGenExpr old syntax s)) ctxt Source #

(Beamable table, IsSql92ExpressionSyntax syntax, FieldsFulfillConstraintNullable (HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax)) table) => SqlValable (table (Nullable (QGenExpr ctxt syntax s))) Source # 

Methods

val_ :: HaskellLiteralForQExpr (table (Nullable (QGenExpr ctxt syntax s))) -> table (Nullable (QGenExpr ctxt syntax s)) Source #

(Beamable table, IsSql92ExpressionSyntax syntax, FieldsFulfillConstraint (HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax)) table) => SqlValable (table (QGenExpr ctxt syntax s)) Source # 

Methods

val_ :: HaskellLiteralForQExpr (table (QGenExpr ctxt syntax s)) -> table (QGenExpr ctxt syntax s) Source #

(Table t, IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) SqlNull) => SqlJustable (t (QExpr syntax s)) (t (Nullable (QExpr syntax s))) Source # 

Methods

just_ :: t (QExpr syntax s) -> t (Nullable (QExpr syntax s)) Source #

nothing_ :: t (Nullable (QExpr syntax s)) Source #

Beamable tbl => QGroupable (tbl (QExpr expr s)) (tbl (QGroupExpr expr s)) Source #

group_ for any Beamable type. Adds every field in the type to the grouping key. This is the equivalent of including the grouping expression of each field in the type as part of the aggregate projection

Methods

group_ :: tbl (QExpr expr s) -> tbl (QGroupExpr expr s) Source #

(Table t, IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) SqlNull) => SqlJustable (PrimaryKey t (QExpr syntax s)) (PrimaryKey t (Nullable (QExpr syntax s))) Source # 

Methods

just_ :: PrimaryKey t (QExpr syntax s) -> PrimaryKey t (Nullable (QExpr syntax s)) Source #

nothing_ :: PrimaryKey t (Nullable (QExpr syntax s)) Source #

(IsSql92ExpressionSyntax syntax, FieldsFulfillConstraintNullable (HasSqlEqualityCheck syntax) tbl, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) Bool, Beamable tbl) => SqlEq (QGenExpr context syntax s) (tbl (Nullable (QGenExpr context syntax s))) Source # 

Methods

(==.) :: tbl (Nullable (QGenExpr context syntax s)) -> tbl (Nullable (QGenExpr context syntax s)) -> QGenExpr context syntax s Bool Source #

(/=.) :: tbl (Nullable (QGenExpr context syntax s)) -> tbl (Nullable (QGenExpr context syntax s)) -> QGenExpr context syntax s Bool Source #

(==?.) :: tbl (Nullable (QGenExpr context syntax s)) -> tbl (Nullable (QGenExpr context syntax s)) -> QGenExpr context syntax s SqlBool Source #

(/=?.) :: tbl (Nullable (QGenExpr context syntax s)) -> tbl (Nullable (QGenExpr context syntax s)) -> QGenExpr context syntax s SqlBool Source #

(IsSql92ExpressionSyntax syntax, FieldsFulfillConstraint (HasSqlEqualityCheck syntax) tbl, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) Bool, Beamable tbl) => SqlEq (QGenExpr context syntax s) (tbl (QGenExpr context syntax s)) Source #

Compare two arbitrary Beamable types containing QGenExprs for equality.

Methods

(==.) :: tbl (QGenExpr context syntax s) -> tbl (QGenExpr context syntax s) -> QGenExpr context syntax s Bool Source #

(/=.) :: tbl (QGenExpr context syntax s) -> tbl (QGenExpr context syntax s) -> QGenExpr context syntax s Bool Source #

(==?.) :: tbl (QGenExpr context syntax s) -> tbl (QGenExpr context syntax s) -> QGenExpr context syntax s SqlBool Source #

(/=?.) :: tbl (QGenExpr context syntax s) -> tbl (QGenExpr context syntax s) -> QGenExpr context syntax s SqlBool Source #

(IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) SqlNull) => SqlJustable (QExpr syntax s a) (QExpr syntax s (Maybe a)) Source # 

Methods

just_ :: QExpr syntax s a -> QExpr syntax s (Maybe a) Source #

nothing_ :: QExpr syntax s (Maybe a) Source #

QGroupable (QExpr expr s a) (QGroupExpr expr s a) Source #

group_ for simple value expressions.

Methods

group_ :: QExpr expr s a -> QGroupExpr expr s a Source #

IsSql92ExpressionSyntax syntax => SqlOrdQuantified (QGenExpr context syntax s) (QQuantified syntax s a) (QGenExpr context syntax s a) Source # 

Methods

(<*.) :: QGenExpr context syntax s a -> QQuantified syntax s a -> QGenExpr context syntax s Bool Source #

(>*.) :: QGenExpr context syntax s a -> QQuantified syntax s a -> QGenExpr context syntax s Bool Source #

(<=*.) :: QGenExpr context syntax s a -> QQuantified syntax s a -> QGenExpr context syntax s Bool Source #

(>=*.) :: QGenExpr context syntax s a -> QQuantified syntax s a -> QGenExpr context syntax s Bool Source #

(IsSql92ExpressionSyntax syntax, HasSqlQuantifiedEqualityCheck syntax a) => SqlEqQuantified (QGenExpr context syntax s) (QQuantified syntax s a) (QGenExpr context syntax s a) Source #

Two arbitrary expressions can be quantifiably compared for equality.

Methods

(==*.) :: QGenExpr context syntax s a -> QQuantified syntax s a -> QGenExpr context syntax s SqlBool Source #

(/=*.) :: QGenExpr context syntax s a -> QQuantified syntax s a -> QGenExpr context syntax s SqlBool Source #

Retaggable (QGenExpr ctxt expr s) (QGenExpr ctxt expr s t) Source # 

Associated Types

type Retag (tag :: (* -> *) -> * -> *) (QGenExpr ctxt expr s t) :: * Source #

Methods

retag :: (forall a. Columnar' (QGenExpr ctxt expr s) a -> Columnar' (tag (QGenExpr ctxt expr s)) a) -> QGenExpr ctxt expr s t -> Retag tag (QGenExpr ctxt expr s t) Source #

IsSql92ExpressionSyntax syntax => SqlOrd (QGenExpr context syntax s) (QGenExpr context syntax s a) Source # 

Methods

(<.) :: QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax s Bool Source #

(>.) :: QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax s Bool Source #

(<=.) :: QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax s Bool Source #

(>=.) :: QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax s Bool Source #

(IsSql92ExpressionSyntax syntax, HasSqlEqualityCheck syntax a) => SqlEq (QGenExpr context syntax s) (QGenExpr context syntax s a) Source #

Compare two arbitrary expressions (of the same type) for equality

Methods

(==.) :: QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax s Bool Source #

(/=.) :: QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax s Bool Source #

(==?.) :: QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax s SqlBool Source #

(/=?.) :: QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax s SqlBool Source #

Eq syntax => Eq (QGenExpr context syntax s t) Source # 

Methods

(==) :: QGenExpr context syntax s t -> QGenExpr context syntax s t -> Bool #

(/=) :: QGenExpr context syntax s t -> QGenExpr context syntax s t -> Bool #

(Fractional a, IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) a) => Fractional (QGenExpr context syntax s a) Source # 

Methods

(/) :: QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax s a #

recip :: QGenExpr context syntax s a -> QGenExpr context syntax s a #

fromRational :: Rational -> QGenExpr context syntax s a #

(Num a, IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) a) => Num (QGenExpr context syntax s a) Source # 

Methods

(+) :: QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax s a #

(-) :: QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax s a #

(*) :: QGenExpr context syntax s a -> QGenExpr context syntax s a -> QGenExpr context syntax s a #

negate :: QGenExpr context syntax s a -> QGenExpr context syntax s a #

abs :: QGenExpr context syntax s a -> QGenExpr context syntax s a #

signum :: QGenExpr context syntax s a -> QGenExpr context syntax s a #

fromInteger :: Integer -> QGenExpr context syntax s a #

(IsSql92ExpressionSyntax syntax, HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) [Char]) => IsString (QGenExpr context syntax s Text) Source # 

Methods

fromString :: String -> QGenExpr context syntax s Text #

ContextRewritable (QGenExpr old syntax s a) Source # 

Associated Types

type WithRewrittenContext (QGenExpr old syntax s a) ctxt :: * Source #

Methods

rewriteContext :: Proxy * ctxt -> QGenExpr old syntax s a -> WithRewrittenContext (QGenExpr old syntax s a) ctxt Source #

(HasSqlValueSyntax (Sql92ExpressionValueSyntax syntax) a, IsSql92ExpressionSyntax syntax) => SqlValable (QGenExpr ctxt syntax s a) Source # 

Methods

val_ :: HaskellLiteralForQExpr (QGenExpr ctxt syntax s a) -> QGenExpr ctxt syntax s a Source #

type WithRewrittenThread s s' (tbl (Nullable (QGenExpr ctxt syntax s))) Source # 
type WithRewrittenThread s s' (tbl (Nullable (QGenExpr ctxt syntax s))) = tbl (Nullable (QGenExpr ctxt syntax s'))
type WithRewrittenThread s s' (tbl (QGenExpr ctxt syntax s)) Source # 
type WithRewrittenThread s s' (tbl (QGenExpr ctxt syntax s)) = tbl (QGenExpr ctxt syntax s')
type WithRewrittenThread s s' (QGenExpr ctxt syntax s a) Source # 
type WithRewrittenThread s s' (QGenExpr ctxt syntax s a) = QGenExpr ctxt syntax s' a
type Retag tag (QGenExpr ctxt expr s t) Source # 
type Retag tag (QGenExpr ctxt expr s t) = Columnar (tag (QGenExpr ctxt expr s)) t
type QExprToField (table (Nullable (QGenExpr context syntax s))) Source # 
type QExprToField (table (Nullable (QGenExpr context syntax s))) = table (Nullable (QField s))
type QExprToField (table (QGenExpr context syntax s)) Source # 
type QExprToField (table (QGenExpr context syntax s)) = table (QField s)
type QExprToIdentity (table (QGenExpr context syntax s)) Source # 
type QExprToIdentity (table (QGenExpr context syntax s)) = table Identity
type HaskellLiteralForQExpr (table (QGenExpr context syntax s)) Source # 
type HaskellLiteralForQExpr (table (QGenExpr context syntax s)) = table Identity
type WithRewrittenContext (tbl (Nullable (QGenExpr old syntax s))) ctxt Source # 
type WithRewrittenContext (tbl (Nullable (QGenExpr old syntax s))) ctxt = tbl (Nullable (QGenExpr ctxt syntax s))
type WithRewrittenContext (tbl (QGenExpr old syntax s)) ctxt Source # 
type WithRewrittenContext (tbl (QGenExpr old syntax s)) ctxt = tbl (QGenExpr ctxt syntax s)
type QExprToField (QGenExpr ctxt syntax s a) Source # 
type QExprToField (QGenExpr ctxt syntax s a) = QField s a
type QExprToIdentity (QGenExpr context syntax s a) Source # 
type QExprToIdentity (QGenExpr context syntax s a) = a
type HaskellLiteralForQExpr (QGenExpr context syntax s a) Source # 
type HaskellLiteralForQExpr (QGenExpr context syntax s a) = a
type WithRewrittenContext (QGenExpr old syntax s a) ctxt Source # 
type WithRewrittenContext (QGenExpr old syntax s a) ctxt = QGenExpr ctxt syntax s a

type family QExprToIdentity x Source #

Instances

type QExprToIdentity () Source # 
type QExprToIdentity () = ()
type QExprToIdentity (table (Nullable c)) Source # 
type QExprToIdentity (table (Nullable c)) = Maybe (QExprToIdentity (table c))
type QExprToIdentity (table (QGenExpr context syntax s)) Source # 
type QExprToIdentity (table (QGenExpr context syntax s)) = table Identity
type QExprToIdentity (a, b) Source # 
type QExprToIdentity (Vector n a) Source # 
type QExprToIdentity (a, b, c) Source # 
type QExprToIdentity (a, b, c, d) Source # 
type QExprToIdentity (QGenExpr context syntax s a) Source # 
type QExprToIdentity (QGenExpr context syntax s a) = a
type QExprToIdentity (a, b, c, d, e) Source # 
type QExprToIdentity (a, b, c, d, e, f) Source # 
type QExprToIdentity (a, b, c, d, e, f, g) Source # 
type QExprToIdentity (a, b, c, d, e, f, g, h) Source # 

type family QExprToField x Source #

Instances

type QExprToField () Source # 
type QExprToField () = ()
type QExprToField (table (Nullable (QGenExpr context syntax s))) Source # 
type QExprToField (table (Nullable (QGenExpr context syntax s))) = table (Nullable (QField s))
type QExprToField (table (QGenExpr context syntax s)) Source # 
type QExprToField (table (QGenExpr context syntax s)) = table (QField s)
type QExprToField (a, b) Source # 
type QExprToField (Vector n a) Source # 
type QExprToField (a, b, c) Source # 
type QExprToField (a, b, c, d) Source # 
type QExprToField (QGenExpr ctxt syntax s a) Source # 
type QExprToField (QGenExpr ctxt syntax s a) = QField s a
type QExprToField (a, b, c, d, e) Source # 
type QExprToField (a, b, c, d, e, f) Source # 
type QExprToField (a, b, c, d, e, f, g) Source # 
type QExprToField (a, b, c, d, e, f, g, h) Source # 

data QWindow syntax s Source #

Instances

ProjectibleWithPredicate WindowFrameContext syntax (QWindow syntax s) Source # 

Methods

project' :: Monad m => Proxy (* -> Constraint) WindowFrameContext -> (forall context. WindowFrameContext context => Proxy * context -> WithExprContext syntax -> m (WithExprContext syntax)) -> QWindow syntax s -> m (QWindow syntax s) Source #

data Aggregation syntax s a Source #