Skip to content

Commit

Permalink
Relax the type of the Unpackspec for makeAggrExplicit
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-circuithub committed Oct 11, 2023
1 parent ce8015a commit ac24797
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Opaleye/Aggregate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ module Opaleye.Aggregate

import Data.Profunctor (lmap)
import qualified Data.Profunctor as P
import Data.Profunctor.Product.Default (def)

import qualified Opaleye.Internal.Aggregate as A
import Opaleye.Internal.Aggregate (Aggregator, orderAggregate)
Expand All @@ -47,6 +46,7 @@ import qualified Opaleye.Internal.HaskellDB.PrimQuery as HPQ
import qualified Opaleye.Internal.Operators as O
import qualified Opaleye.Internal.PackMap as PM
import qualified Opaleye.Internal.Tag as Tag
import qualified Opaleye.Internal.Unpackspec as U

import qualified Opaleye.Field as F
import qualified Opaleye.Order as Ord
Expand Down Expand Up @@ -195,7 +195,7 @@ jsonAgg = A.makeAggr HPQ.JsonArr
stringAgg :: F.Field T.SqlText
-> Aggregator (F.Field T.SqlText) (F.Field T.SqlText)
stringAgg delimiter =
lmap (\a -> (a, delimiter)) $ A.makeAggrExplicit def HPQ.AggrStringAggr
A.makeAggrExplicit (U.unpackspecField <* lmap (const delimiter) U.unpackspecField) HPQ.AggrStringAggr

-- | Count the number of rows in a query. This is different from
-- 'aggregate' 'count' because it always returns exactly one row, even
Expand Down
2 changes: 1 addition & 1 deletion src/Opaleye/Internal/Aggregate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ makeAggr' mAggrOp = P.dimap C.unColumn C.Column $ Aggregator (PM.PackMap
makeAggr :: HPQ.AggrOp -> Aggregator (C.Field_ n a) (C.Field_ n' b)
makeAggr = makeAggr' . Just

makeAggrExplicit :: U.Unpackspec a a -> HPQ.AggrOp -> Aggregator a (C.Field_ n b)
makeAggrExplicit :: U.Unpackspec a a' -> HPQ.AggrOp -> Aggregator a (C.Field_ n b)
makeAggrExplicit unpackspec op =
C.Column <$> Aggregator (PM.PackMap (\f e -> f (aggr e)))
where
Expand Down

0 comments on commit ac24797

Please sign in to comment.