DiscriminatedUnion Protocol

I found an older thread that is relevant to the idea of active patterns: Generalized pattern matching. The example in that thread was based on functional-style list destructuring. I like your syntax better than what I had come up with in that thread. The example might look something like this:

extension Collection {
    case empty, element(Element, rest: SubSequence) {
        if self.isEmpty { 
           return empty
        } else {
           let secondIndex = self.indexAfter(self.startIndex)
           return element(self[self.startIndex], self[secondIndex..<endIndex])
        }
    }
}