title: Haskell Family Tree - Exam Preparation
body: <p>I'm doing an exam soon and need help with an exam question about family trees. I've done trees previously but only of this format: </p>
  
  <p><code>data Tree a = Empty | Leaf a | Node a (Tree a) (Tree a)</code></p>
  
  <p>So basically a tree that either empty or leaf nodes, or a node that has 2 trees that follow it recursively.
  Now I've been given this question:</p>
  
  <pre><code>                                DAN=DORIS
  
                 /                   |                          \
          JACK-PEGGY            CHRISTINE-PAUL                PHIL-JILL 
        /     |     \                                      /    /     |     \  
   JENNIFER LILLIAN TONY                              SCULA KENTON DAVID ELIZABETH
  
  This shows that Dan married Doris and their children were Jack (who married Peggy), 
  Christine (who married Paul) and Phil (who married Jill). The children of Jack and Peggy 
  were Jennifer, Lillian and Tony. Christine and Paul had no children. Phil and Jill’s 
  children were Shula, Kenton, David and Elizabeth. 
  Assume that any name appears in the tree at most once. Neglect the possibility of 
  second marriages. 
  
  (i) Give a Haskell algebraic datatype definition for family trees, and show how the 
      above tree would be represented using your datatype
  (ii) Using your datatype definition, write a Haskell function which, given the name 
       of a person and a family tree, returns the names of that person’s children, if 
       any.
  </code></pre>
  
  <p>Sorry that was the best I can draw of the tree shown in the paper - but its pretty obvious, Dan is married to Doris at the topmost, then has 3 kids Jack, Christine, and Phil, etc. </p>
  
  <p>So the tree type I used can't be used here, I was wondering what type definition is it this time (basically question 2.(i), and any ideas for (ii)?</p>