[Haskell-cafe] Implementing ParseChart with Data.Map

Neil Mitchell ndmitchell at gmail.com
Mon Jun 2 18:07:55 EDT 2008

Hi Krasimir,

> insert :: k -> v -> Chart k v -> Maybe (Chart k v)
> where the result is (Just _) if the (k,v) is actually added to the
> chart or Nothing if it was already there and nothing have to be done.

insertLookupWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k
a -> (Maybe a, Map k a)

This should provide the information you need, without the double
traversal of the data structure.



More information about the Haskell-Cafe mailing list