@@ -9,6 +9,7 @@ module Rel8.Aggregate.Context
9{-# DEPRECATED "This is purely for backwards compatibility with prehistoric Rel8 and will be removed at some point." #-}
9{-# DEPRECATED "This is purely for backwards compatibility with prehistoric Rel8 and will be removed at some point." #-}
10 ( Aggregates
10 ( Aggregates
11 , aggregate
11 , aggregate
12+ , aggregateTabulation
14 , nonEmptyAgg
15 , nonEmptyAgg
@@ -36,6 +37,8 @@ import Rel8.Table.Eq ( EqTable, eqTable )
36import Rel8.Table.List ( ListTable )
37import Rel8.Table.List ( ListTable )
37import Rel8.Table.NonEmpty ( NonEmptyTable )
38import Rel8.Table.NonEmpty ( NonEmptyTable )
38import Rel8.Table.Opaleye ( aggregator )
39import Rel8.Table.Opaleye ( aggregator )
40+import Rel8.Tabulate ( Tabulation )
41+import qualified Rel8.Tabulate
41-- | Apply an aggregation to all rows returned by a 'Query'.
44-- | Apply an aggregation to all rows returned by a 'Query'.
@@ -43,6 +46,13 @@ aggregate :: Aggregates aggregates exprs => Query aggregates -> Query exprs
43aggregate = mapOpaleye (Opaleye.aggregate aggregator) . fmap (fromColumns . toColumns)
46aggregate = mapOpaleye (Opaleye.aggregate aggregator) . fmap (fromColumns . toColumns)
50+ :: (EqTable k, Aggregates aggregates exprs)
51+ => (t -> aggregates) -> Tabulation k t -> Tabulation k exprs
52+aggregateTabulation f =
53+ Rel8.Tabulate.aggregateTabulation . fmap (fromColumns . toColumns . f)
46-- | Group equal tables together. This works by aggregating each column in the
56-- | Group equal tables together. This works by aggregating each column in the
47-- given table with 'groupByExpr'.
57-- given table with 'groupByExpr'.
48groupBy :: forall exprs aggregates. (EqTable exprs, Aggregates aggregates exprs)
58groupBy :: forall exprs aggregates. (EqTable exprs, Aggregates aggregates exprs)