Proposal: Make Data.Map.insertWith' and friends consistently force the value inserted

Edward Kmett ekmett at gmail.com
Sun May 30 21:08:04 EDT 2010


+1

Sent from my iPhone

On May 30, 2010, at 8:51 PM, Felipe Lessa <felipe.lessa at gmail.com>  
wrote:

> 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.
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries


More information about the Libraries mailing list