Algebraic Data Types in Swift

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

4 earlier thoughts

0

Of course that's fixed to being a Tree of Ints.

enum Tree<T>:TreeLike {
    case Empty
    case Leaf(T)
    case Node(TreeLike, TreeLike)
}

which kills the REPL with:

LLVM ERROR: unimplemented IRGen feature! non-fixed multi-payload enum layout
Assertion failed: (err == 0), function ~Mutex, file /SourceCache/lldb_KLONDIKE/lldb_KLONDIKE-320.3.100/source/Host/common/Mutex.cpp, line 246.
Abort trap: 6

And TreeLike isn't even the suitable generic.

6 later thoughts