title: Haskell traverse tree inorder preorder postorder
body: <p>I have the following Haskell data definition:</p>
  
  <pre><code>data Tree = Leaf Int | Node Int Tree Tree deriving Show
  </code></pre>
  
  <p>and I wrote the following programs to traverse trees preorder, inorder and postorder:</p>
  
  <pre><code>preorder(Leaf n) = n
  preorder(Node n t0 t1) = [n] ++ preorder t0 ++ preorder t1
  
  inorder(Leaf n) = n
  inorder(Node n t0 t1) = inorder t0 ++ [n] ++ inorder t1
  
  postorder(Leaf n) = n
  postorder(Node n t0 t1) = postorder t0 ++ postorder t1 ++ [n]
  </code></pre>
  
  <p>The error that I get is:</p>
  
  <pre><code>- Type error in application  
  *** Expression     : preorder t0 ++ preorder t1  
  *** Term           : preorder t1  
  *** Type           : Int  
  *** Does not match : [a]  
  </code></pre>
  
  <p>I need to return a list that contains all tree integers in appropriate order. Any help is highly appreciated as I am new to Haskell.</p>