title: How to count the number of times a function was called, the FP way
body: <p>I am currently working through <a href="http://mitpress.mit.edu/sicp/">SICP</a> with Haskell. Exercise 1.15 asks how many times a function is called. The idea is probably that you should use the substitution method, but I would like to know how to do so in code.</p>
  
  <p>In an imperative language one can keep a global variable and increment it every time the function is called. But how would you go about it in Haskell (or the pure functional way)?</p>