Once I got a hint for fold()'s signature, I was able to figure out the rest. map implementation was tricky, since scala's type inferencing didn't recognise Leaf() as a Tree type. Had to peek at answers to realise that the trick was to do type annotation for Leaf() i.e. Leaf(x): Tree[B]