7 Nov
                
                    2009
                
            
            
                7 Nov
                
                '09
                
            
            
            
        
    
                4:29 p.m.
            
        On Sun, Nov 08, 2009 at 12:15:57AM +0300, Eugene Kirpichov wrote:
Here, you should not use Map.fromListWith (+) because Map is not strict in its entries and you end up having big fat thunks there. You should use Map.fromListWith plus where x `plus` y = x `seq` y `seq` x+y.
fromListWith is implemented with insertWithKey; is defining plus like above enough? I would guess that we need fromListWith' implemented with insertWithKey'. The problem is that it will build a thunk (x `plus` y) and your seq's only say that whenever you evaluate that thunk you'll evaluate the arguments as well. If the thunk itself isn't needed, it won't be evaluated. -- Felipe.