title: Get the sum and product of integres defined in a tree
body: <p>I have a little problem understanding how to to the following in Haskell:</p>
  
  <p>Lets say I have a statement similar to this ones: </p>
  
  <ul>
  <li>a * (b + c)</li>
  <li>a + (b * c)</li>
  <li>a + (b * ( c + d))</li>
  <li>a * (b + ( c * d))</li>
  <li>etc. etc.</li>
  </ul>
  
  <p>I want to express these statements in a tree and evaluate the result of each, for starters I defined the following data structure:</p>
  
  <pre><code>data statement = Number Int 
                 | Product statement statement 
                 | Sum statement statement
                 deriving (Eq, Show)
  </code></pre>
  
  <p>For an example Tree to work with, I used the following function:</p>
  
  <pre><code>a :: statement
  a = Product (Number 2) (Sum (Number 5) (Number 1))
  </code></pre>
  
  <p>Now I want to build a function treeResult which gives me the result of my statement defined, but I don't know how to approach this problem. The integer returned for the above statement should be 12.</p>
  
  <p>My first guess was to write a function that takes "statement" as a parameter and returns an int, for starters only with simple statements.</p>
  
  <pre><code>treeResult :: statement -&gt; Int
  treeResult (Number a) = a
  treeResult (Product (Number a) (Number b)) = a*b
  treeResult (Sum (Number a) (Number b)) = a+b
  </code></pre>
  
  <p>Now I know that I need something that works recursive but I don't know how to write it in haskell, can someone help me out here, please?</p>