[Haskell-cafe] Byte Histogram
Johan Tibell
johan.tibell at gmail.com
Sun Feb 6 19:38:11 CET 2011
On Sat, Feb 5, 2011 at 4:16 PM, Andrew Coppin
<andrewcoppin at btinternet.com> wrote:
> Random fact: Data.Map.insertWith' exists. Data.IntMap.insertWith' does *not*
> exist.
The containers library is a mess. For example, Data.Map has 10+
functions (e.g. adjust) that don't have strict counterparts even
though the strict version is most likely what you want. Some functions
do allow you to force the value before it's inserted into the map just
because you can piggy-back on the evaluation of a constructor e.g.
update :: Ord k => (a -> Maybe a) -> k -> Map k a -> Map k a
f = update g someKey someMap
where g = (\ v -> let v' = v + 1 in v' `seq` Just v')
Since the implementation must evaluate the result of g to decide
whether to remove the element or not.
Johan
More information about the Haskell-Cafe
mailing list