I've been using the Tree class today, and I see some room for improvement. One is that construction and pattern matching should more like conventional Scala case classes, and the other is that there needs to be an equals implementation.
There should be symmetry between the constructors Tree.leaf, Tree.node and the pattern matching, which right now is gotten by Tree.Node. If we really can't have a concrete case class, Scala convention calls for constructors Tree.Leaf.apply, Tree.Node.apply, and corresponding unapply methods in the same objects.
Equality doesn't work the way I would expect. Having an Equal instance is perfectly great, but it needs to be in addition to the conventional equals method, not instead of. I'm running unit tests on trees, and requiring that I use Equal makes them unnecessarily horrible to write. The following fails, even though the trees are the same.
assertResult(Tree.leaf("hi"))(Tree.leaf("hi"))Instead, I have to invoke special scalaz magic.
assert(Equal[Tree[String]].equal(Tree.leaf("hi"), Tree.leaf("hi")))I would also like to improve toString, but I see that is probably impossible with the level of laziness Tree is using.
I'll see about making a merge request with some changes unless people really dislike my ideas.
Jeff