@@ -1608,23 +1608,12 @@ tsHeadline = unsafeFunctionHet "ts_headline"
16081608aggregation
16091609-----------------------------------------}
16101610
1611−type AggrFun x y
1612− = forall outer bys commons schemas params from
1613− . Distinction (Expression outer commons 'Ungrouped schemas params from) x
1614− -- ^ input
1615− -> Expression outer commons ('Grouped bys) schemas params from y
1616− -- ^ output
1617−
1618−type AggrHet xs y
1619− = forall outer bys commons schemas params from
1620− . Distinction (NP (Expression outer commons 'Ungrouped schemas params from)) xs
1621− -- ^ inputs
1611+unsafeAggregateHet
1612+ :: SOP.SListI xs
1613+ => ByteString -- ^ function
1614+ -> Distinction (NP (Expression outer commons 'Ungrouped schemas params from)) xs
16221615 -> Expression outer commons ('Grouped bys) schemas params from y
1623− -- ^ output
1624−
1625−unsafeAggregateHet :: SOP.SListI xs => ByteString -> AggrHet xs y
1626−unsafeAggregateHet fun xs = UnsafeExpression $ mconcat
1627− [fun, "(", renderSQL xs, ")"]
1616+unsafeAggregateHet fun xs = UnsafeExpression $ fun <> parenthesized (renderSQL xs)
16281617
16291618{- |
16301619`Aggregate` functions compute a single result from a set of input values.
@@ -2032,9 +2021,9 @@ instance Aggregate
20322021-- | escape hatch to define aggregate functions
20332022unsafeAggregate1
20342023 :: ByteString -- ^ aggregate function
2035− -> AggrFun xty yty
2036−unsafeAggregate1 fun x = UnsafeExpression $ mconcat
2037− [fun, "(", renderSQL x, ")"]
2024+ -> Distinction (Expression outer commons 'Ungrouped schemas params from) x
2025+ -> Expression outer commons ('Grouped bys) schemas params from y
2026+unsafeAggregate1 fun x = UnsafeExpression $ fun <> parenthesized (renderSQL x)
20382027
20392028-- | A type family that calculates `PGAvg` type of a `PGType`.
20402029type family PGAvg ty where