title: Expression evaluation tree in Haskell
body: <p>In an exam today I was asked to create an expression evaluation tree in Haskell.
  Usually the answer is as simple as:</p>
  
  <pre><code>data Expr = Value Integer
            | Add Expr Expr
            | Sub Expr Expr
            | Mul Expr Expr
  </code></pre>
  
  <p>And to evaluate it, you just use a function such as:</p>
  
  <pre><code>eval :: Expr -&gt; Integer
  eval (Value x) = x
  eval (Add l r) = eval l + eval r
  eval (Sub l r) = eval l - eval r
  eval (Mul l r) = eval l * eval r
  </code></pre>
  
  <p>However today, we were given a data type:</p>
  
  <pre><code>data Op = Add
          | Sub
          | Mul
  </code></pre>
  
  <p>So I assumed to create the expression tree I could just do:</p>
  
  <pre><code>data Expr = Value Integer
            | Op Expr Expr
  </code></pre>
  
  <p>And use the same <code>eval</code> function. However, I have since written that function and loaded it into GHCI, but it does not seem to work.
  Could anyone explain why this doesn't work?</p>