title: Haskell Tree Traverse Confused
body: <p>I'm very new to haskell and I just can't seem to understand this code:</p>
  
  <pre><code>data Tree a = Empty | Leaf a | Node a (Tree a) (Tree a)
  
  -- animals tree 
  animals :: Tree String
  animals = Node "elephant"
                (Node "bat"
                     (Leaf "aardvark")
                     (Node "cow"
                     (Leaf "chicken")
                      Empty))
                (Node "hare"
                     (Node "fox"
                           Empty
                           (Leaf "goat"))
                     (Leaf "jackal"))
  </code></pre>
  
  <p>Specifically, creating that data type its more complex than simple data types I attempted in class. The animals function creates the tree but how does it utilize that type to do so?</p>
  
  <p>Then traversing it with this function:</p>
  
  <pre><code>traverse :: (Tree a) -&gt; [a]
  traverse Empty = []
  traverse (Leaf x) = [x] --leaf returns list of 1 item
  traverse (Node x left_sub_tree right_sub_tree) =
   (traverse left_sub_tree) ++
    [x] ++
   (traverse right_sub_tree)
  </code></pre>
  
  <p>I'm not sure how this code works, probably because I'm not sure how that data type allows us  to make trees. What I can't see is basically the "links" beteen the type creates and how this algorithm uses those function types to create a tree. </p>
  
  <p>Help to understand this would be incredible, thanks!</p>