title: Haskell binary tree parsing
body: <p>I am learning about building and parsing binary trees in Haskell and I found a program example that I can't quite understand how works.. So the code is:</p>
  
  <pre><code>module Main where
  
  data TTT aa = Leaf [aa] | Node (TTT aa) (TTT aa)  deriving (Show,Eq);
  
  a :: Num a =&gt; Integer -&gt; Integer; 
  a x = x^2; 
  
  ff_a :: TTT Integer -&gt; TTT Integer; 
  ff_a t = mm a t; 
  
  mm :: (Integer -&gt; Integer) -&gt; TTT Integer -&gt; TTT Integer; 
  mm f (Node a1 a2) = Node(mm f a1) (mm f a2); 
  mm f (Leaf n) = Leaf(new_mm f n); 
  
  new_mm :: (Integer -&gt; Integer) -&gt; [Integer] -&gt; [Integer]; 
  new_mm f (a:a1) = f a : new_mm f a1; 
  new_mm f [] = []; 
  
  tree =   
      Node   
          (Node   
              (Node   
                  ((Leaf[16,-5,19]))
                  ((Leaf[14,24,-55,27]))
              )  
              (Node   
                  ((Leaf[37,11,64]))
                  ((Leaf[-14,6,29]))
              )  
          )  
          (Node   
              (Node   
                  ((Leaf[10,-19,22]))
                  ((Leaf[3,4,5,-7]))
              )  
              (Node   
                  ((Leaf[31,29,13]))
                  ((Leaf[18,38,-4]))
              )  
          )  
  
  
  main :: IO ();
  
  t0 = tree      
  t1 = ff_a tree 
  
  main = do
  
      print t0;
      print t1;
  </code></pre>
  
  <p>Could someone explain to me how really functions <code>mm</code> and <code>new_mm</code> work? And what does <code>Integer -&gt; Integer</code> and <code>TTT integer -&gt; TTT integer</code> means and what data type is that?</p>