On Sun, Aug 22, 2010 at 9:45 AM, Johan Tibell <johan.tibell@gmail.com> wrote:
On Sat, Aug 21, 2010 at 1:45 PM, Ian Lynagh <igloo@earth.li> wrote:On Wed, Aug 18, 2010 at 02:00:39PM +0200, Johan Tibell wrote:Shouldn't (go z l) be forced too?
>
> The current API doesn't offer any efficient way to do something simple as
> e.g. summing the values in a map. I suggest we add a foldlWithKey' function:
>
> http://hackage.haskell.org/trac/ghc/ticket/4261
It makes sense to me to do so but the core looks worse for some reason:foldlWithKey' :: (b -> k -> a -> b) -> b -> Map k a -> bfoldlWithKey' f z0 m0 = go z0 m0wherego z _ | z `seq` False = undefinedgo z Tip = zgo z (Bin _ kx x l r) = let z' = go z lz'' = f z' kx x
in z' `seq` z'' `seq` go z'' r{-# INLINE foldlWithKey' #-}