title: Haskell: Calling a function multiple times within the same line
body: <p>If I have a function like the following</p>
  
  <pre><code>f x = if g x /= Nothing then g x else False
  </code></pre>
  
  <p>will <code>g</code> be called twice in <code>f</code> or does Haskell 'cache' the result of <code>g x</code> after the first instance for possible later use in the same line? I'm trying to optimise some code and I don't know if functions in the style of the one above are twice as computationally expensive as I want them to be.</p>
  
  <p>Thanks in advance.</p>