opaleye-sqlite-0.0.1.1: An SQL-generating DSL targeting SQLite
Safe HaskellNone
LanguageHaskell2010

Opaleye.SQLite.Aggregate

Description

Perform aggregations on query results.

Synopsis

Documentation

aggregate :: Aggregator a b -> Query a -> Query b Source #

Given a Query producing rows of type a and an Aggregator accepting rows of type a, apply the aggregator to the results of the query.

groupBy :: Aggregator (Column a) (Column a) Source #

Group the aggregation by equality on the input to groupBy.

sum :: Aggregator (Column a) (Column a) Source #

Sum all rows in a group.

count :: Aggregator (Column a) (Column PGInt8) Source #

Count the number of non-null rows in a group.

avg :: Aggregator (Column PGFloat8) (Column PGFloat8) Source #

Average of a group

max :: PGOrd a => Aggregator (Column a) (Column a) Source #

Maximum of a group

min :: PGOrd a => Aggregator (Column a) (Column a) Source #

Maximum of a group

data Aggregator a b Source #

An Aggregator takes a collection of rows of type a, groups them, and transforms each group into a single row of type b. This corresponds to aggregators using GROUP BY in SQL.

An Aggregator corresponds closely to a Fold from the foldl package. Whereas an Aggregator a b takes each group of type a to a single row of type b, a Fold a b takes a list of a and returns a single row of type b.

Instances

Instances details
Profunctor Aggregator Source # 
Instance details

Defined in Opaleye.SQLite.Internal.Aggregate

Methods

dimap :: (a -> b) -> (c -> d) -> Aggregator b c -> Aggregator a d #

lmap :: (a -> b) -> Aggregator b c -> Aggregator a c #

rmap :: (b -> c) -> Aggregator a b -> Aggregator a c #

(#.) :: forall a b c q. Coercible c b => q b c -> Aggregator a b -> Aggregator a c #

(.#) :: forall a b c q. Coercible b a => Aggregator b c -> q a b -> Aggregator a c #

ProductProfunctor Aggregator Source # 
Instance details

Defined in Opaleye.SQLite.Internal.Aggregate

Methods

purePP :: b -> Aggregator a b #

(****) :: Aggregator a (b -> c) -> Aggregator a b -> Aggregator a c #

empty :: Aggregator () () #

(***!) :: Aggregator a b -> Aggregator a' b' -> Aggregator (a, a') (b, b') #

SumProfunctor Aggregator Source # 
Instance details

Defined in Opaleye.SQLite.Internal.Aggregate

Methods

(+++!) :: Aggregator a b -> Aggregator a' b' -> Aggregator (Either a a') (Either b b') #

Functor (Aggregator a) Source # 
Instance details

Defined in Opaleye.SQLite.Internal.Aggregate

Methods

fmap :: (a0 -> b) -> Aggregator a a0 -> Aggregator a b #

(<$) :: a0 -> Aggregator a b -> Aggregator a a0 #

Applicative (Aggregator a) Source # 
Instance details

Defined in Opaleye.SQLite.Internal.Aggregate

Methods

pure :: a0 -> Aggregator a a0 #

(<*>) :: Aggregator a (a0 -> b) -> Aggregator a a0 -> Aggregator a b #

liftA2 :: (a0 -> b -> c) -> Aggregator a a0 -> Aggregator a b -> Aggregator a c #

(*>) :: Aggregator a a0 -> Aggregator a b -> Aggregator a b #

(<*) :: Aggregator a a0 -> Aggregator a b -> Aggregator a a0 #