@@ -9,6 +9,7 @@ module Rel8.Aggregate.Context
99{-# DEPRECATED "This is purely for backwards compatibility with prehistoric Rel8 and will be removed at some point." #-}
1010 ( Aggregates
1111 , aggregate
12+ , aggregateTabulation
1213 , groupBy
1314 , listAgg
1415 , nonEmptyAgg
@@ -36,6 +37,8 @@ import Rel8.Table.Eq ( EqTable, eqTable )
3637import Rel8.Table.List ( ListTable )
3738import Rel8.Table.NonEmpty ( NonEmptyTable )
3839import Rel8.Table.Opaleye ( aggregator )
40+import Rel8.Tabulate ( Tabulation )
41+import qualified Rel8.Tabulate
3942
4043
4144-- | Apply an aggregation to all rows returned by a 'Query'.
@@ -43,6 +46,13 @@ aggregate :: Aggregates aggregates exprs => Query aggregates -> Query exprs
4346aggregate = mapOpaleye (Opaleye.aggregate aggregator) . fmap (fromColumns . toColumns)
4447
4548
49+aggregateTabulation
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)
54+
55+
4656-- | Group equal tables together. This works by aggregating each column in the
4757-- given table with 'groupByExpr'.
4858groupBy :: forall exprs aggregates. (EqTable exprs, Aggregates aggregates exprs)