<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">If we had a sufficiently generalized "splat" operation to unpack tuples into argument or tuple lists, you could conceivably use it to do this:<div class=""><br class=""></div><div class="">typealias AB = (A,B)</div><div class="">typealias CD = (C,D)</div><div class="">typealias ABCD = (AB..., CD...)</div><div class=""><br class=""></div><div class="">func join<T, U>(_ a: (T...), _ b: (U...)) -> (T..., U...) {</div><div class=""> return (a..., b...)</div><div class="">}</div><div class=""><br class=""></div><div class="">func pop<T, U>(_ tuple: (T..., U)) -> ((T...), U) {</div><div class=""> let (a..., b) = tuple</div><div class=""> return (a, b)</div><div class="">}</div><div class=""><br class=""></div><div class="">func push<T, U>(_ tuple: (T...), _ back: U) -> (T..., U) {</div><div class=""> return (tuple..., back)</div><div class="">}</div><div class=""><br class=""></div><div class="">-Joe</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 30, 2016, at 9:14 PM, Andrew Bennett via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi Swift Evolution populace,</div><div class=""><br class=""></div><div class="">I'd like a <span style="color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class="">a way to concatenate tuple types together:</span><br class=""></div><div class=""><span style="color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class=""><br class=""></span></div><div class=""><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class=""><pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal" class=""><span style="color:rgb(167,29,93)" class="">typealias</span> ABCD <span style="color:rgb(167,29,93)" class="">=</span> (A,B)<span style="color:rgb(167,29,93)" class="">+</span>(C,D) <span style="color:rgb(150,152,150)" class="">// Same as (A,B,C,D)</span></pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class="">Also a way to allow tuples to be converted to other tuples that are the same when flattened:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class=""><pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal" class="">(a,(b,c),d) <span style="color:rgb(167,29,93)" class="">as</span> ((a,b),(c,d))</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class="">This proposal aims to make the minimal changes possible, with the most familiar syntax, and give tuples this power.</p><h3 style="margin-top:1em;margin-bottom:16px;line-height:1.43;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class=""><span style="font-size:large" class="">Examples</span><br class=""></h3><div class=""><font face="arial, helvetica, sans-serif" class="">These are things that will be possible after these changes.</font></div><h4 style="margin-top:1em;margin-bottom:16px;line-height:1.4;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class="">Joining two tuples together</h4><h4 style="margin-top:1em;margin-bottom:16px;line-height:1.4;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class=""><div class="" style="margin-bottom:16px;font-weight:normal"><pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal" class=""><span class="" style="color:rgb(167,29,93)">let</span> a <span class="" style="color:rgb(167,29,93)">=</span> (<span class="" style="color:rgb(0,134,179)">1</span>,<span class="" style="color:rgb(0,134,179)">2</span>), b <span class="" style="color:rgb(167,29,93)">=</span> (<span class="" style="color:rgb(0,134,179)">3</span>,<span class="" style="color:rgb(0,134,179)">4</span>)
<span class="" style="color:rgb(167,29,93)">let</span> c <span class="" style="color:rgb(167,29,93)">=</span> <span class="" style="color:rgb(0,134,179)">join</span>(a, b) <span class="" style="color:rgb(150,152,150)">// (Int,Int,Int,Int)</span></pre></div></h4><h4 style="margin-top:1em;margin-bottom:16px;line-height:1.4;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class="">Stack like operations on tuples</h4><div class="" style="margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'"><pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal" class=""><span class="" style="color:rgb(167,29,93)">let</span> (abcde) <span class="" style="color:rgb(167,29,93)">=</span> (<span class="" style="color:rgb(0,134,179)">1</span>,<span class="" style="color:rgb(0,134,179)">2</span>,<span class="" style="color:rgb(0,134,179)">3</span>,<span class="" style="color:rgb(0,134,179)">4</span>,<span class="" style="color:rgb(0,134,179)">5</span>)
<span class="" style="color:rgb(167,29,93)">let</span> (abcd,e) <span class="" style="color:rgb(167,29,93)">=</span> pop(abcde)
<span class="" style="color:rgb(167,29,93)">let</span> (abc,d) <span class="" style="color:rgb(167,29,93)">=</span> pop(abcd)
<span class="" style="color:rgb(167,29,93)">let</span> (abce) <span class="" style="color:rgb(167,29,93)">=</span> push(abc, e)
<span class="" style="color:rgb(0,134,179)">assert</span>(abce <span class="" style="color:rgb(167,29,93)">==</span> (<span class="" style="color:rgb(0,134,179)">1</span>,<span class="" style="color:rgb(0,134,179)">2</span>,<span class="" style="color:rgb(0,134,179)">3</span>,<span class="" style="color:rgb(0,134,179)">5</span>))</pre></div><h4 style="margin-top:1em;margin-bottom:16px;line-height:1.4;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class="">Chained ZipSequence</h4><div class=""><pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;color:rgb(51,51,51)" class=""><span class="" style="color:rgb(167,29,93)">let</span> a <span class="" style="color:rgb(167,29,93)">=</span> [<span class="" style="color:rgb(0,134,179)">1</span>,<span class="" style="color:rgb(0,134,179)">2</span>,<span class="" style="color:rgb(0,134,179)">3</span>]
<span class="" style="color:rgb(167,29,93)">let</span> b <span class="" style="color:rgb(167,29,93)">=</span> [<span class="" style="color:rgb(24,54,145)"><span class="" style="">"</span>a<span class="" style="">"</span></span>, <span class="" style="color:rgb(24,54,145)"><span class="" style="">"</span>b<span class="" style="">"</span></span>, <span class="" style="color:rgb(24,54,145)"><span class="" style="">"</span>c<span class="" style="">"</span></span>]
<span class="" style="color:rgb(167,29,93)">let</span> c <span class="" style="color:rgb(167,29,93)">=</span> [<span class="" style="color:rgb(0,134,179)">1</span><span class="" style="color:rgb(167,29,93)">.</span><span class="" style="color:rgb(0,134,179)">2</span>, <span class="" style="color:rgb(0,134,179)">2</span><span class="" style="color:rgb(167,29,93)">.</span><span class="" style="color:rgb(0,134,179)">3</span>, <span class="" style="color:rgb(0,134,179)">3</span><span class="" style="color:rgb(167,29,93)">.</span><span class="" style="color:rgb(0,134,179)">4</span>]
<span class="" style="color:rgb(167,29,93)">let</span> d <span class="" style="color:rgb(167,29,93)">=</span> [<span class="" style="color:rgb(0,134,179)">nil</span>, <span class="" style="color:rgb(0,134,179)">nil</span>, <span class="" style="color:rgb(0,134,179)">123</span>]
<span class="" style="color:rgb(167,29,93)">let</span> abc <span class="" style="color:rgb(167,29,93)">=</span> a<span class="" style="color:rgb(167,29,93)">.</span><span class="" style="color:rgb(0,134,179)">zip</span>(b)<span class="" style="color:rgb(167,29,93)">.</span><span class="" style="color:rgb(0,134,179)">zip</span>(c)<span class="" style="color:rgb(167,29,93)">.</span><span class="" style="color:rgb(0,134,179)">zip</span>(d) <span class="" style="color:rgb(150,152,150)">// AnySequence<(Int,String,Float,Int?)></span></pre></div><h4 style="margin-top:1em;margin-bottom:16px;line-height:1.4;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class="">Turn any function with a callback into one with a promise</h4><div class="" style="margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'"><pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal" class=""><span class="" style="color:rgb(167,29,93)">func</span> <span class="" style="color:rgb(121,93,163)">promise</span><A,B,C>(f: (A <span class="" style="color:rgb(167,29,93)">+</span> (B<span class="" style="color:rgb(167,29,93)">-></span><span class="" style="color:rgb(0,134,179)">Void</span>)) <span class="" style="color:rgb(167,29,93)">-></span> C) -> A -> (C, Promise<B>)</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'" class=""><span style="color:rgb(34,34,34);font-family:arial,sans-serif" class="">This proposal, and more examples, can be seen in more detail here:</span><br class=""></p><div class=""> <a href="https://github.com/therealbnut/swift-evolution/blob/therealbnut-tuple-manipulation/proposals/0000-tuple-operators.md" target="_blank" class="">https://github.com/therealbnut/swift-evolution/blob/therealbnut-tuple-manipulation/proposals/0000-tuple-operators.md</a><br class=""></div><div class=""><br class=""></div><div class="">I'll keep this file up to date over the course of the discussion, PRs are welcome.</div></div><div class=""><br class=""></div><div class=""><b class="">Related proposals:</b><br class=""></div><div class=""><br class=""></div><div class="">This proposal's use cases relate to at least a few other currently active proposals:</div><div class=""><ul class=""><li class=""><b class="">Compile-time parameters</b><br class=""></li><ul class=""><li class=""><b class=""><a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/5240" target="_blank" class="">http://thread.gmane.org/gmane.comp.lang.swift.evolution/5240</a></b></li></ul><li class=""><b class="">Contiguous Variables (A.K.A. Fixed Sized Array Type)</b></li><ul class=""><li class=""><b class=""><a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/4809" target="_blank" class="">http://thread.gmane.org/gmane.comp.lang.swift.evolution/4809</a><br class=""></b></li></ul><li class=""><b class="">Remove implicit tuple splat behavior from function applications<br class=""></b></li><ul class=""><li class=""><b class=""><a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/4681" target="_blank" class="">http://thread.gmane.org/gmane.comp.lang.swift.evolution/4681</a></b></li></ul></ul></div><div class="">Thanks!</div></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>