You want to write a recursive function for this. For each Tree constructor, you will need a different case in your function. For starters, you know that the depth of any Leaf is 1 , so
maxDepth :: Tree -> Int maxDepth (Leaf _) = 1 maxDepth (Branch2 c left right) = maximum [???] maxDepth (Branch3 c left center right) = maximum [???]
I will let you finish the rest of the function. You could do this in several different ways (for example, use max instead of maximum ).
source share