Algebraic Data Types in Swift

11 thoughts
last posted Feb. 8, 2015, 9:19 p.m.

2 earlier thoughts

0

This works (as is but not sure if it would work once we start adding other things):

protocol TreeLike {}
enum Tree:TreeLike {
    case Empty
    case Leaf(Int)
    case Node(TreeLike, TreeLike)
}

8 later thoughts