Retrieve annotation from a tree annotated with a Monoid
Since this is a relatively simple question, 4 days is enough waiting for a more knowledgeable answer.

Your implementation of tag is correct and there is neither much room for improvement, nor there really is other ways to do it. You can replace Append x left right with Append x _ _ like you did for Single, and that's about the change you can make.


  Originally, I had implemented the Append ... case as:


That implementation was just wrong, consider what the two implementations return for your first example: 100 != 100 * 10 * 10.


  I'm not sure if I can assume that the [a] in [B] is
  already populated.


You can assume it is populated, you cannot have instances of algebraic data types with missing elements.

What you were trying to do probably is ensuring that an invariant, namely tag (Append x left right) == tag left &lt;&gt; tag right, is satisfied. This is the duty of a smart constructor. In this case the other function (+++ operator) you were asked to implement in the homework.