[Haskell-cafe] Implementing ParseChart with Data.Map

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Mon Jun 2 18:28:29 EDT 2008

On Mon, 2008-06-02 at 22:35 +0200, Krasimir Angelov wrote:

> The problem with this is that both the Map and the Set are traversed
> twice. The first time from lookup/member and the second time from
> insert. Does someone have an idea how to do this with the current
> libraries?

> The chart manipulation is in the tight loop of my application so I
> need fast code. Any other ideas?

I'm not sure if it helps your application but we had a discussion on
#haskell the other day about Data.Map and were talking about a general
insert/modify/delete operator like:

modify :: k -> Map k e -> (e, Maybe e -> Map k e)

so it's a lookup that returns the element at k and also a continuation
that lets you rebuild a new map with an altered element. I guess that
doesn't account for the element not existing. There's probably a
generalisation that does.


More information about the Haskell-Cafe mailing list