Proposal: Make Data.Map.insertWith' and friends consistently
force the value inserted
Felipe Lessa
felipe.lessa at gmail.com
Sun May 30 20:51:44 EDT 2010
On Sun, May 30, 2010 at 11:34:47PM +0100, Ian Lynagh wrote:
> Hi all,
>
> Currently, Data.Map.insertWith' (and friends) only force the value
> inserted when the combining function creates it:
>
> Prelude Data.Map> insertWith' (+) "foo" undefined empty `seq` ()
> ()
> Prelude Data.Map> insertWith' (+) "foo" undefined (singleton "foo" 1) `seq` ()
> *** Exception: Prelude.undefined
>
> I think it would be more consistent for it to always force it:
>
> Prelude Data.Map> insertWith' (+) "foo" undefined empty `seq` ()
> *** Exception: Prelude.undefined
> Prelude Data.Map> insertWith' (+) "foo" undefined (singleton "foo" 1) `seq` ()
> *** Exception: Prelude.undefined
The current behaviour is unexpected.
+1 for the patch.
--
Felipe.
More information about the Libraries
mailing list