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

Jesper Louis Andersen jesper.louis.andersen at gmail.com
Mon May 31 09:15:27 EDT 2010


+1 from here as well.

The existing behaviour is not consistent with what I would expect
insertWith' to produce.

On Mon, May 31, 2010 at 3:08 AM, Edward Kmett <ekmett at gmail.com> wrote:
> +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
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>



-- 
J.


More information about the Libraries mailing list