karamaan / karamaan-opaleye

Other
11 stars 7 forks source link

Replace Aggregator module with contents of AggregatorSuper? #79

Open tomjaguarpaw opened 10 years ago

tomjaguarpaw commented 10 years ago

I've come up with a concept of "super" aggregator which is the same as our current Aggregator but with slightly nicer structure. In particular it allows us to write countAll :: Aggregator () (Wire Int64) which was impossible with the old approach (see https://github.com/karamaan/karamaan-opaleye/issues/76).

(Example usage of the super aggregator)

Once I've implemented everything, it should be API compatible with the old Aggregator module with one exception. The type off aggregate has changed from

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

to

aggregate :: (D.Default (PP.PPOfContravariant U.Unpackspec) a a,
          D.Default (PP.PPOfContravariant U.Unpackspec) b b)
          => Aggregator a b -> Query a -> Query b

The new version is a bit more messy, but we're used to this sort of use of the Default typeclass by now. In pretty much all uses the new version will still work because we will have suitable instances for our a and b.

Should I just go ahead and replace the old module with the new one?

bergmark commented 10 years ago

Sure!