title: Calling Helper functions within functions - Haskell
body: <p>I have 3 functions, the first one is a </p>
  
  <pre><code>toList :: Tree -&gt; [Integer]
  </code></pre>
  
  <p>the second is </p>
  
  <pre><code>sumTree :: Tree -&gt; Maybe Integer
  </code></pre>
  
  <p>which sums a the elements in a tree, filtering for some edge cases. My main function is </p>
  
  <pre><code>treeSum :: Tree -&gt; Maybe Integer
  </code></pre>
  
  <p>which I want to call the toList on the input to Tree then call sumTree on the output of the previous call. I don't know how to structure it together elegantly. What I did was</p>
  
  <pre><code>treeSum = sumTree (toList x)
  </code></pre>
  
  <p>but I am getting <code>x</code> not in scope.</p>