Jan-Willem Maessen jmaessen at
Fri Jun 3 10:57:40 EDT 2005

On Jun 3, 2005, at 7:51 AM, Christian Maeder wrote:

> Serge D. Mechveliani wrote:
>> I used to apply  FiniteMap.addListToFM.
>> Now, what is its best expression in ghc-6.4 ?
>> Is this
>>         \ mp pairs -> Map.union (Map.fromList pairs) mp
>> ?
>> (the order of the arguments in Map.union is essential).
> This looks fine to me. "best" is hard to meet. I'ld suggest:
>   foldr (uncurry Map.insert)

The trouble is, neither of these approaches is demonstrably better for 
*all* finitemap implementations.  The latter is probably best for 
standard binary trees with a balance metric, where union is notoriously 
difficult.  But for other structures the union approach may work better 
(a randomly-balanced tree I'm fiddling with has this property, I 

That argues for presence in the library.

-Jan-Willem Maessen

More information about the Glasgow-haskell-users mailing list