Proposal: Make `NFData` a fundamental/primitive type-class (by making `deepseq` a GHC-boot package)

Johan Tibell johan.tibell at gmail.com
Fri Aug 26 12:03:18 CEST 2011


On Fri, Aug 26, 2011 at 10:34 AM, Paterson, Ross <R.Paterson at city.ac.uk> wrote:
> Simon Marlow writes:
>> That's what we have right now, the problem is that deepseq can't define
>> a good instance for NFData Map, because it can't see enough of the
>> internals of Map.
>
> Couldn't the strict foldl do it?

In this case yes, if you know the internal representation of the Map
type (which is subject to change). To do it well you must force the
values but not the keys while folding (the keys are already WHNF so
forcing them would be wasteful). You must also make sure that the fold
itself doesn't add any extra overhead.

Johan



More information about the Libraries mailing list