<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 22, 2016, at 7:43 PM, Robert Widmann &lt;<a href="mailto:devteam.codafi@gmail.com" class="">devteam.codafi@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Do you think there’s room for a more general&nbsp;<a href="https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms" class="">Pattern Synonyms-like</a>&nbsp;feature that could extend this to things that look tuple-y? &nbsp;We had a short conversation on Twitter 'round about the release of Swift 1.2 about Swiftz’s&nbsp;<a href="https://github.com/typelift/Swiftz/blob/master/Sources/HList.swift#L185" class="">HList</a>&nbsp;implementation and my desire to be able to destructure them into tuples for native pattern matching.</div></div></div></blockquote><br class=""></div><div>My personal favorite design for user-extensible pattern syntax is F#'s "active pattern" feature, which lets you declare a set of mutual exclusive, total or partial conditions along with a function body that computes which condition holds. For the specific case of container patterns, though, I feel like it's worth keeping a close association with Collection semantics, so that:</div><div><br class=""></div><div>- [] matches when the incoming collection's startIndex == endIndex,</div><div>- [&lt;pattern&gt;, &lt;pattern-list&gt;] fails if startIndex == endIndex, or else matches collection[startIndex] against &lt;pattern&gt; and recursively matches collection[startIndex.advancedBy(1)..&lt;endIndex] against [&lt;pattern-list&gt;]</div><div>- [&lt;pattern&gt;...] matches the remaining collection against &lt;pattern&gt;</div><div><br class=""></div><div class="">-Joe</div></body></html>