Change sum to be defined in terms of generalized foldr.
Added a function to compute arithmetic mean of quantities.
Removed noisy type signatures from local functions in definition of mean.
Manual merge