<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="https://stackoverflow.com/questions/324311/symbolic-simplification-in-haskell-using-recursion">Symbolic simplification in Haskell (using recursion?)</a>  </p>
</blockquote>



<p>The simplifications I have in mind are</p>

<pre><code>0*e = e*0 = 0
1*e = e*1 = 0+e = e+0 = e-0 = e
</code></pre>

<p>and simplifying constant subexpressions, e.g. <code>Plus (Const 1) (Const 2)</code> would become <code>Const 3</code>. I would not expect variables (or variables and constants) to be concatenated: <code>Var "st"</code> is a distinct variable from <code>Var "s"</code>. </p>

<p>For example <code>simplify(Plus (Var "x") (Const 0))= Var "x"</code></p>

Well, can't you apply pattern matching to the individual cases?
```
```
simplify (Plus (Const 0) (Expr x)) = simplify (Expr x)
simplify (Plus (Expr x) (Const 0)) = simplify (Expr x)
simplify (Mult (Const 0) _) = Const 0
simplify (Mult _ (Const 0)) = Const 0
– … and so on
```
```
EDIT: Yes, of course … recursion added.