title: How can I find the allocation in a Haskell function compiled with GHC?
body: <p>I'm using GHC 7.4 to compile the following function:</p>
  
  <pre><code>nodups' :: [Int] -&gt; Bool
  nodups' = ok empty
    where ok _ [] = True
          ok seen (n:ns) = not (n `member` seen) &amp;&amp; ok (n `insert` seen) ns
          member n word = testBit word n
          insert n word = setBit word n
          empty = 0 :: Int
  </code></pre>
  
  <p>The function looks for duplicate elements in a list of small integers.  The set <code>seen</code> is a representation of a set of small integers as a bit vector.  The profiler (run with <code>ghc -prof -auto-all</code>) claims that the <code>ok</code> function accounts for 22% of allocation overall.  Looking at the output with <code>-ddump-simpl</code>, I can't understand why this code is allocating.  I checked, and as far as I can tell it is <em>not</em> allocating a thunk for the call to <code>insert</code>.</p>
  
  <p>What should I look at to identify the part of my code that is allocating?</p>