rel8-internal
Safe HaskellNone
LanguageHaskell2010

Rel8.Internal.Table.Either

Synopsis

Documentation

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

An EitherTable a b is a Rel8 table that contains either the table a or the table b. You can construct an EitherTable using leftTable and rightTable, and eliminate/pattern match using eitherTable.

An EitherTable is operationally the same as Haskell's Either type, but adapted to work with Rel8.

Constructors

EitherTable 

Fields

Instances

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

Defined in Rel8.Internal.Table.Either

Associated Types

type Columns (EitherTable context a b) 
Instance details

Defined in Rel8.Internal.Table.Either

type Columns (EitherTable context a b) = HEitherTable (Columns a) (Columns b)
type Context (EitherTable context a b) 
Instance details

Defined in Rel8.Internal.Table.Either

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

Defined in Rel8.Internal.Table.Either

type FromExprs (EitherTable context a b) = Either (FromExprs a) (FromExprs b)

Methods

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

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

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

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

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

Defined in Rel8.Internal.Table.Either

Methods

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

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

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

Biprojectable (EitherTable context) Source # 
Instance details

Defined in Rel8.Internal.Table.Either

Methods

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

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

Defined in Rel8.Internal.Table.Either

Methods

pure :: a0 -> EitherTable context a a0 #

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

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

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

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

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

Defined in Rel8.Internal.Table.Either

Methods

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

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

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

Defined in Rel8.Internal.Table.Either

Methods

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

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

return :: a0 -> EitherTable context a a0 #

Projectable (EitherTable context a) Source # 
Instance details

Defined in Rel8.Internal.Table.Either

Methods

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

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

Defined in Rel8.Internal.Table.Either

Methods

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

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

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

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

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

Defined in Rel8.Internal.Table.Either

Methods

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

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

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

Defined in Rel8.Internal.Table.Either

Methods

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

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

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

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

Defined in Rel8.Internal.Table.Either

Methods

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

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

Defined in Rel8.Internal.Table.Either

Methods

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

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

Defined in Rel8.Internal.Table.Either

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

Defined in Rel8.Internal.Table.Either

type Columns (EitherTable context a b) = HEitherTable (Columns a) (Columns b)
type Context (EitherTable context a b) Source # 
Instance details

Defined in Rel8.Internal.Table.Either

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

Defined in Rel8.Internal.Table.Either

type FromExprs (EitherTable context a b) = Either (FromExprs a) (FromExprs b)

eitherTable :: Table Expr c => (a -> c) -> (b -> c) -> EitherTable Expr a b -> c Source #

Pattern match/eliminate an EitherTable, by providing mappings from a leftTable and rightTable.

leftTable :: Table Expr b => a -> EitherTable Expr a b Source #

Construct a left EitherTable. Like Left.

rightTable :: Table Expr a => b -> EitherTable Expr a b Source #

Construct a right EitherTable. Like Right.

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

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

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

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

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

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

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

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

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

Lift a pair aggregators to operate on an EitherTable. leftTables and rightTables are grouped separately.

nameEitherTable Source #

Arguments

:: Name EitherTag

The name of the column to track whether a row is a leftTable or rightTable.

-> a

Names of the columns in the a table.

-> b

Names of the columns in the b table.

-> EitherTable Name a b 

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

Orphan instances

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