[Haskell] combining IntMaps

Adrian Hey ahey at iee.org
Sun Jul 31 02:40:34 EDT 2005

On Saturday 30 Jul 2005 7:07 pm, Daan Leijen wrote:
> Efficiency wise, I think one should only provide functions that ensure that
> the complexity does not get worse -- if one also considers functionality
> that improves on a constant factor (like traversing twice) there is no end
> to the number of functions that can be provided (as one is basically doing
> deforestation by hand). But this is of course just my personal opinion on
> how to control the size of the API.

Actually, I think the point of Chads example is that the function he
really needs is not a deforestation of the only solution available
to him. The values in the two input maps are already known to satisfy the
required condition. The test only needs to be applied on the new combined
values (where the maps intersect). So I think it would be worthwhile to
produce some kind of unionWithMaybe function. But I have no idea how
to do this with IntMaps so I'm not volunteering :-)

My 2p..

Adrian Hey

More information about the Haskell mailing list