BrainF*** in the Swift type system

Excellent idea! Sadly we cannot involve parameter packs here to build a generic tuple in this way. Wonder if the bar can be lifted, so we can have something like:

protocol Nat {
    associatedtype Tuple<E>
}
struct Zero: Nat {
    typealias Tuple<E> = ()
}
struct Succ<Pred: Nat>: Nat {
    typealias Tuple<E> = (E, repeat each Pred.Tuple<E>)
}

print(Succ<Succ<Succ<Zero>>>.Tuple<Int>.self) // (Int, Int, Int)
2 Likes