rel8-internal
Safe HaskellNone
LanguageHaskell2010

Rel8.Internal.Table.These

Synopsis

Documentation

data TheseTable (context :: Context) a b Source #

TheseTable a b is a Rel8 table that contains either the table a, the table b, or both tables a and b. You can construct TheseTables using thisTable, thatTable and thoseTable. TheseTables can be eliminated/pattern matched using theseTable.

TheseTable is operationally the same as Haskell's These type, but adapted to work with Rel8.

Constructors

TheseTable 

Fields

Instances

Instances details
(Table context a, Table context b, Reifiable context, context ~ context') => Table context' (TheseTable context a b) Source # 
Instance details

Defined in Rel8.Internal.Table.These

Associated Types

type Columns (TheseTable context a b) 
Instance details

Defined in Rel8.Internal.Table.These

type Columns (TheseTable context a b) = HTheseTable (Columns a) (Columns b)
type Context (TheseTable context a b) 
Instance details

Defined in Rel8.Internal.Table.These

type Context (TheseTable context a b) = Context a
type FromExprs (TheseTable context a b) 
Instance details

Defined in Rel8.Internal.Table.These

type FromExprs (TheseTable context a b) = These (FromExprs a) (FromExprs b)

Methods

toColumns :: TheseTable context a b -> Columns (TheseTable context a b) context' Source #

fromColumns :: Columns (TheseTable context a b) context' -> TheseTable context a b Source #

fromResult :: Columns (TheseTable context a b) Result -> FromExprs (TheseTable context a b) Source #

toResult :: FromExprs (TheseTable context a b) -> Columns (TheseTable context a b) Result Source #

Nullifiable context => Bifunctor (TheseTable context) Source # 
Instance details

Defined in Rel8.Internal.Table.These

Methods

bimap :: (a -> b) -> (c -> d) -> TheseTable context a c -> TheseTable context b d #

first :: (a -> b) -> TheseTable context a c -> TheseTable context b c #

second :: (b -> c) -> TheseTable context a b -> TheseTable context a c #

Biprojectable (TheseTable context) Source # 
Instance details

Defined in Rel8.Internal.Table.These

Methods

biproject :: (Projecting a b, Projecting c d) => Projection a b -> Projection c d -> TheseTable context a c -> TheseTable context b d Source #

(context ~ Expr, Table Expr a, Semigroup a) => Applicative (TheseTable context a) Source # 
Instance details

Defined in Rel8.Internal.Table.These

Methods

pure :: a0 -> TheseTable context a a0 #

(<*>) :: TheseTable context a (a0 -> b) -> TheseTable context a a0 -> TheseTable context a b #

liftA2 :: (a0 -> b -> c) -> TheseTable context a a0 -> TheseTable context a b -> TheseTable context a c #

(*>) :: TheseTable context a a0 -> TheseTable context a b -> TheseTable context a b #

(<*) :: TheseTable context a a0 -> TheseTable context a b -> TheseTable context a a0 #

Nullifiable context => Functor (TheseTable context a) Source # 
Instance details

Defined in Rel8.Internal.Table.These

Methods

fmap :: (a0 -> b) -> TheseTable context a a0 -> TheseTable context a b #

(<$) :: a0 -> TheseTable context a b -> TheseTable context a a0 #

(context ~ Expr, Table Expr a, Semigroup a) => Monad (TheseTable context a) Source # 
Instance details

Defined in Rel8.Internal.Table.These

Methods

(>>=) :: TheseTable context a a0 -> (a0 -> TheseTable context a b) -> TheseTable context a b #

(>>) :: TheseTable context a a0 -> TheseTable context a b -> TheseTable context a b #

return :: a0 -> TheseTable context a a0 #

Projectable (TheseTable context a) Source # 
Instance details

Defined in Rel8.Internal.Table.These

Methods

project :: Projecting a0 b => Projection a0 b -> TheseTable context a a0 -> TheseTable context a b Source #

(context ~ Expr, Table Expr a, Semigroup a) => Apply (TheseTable context a) Source # 
Instance details

Defined in Rel8.Internal.Table.These

Methods

(<.>) :: TheseTable context a (a0 -> b) -> TheseTable context a a0 -> TheseTable context a b

(.>) :: TheseTable context a a0 -> TheseTable context a b -> TheseTable context a b

(<.) :: TheseTable context a a0 -> TheseTable context a b -> TheseTable context a a0

liftF2 :: (a0 -> b -> c) -> TheseTable context a a0 -> TheseTable context a b -> TheseTable context a c

(context ~ Expr, Table Expr a, Semigroup a) => Bind (TheseTable context a) Source # 
Instance details

Defined in Rel8.Internal.Table.These

Methods

(>>-) :: TheseTable context a a0 -> (a0 -> TheseTable context a b) -> TheseTable context a b

join :: TheseTable context a (TheseTable context a a0) -> TheseTable context a a0

(context ~ Expr, Table Expr a, Table Expr b, Semigroup a, Semigroup b) => Semigroup (TheseTable context a b) Source # 
Instance details

Defined in Rel8.Internal.Table.These

Methods

(<>) :: TheseTable context a b -> TheseTable context a b -> TheseTable context a b #

sconcat :: NonEmpty (TheseTable context a b) -> TheseTable context a b #

stimes :: Integral b0 => b0 -> TheseTable context a b -> TheseTable context a b #

(EqTable a, EqTable b, context ~ Expr) => EqTable (TheseTable context a b) Source # 
Instance details

Defined in Rel8.Internal.Table.These

Methods

eqTable :: Columns (TheseTable context a b) (Dict (Sql DBEq)) Source #

(OrdTable a, OrdTable b, context ~ Expr) => OrdTable (TheseTable context a b) Source # 
Instance details

Defined in Rel8.Internal.Table.These

Methods

ordTable :: Columns (TheseTable context a b) (Dict (Sql DBOrd)) Source #

type Transpose to (TheseTable context a b) Source # 
Instance details

Defined in Rel8.Internal.Table.These

type Transpose to (TheseTable context a b) = TheseTable to (Transpose to a) (Transpose to b)
type Columns (TheseTable context a b) Source # 
Instance details

Defined in Rel8.Internal.Table.These

type Columns (TheseTable context a b) = HTheseTable (Columns a) (Columns b)
type Context (TheseTable context a b) Source # 
Instance details

Defined in Rel8.Internal.Table.These

type Context (TheseTable context a b) = Context a
type FromExprs (TheseTable context a b) Source # 
Instance details

Defined in Rel8.Internal.Table.These

type FromExprs (TheseTable context a b) = These (FromExprs a) (FromExprs b)

theseTable :: Table Expr c => (a -> c) -> (b -> c) -> (a -> b -> c) -> TheseTable Expr a b -> c Source #

Pattern match on a TheseTable. Corresponds to these.

thisTable :: Table Expr b => a -> TheseTable Expr a b Source #

Construct a TheseTable. Corresponds to This.

thatTable :: Table Expr a => b -> TheseTable Expr a b Source #

Construct a TheseTable. Corresponds to That.

thoseTable :: a -> b -> TheseTable Expr a b Source #

Construct a TheseTable. Corresponds to These.

isThisTable :: TheseTable Expr a b -> Expr Bool Source #

Test if a TheseTable was constructed with thisTable.

Corresponds to isThis.

isThatTable :: TheseTable Expr a b -> Expr Bool Source #

Test if a TheseTable was constructed with thatTable.

Corresponds to isThat.

isThoseTable :: TheseTable Expr a b -> Expr Bool Source #

Test if a TheseTable was constructed with thoseTable.

Corresponds to isThese.

hasHereTable :: TheseTable Expr a b -> Expr Bool Source #

Test if the a side of TheseTable a b is present.

Corresponds to hasHere.

hasThereTable :: TheseTable Expr a b -> Expr Bool Source #

Test if the b table of TheseTable a b is present.

Corresponds to hasThere.

justHereTable :: forall (context :: Context) a b. TheseTable context a b -> MaybeTable context a Source #

Attempt to project out the a table of a TheseTable a b.

Corresponds to justHere.

justThereTable :: forall (context :: Context) a b. TheseTable context a b -> MaybeTable context b Source #

Attempt to project out the b table of a TheseTable a b.

Corresponds to justThere.

alignMaybeTable :: MaybeTable Expr a -> MaybeTable Expr b -> MaybeTable Expr (TheseTable Expr a b) Source #

Construct a TheseTable from two MaybeTables.

aggregateThisTable :: forall c a (fold :: Fold) b. Table Expr c => Aggregator a c -> Aggregator' fold (TheseTable Expr a b) c Source #

Lift an Aggregator to operate on a TheseTable. If the input query has thisTable as, they are folded into a single c by the given aggregator — in the case where the input query is all thatTables or thoseTables, the Aggregator's fallback c is returned.

aggregateThisTable1 :: forall c (fold :: Fold) a (fold' :: Fold) b. Table Expr c => Aggregator' fold a c -> Aggregator' fold' (TheseTable Expr a b) (MaybeTable Expr c) Source #

Lift an Aggregator1 to operate on a TheseTable. If the input query has thisTable as, they are folded into a single justTable c by the given aggregator — in the case where the input query is all thatTables or thoseTables, a single nothingTable row is returned.

aggregateThatTable :: forall c b (fold :: Fold) a. Table Expr c => Aggregator b c -> Aggregator' fold (TheseTable Expr a b) c Source #

Lift an Aggregator to operate on a TheseTable. If the input query has thatTable bs, they are folded into a single c by the given aggregator — in the case where the input query is all thisTables or thoseTables, the Aggregator's fallback c is returned.

aggregateThatTable1 :: forall c (fold :: Fold) b (fold' :: Fold) a. Table Expr c => Aggregator' fold b c -> Aggregator' fold' (TheseTable Expr a b) (MaybeTable Expr c) Source #

Lift an Aggregator1 to operate on a TheseTable. If the input query has thatTable bs, they are folded into a single justTable c by the given aggregator — in the case where the input query is all thisTables or thoseTables, a single nothingTable row is returned.

aggregateThoseTable :: forall c a b (fold :: Fold). Table Expr c => Aggregator (a, b) c -> Aggregator' fold (TheseTable Expr a b) c Source #

Lift an Aggregator to operate on a ThoseTable. If the input query has thoseTable a bs, they are folded into a single c by the given aggregator — in the case where the input query is all thisTables or thatTables, the Aggregator's fallback c is returned.

aggregateThoseTable1 :: forall c (fold :: Fold) a b (fold' :: Fold). Table Expr c => Aggregator' fold (a, b) c -> Aggregator' fold' (TheseTable Expr a b) (MaybeTable Expr c) Source #

Lift an Aggregator1 to operate on a TheseTable. If the input query has thoseTable a bs, they are folded into a single justTable c by the given aggregator — in the case where the input query is all thisTables or thatTables, a single nothingTable row is returned.

aggregateHereTable :: forall c a (fold :: Fold) b. Table Expr c => Aggregator a c -> Aggregator' fold (TheseTable Expr a b) c Source #

Lift an Aggregator to operate on a TheseTable. If the input query has thisTable as or thoseTable a _s, the as are folded into a single c by the given aggregator — in the case where the input query is all thatTables, the Aggregator's fallback c is returned.

aggregateHereTable1 :: forall c (fold :: Fold) a (fold' :: Fold) b. Table Expr c => Aggregator' fold a c -> Aggregator' fold' (TheseTable Expr a b) (MaybeTable Expr c) Source #

Lift an Aggregator1 to operate on an TheseTable. If the input query has thisTable as or thoseTable a _s, the as are folded into a single justTable c by the given aggregator — in the case where the input query is all thatTables, a single nothingTable row is returned.

aggregateThereTable :: forall c b (fold :: Fold) a. Table Expr c => Aggregator b c -> Aggregator' fold (TheseTable Expr a b) c Source #

Lift an Aggregator to operate on a TheseTable. If the input query has thatTable bs or thoseTable _ bs, the bs are folded into a single c by the given aggregator — in the case where the input query is all thisTables, the Aggregator's fallback c is returned.

aggregateThereTable1 :: forall c (fold :: Fold) b (fold' :: Fold) a. Table Expr c => Aggregator' fold b c -> Aggregator' fold' (TheseTable Expr a b) (MaybeTable Expr c) Source #

Lift an Aggregator1 to operate on an TheseTable. If the input query has thatTable bs or thoseTable _ bs, the bs are folded into a single justTable c by the given aggregator — in the case where the input query is all thisTables, a single nothingTable row is returned.

aggregateTheseTable :: forall (fold :: Fold) i a (fold' :: Fold) i' b. Aggregator' fold i a -> Aggregator' fold' i' b -> Aggregator1 (TheseTable Expr i i') (TheseTable Expr a b) Source #

Lift a pair aggregators to operate on a TheseTable. thisTables, thatTables are thoseTables are grouped separately.

nameTheseTable Source #

Arguments

:: Name (Maybe MaybeTag)

The name of the column to track the presence of the a table.

-> Name (Maybe MaybeTag)

The name of the column to track the presence of the b table.

-> a

Names of the columns in the a table.

-> b

Names of the columns in the b table.

-> TheseTable Name a b 

Construct a TheseTable in the Name context. This can be useful if you have a TheseTable that you are storing in a table and need to construct a TableSchema.

Orphan instances

(ToExprs exprs1 a, ToExprs exprs2 b, x ~ TheseTable Expr exprs1 exprs2) => ToExprs x (These a b) Source # 
Instance details