The list based monoid representation is not space efficient. This
implementation also leads towards a number of confusing and highly
opinionated instances. This new implementation is space efficient, ideal
for on-line algorithms and does not include possibly confusing/problematic
instances.
Unfortunately, storing a running sum means we can't just fmap or combine values anymore, because the stored values are magnified when averaged. I adressed this issue by changing from Functor to MonoFunctor, and performing the average before those operations.
It would also be possible to just store the average right away; I've explored that in https://github.com/leftaroundabout/average/tree/refactor/weight-and-average. However that approach makes the Monoid instance quite inefficient, and we should probably prioritise keeping that efficient because it's the centerpiece of this package.
Re #4:
Unfortunately, storing a running sum means we can't just fmap or combine values anymore, because the stored values are magnified when averaged. I adressed this issue by changing from
Functor
toMonoFunctor
, and performing the average before those operations.It would also be possible to just store the average right away; I've explored that in https://github.com/leftaroundabout/average/tree/refactor/weight-and-average. However that approach makes the
Monoid
instance quite inefficient, and we should probably prioritise keeping that efficient because it's the centerpiece of this package.