[Haskell-cafe] Multi groupby with foldl' and Map.insertWithKey

Olaf Klinke olf at aatal-apotheke.de
Wed Dec 28 20:21:06 UTC 2016

> Am 28.12.2016 um 19:40 schrieb Jan-Willem Maessen <jmaessen at alum.mit.edu>:
> A caution on this alternative: the first component of the tuple won't be strict enough and you'll leak space.  I think the proposed solution is better.  Note that you *don't* necessarily need the strictness annotation on healthTopics – this shifts around when the list append gets run but won't change space much.
> -Jan-Willem Maessen
Thanks for clarifying this, Jan-Willem. So there ought to be stricter versions of the newtype wrappers in Data.Monoid. Even then, the tuple is not strict. Will that also leak space? 
I just thought the (Sum Int,[String]) type was a neat example of instance deriving. 


More information about the Haskell-Cafe mailing list