The profiles sometimes charges to the wrong account. In this example:
foo :: (() -> () -> [()] -> [()]) -> () -> [()] -> [()]
foo k =
\_ xs -> concatMap ($ [head xs]) [bar]
where
bar =
let k' = k undefined undefined
in \xs ->
let k'' = [k' xs]
in (() : (foldr1 (>>) k''))
k = foo (\_ -> k)
--k a = foo (\_ -> k) a
r = k undefined [] !! 4000
main = print r
almost all of the time, allocations, and heap retention are charged
to k. However, if you use the commented definition of k, the changes
switch to foo, as expected. This can be tested by running
ghc --make -prof -auto-all Logic.hs && ./a.out +RTS -hc && hp2ps -c a.out.hp
and watching the pretty graph change.
This is using ghc 6.4.1 from Debian unstable. More background at
http://haskell.org/pipermail/haskell-cafe/2006-February/014139.html