Data.HashMap: Strict or lazy by default?

wren ng thornton wren at
Sat Feb 19 03:06:32 CET 2011

On 2/18/11 6:36 PM, Isaac Dupree wrote:
> On 02/18/11 18:21, Edward Kmett wrote:
>> Hrmm, the strict version will violate the laws for Functor:
>> (fmap (const 12) . fmap error) /= fmap (const 12 . error)
> That's an issue, though. It means you can't use a Map that tries to keep
> its values always strict if you want to use class Functor with it. *Even
> if* it's a separate type in Data.SomeMap.Strict. (Unless you're willing
> to break the law in the presence of _|_ values.)

FWIW, it's still a (category theoretic) functor:

     (fmap (const 12) . fmap error) == fmap (const 12 .! error)
     (f .! g) x = f $! g x's just not an endofunctor. But the Functor class is for encoding 
endofunctors, so this detail doesn't help us much. At least, not directly.

Live well,

More information about the Libraries mailing list