<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=""><div><blockquote type="cite" class="">As an alternative to a semantically-neutral Either type, it might be worth considering the possibility of anonymous structural sum types (similar to how tuples are the structural analog of structs).</blockquote><div><br class=""></div><div>John mentioned that these are a massive complication for type systems when I proposed them as a possible way to implement throwing multiple error types. &nbsp;Do you agree with that?</div><div><br class=""></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 10, 2015, at 10:06 AM, Nick Shelley via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Can you explain why you think it's better to just define your own two-variant enum rather than having a built-in Either type, or point me to the evidence that Rust found in favor of this approach?<div class=""><br class=""></div><div class="">I had to create my own Either type for some code I wrote semi-recently and wished it was built in, so I'm wondering why I apparently shouldn't have wished that, but been glad that I'm creating my own.<br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Dec 10, 2015 at 1:34 AM, Kevin Ballard via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u class=""></u>




<div class=""><div class="">I support the addition of a Result, and I encourage people to look at&nbsp;<a href="https://doc.rust-lang.org/stable/std/result/index.html" target="_blank" class="">https://doc.rust-lang.org/stable/std/result/index.html</a>&nbsp;for a good example of how this can be done well. I'd like a Result&lt;T,E&gt; in Swift that looks similar.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">I do not support the addition of Either. As far as I am aware, the only compelling argument in favor of an Either type is "because Haskell has one", but I believe it's commonly recognized that Haskell's Either is not particularly good. It's a weird name for results (which Result covers), and for other cases it's usually better just to define your own two-variant enum anyway. Rust provides some evidence in favor of this, as this was the rationale for why Rust has a Result&lt;T,E&gt; but no Either, and it turns out there has been no need to add an Either.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">-Kevin Ballard</div><div class=""><div class="">
<div class="">&nbsp;</div>
<div class="">On Wed, Dec 9, 2015, at 04:01 PM, T.J. Usiyan via swift-evolution wrote:<br class=""></div>
<blockquote type="cite" class=""><div dir="ltr" class="">I hope that we can get both Either and Result into the standard lib. A great situation might be if Result were some sort of newtype declaration of Either.<br class=""></div>
<div class=""><div class="">&nbsp;</div>
<div class=""><div class="">On Thu, Dec 10, 2015 at 5:25 AM, Developer via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex" class=""><div style="word-wrap:break-word" class=""><div class="">There is!&nbsp; That’s what the Bifunctor typeclass is for.&nbsp; But if you had to pick just one of them to implement some Functor constraint - some canonical `map` function, would you pick the side that you filled with Errors, or the side that you filled with Values?<br class=""></div>
<div class=""><div class=""><div class="">&nbsp;</div>
<div class=""><div class="">&nbsp;</div>
<div class=""><blockquote type="cite" class=""><div class="">On Dec 9, 2015, at 6:52 PM, Jacob Bandes-Storch &lt;<a href="mailto:jtbandes@gmail.com" target="_blank" class="">jtbandes@gmail.com</a>&gt; wrote:<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div dir="ltr" class=""><div class="">Is there not precedent for having both "mapLeft&lt;T&gt;(f: L -&gt; T) -&gt; Either&lt;T, R&gt;" and "mapRight&lt;T&gt;(f: R -&gt; T) -&gt; Either&lt;L, T&gt;" ?<br class=""></div>
<div class=""><div class="">&nbsp;</div>
<div class=""><div class=""><div dir="ltr" class=""><div class="">Jacob Bandes-Storch<br class=""></div>
</div>
</div>
</div>
<div class="">&nbsp;</div>
<div class=""><div class="">On Wed, Dec 9, 2015 at 3:49 PM, Developer <span dir="ltr" class="">&lt;<a href="mailto:devteam.codafi@gmail.com" target="_blank" class="">devteam.codafi@gmail.com</a>&gt;</span> wrote:<br class=""></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex" class=""><div style="word-wrap:break-word" class=""><div class="">How would you write `map` for an unbiased Either.&nbsp; You have to pick a side!<br class=""></div>
<div class="">&nbsp;</div>
<div class="">Our implementation happens to be the one standardized on by Scala, Haskell, ML, (and to a limited extent) F#.&nbsp; For a less arbitrary reason, the use of "Right as Correct" is because Either, in all it’s Bifunctor-ial ways, has to admit two ways to map “across” itself.&nbsp; To paraphrase the words of a friend "There are lots of things in computer science we can leftMap”.&nbsp; In Haskell, such a thing is represented by the Functor typeclass, and due to the way type application works in that language, the convention has been to map over the rightmost side.&nbsp; But this isn’t Haskell, so our reasons can get even more theoretical than that (if you really want to get into what it looks like when you implement Covariant mapping down the left side of a common Bifunctor like Either, Cats has already had a thorough discussion on the subject:&nbsp;<a href="https://github.com/non/cats/issues/189" target="_blank" class="">https://github.com/non/cats/issues/189</a>).<br class=""></div>
<div class=""><div class=""><div class="">&nbsp;</div>
<div class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 9, 2015, at 6:44 PM, Ilias Karim &lt;<a href="mailto:ilias.karim@gmail.com" target="_blank" class="">ilias.karim@gmail.com</a>&gt; wrote:<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div style="word-wrap:break-word" class=""><div class="">I’m sorry, I misunderstood. I guess an enum would be the appropriate choice, instead.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">As far as left/right goes, the decision to have left or right be the “correct” value is entirely arbitrary and should be left up to the developer. It should be a convention at best.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">Ilias<br class=""></div>
<div class=""><div class="">&nbsp;</div>
<div class=""><blockquote type="cite" class=""><div class="">On Dec 9, 2015, at 3:43 PM, Dave DeLong &lt;<a href="mailto:delong@apple.com" target="_blank" class="">delong@apple.com</a>&gt; wrote:<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div style="word-wrap:break-word" class=""><div class="">With a tuple, you have to do “(left: T?, right: U?)”, whereas with an Either you are guaranteed to always have one or other other; never both and never neither. That is not guaranteed with the tuple.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">Dave<br class=""></div>
<div class=""><div class="">&nbsp;</div>
<div class=""><blockquote type="cite" class=""><div class="">On Dec 9, 2015, at 4:41 PM, Ilias Karim via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">What are the advantage over using a tuple? One great feature about tuples is being able to name parameters so you can dispel ambiguity.<br class=""></div>
<div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">&nbsp;</div>
<div class="">&nbsp;</div>
<div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><blockquote type="cite" class=""><div class="">On Dec 9, 2015, at 3:35 PM, Jacob Bandes-Storch &lt;<a href="mailto:jtbandes@gmail.com" target="_blank" class="">jtbandes@gmail.com</a>&gt; wrote:<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div dir="ltr" class=""><div class="">The idea of using Left/Right is to remain agnostic to what sorts of things users might want to put in. It's feasible a user might want Either&lt;Int, String&gt;, not just Either&lt;ErrorType, T&gt;.<br class=""></div>
<div class="">&nbsp;</div>
<div class=""><div class="">While I'm not sure Left &amp; Right are the best choices, I don't think it's particularly worrisome when it comes to errors, as the general type-safety of the language will prevent users from mixing up success &amp; error cases.<br class=""></div>
<div class=""><div class="">&nbsp;</div>
<div class=""><div class=""><div dir="ltr" class=""><div class="">Jacob<br class=""></div>
</div>
</div>
</div>
<div class="">&nbsp;</div>
<div class=""><div class="">On Wed, Dec 9, 2015 at 3:32 PM, Ilias Karim via swift-evolution<span class=""></span><span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span><span class=""></span>wrote:<br class=""></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex" class=""><div class="">Hi Robert,<br class=""></div>
<div class="">&nbsp;</div>
<div class="">I agree with your recommendation of a generic Either type.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">However, I find your use of “Right” as the “Correct” value (whatever that means) of an instance of an Either type a little perplexing. While clever, it is exactly the kind of convention that easily leads to misunderstandings about the nature of the type itself ie. is it right and left or wrong and correct? At least that is my first impression after scanning your code.<br class=""></div>
<div class="">&nbsp;</div>
<div class="">Ilias<br class=""></div>
<div class=""><div class=""><div class="">&nbsp;</div>
<div class="">&gt; On Dec 9, 2015, at 3:06 PM, Developer via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div>
<div class="">&gt;<br class=""></div>
<div class="">&gt; It’s high time the STL admitted some kind of disjoint union type, at the very least because it’s such a minor addition it seems a shame to leave it out.&nbsp; Whatever feelings one may have about `throws`, the lack of standardizing on a datatype representing choice has caused the community to get creative and create many disjoint implementation of the same concept over and over and over again.&nbsp; To that end, I propose the STL ship with an Either type; We at TypeLift have already got our own we’d like to model it on (<a href="https://github.com/typelift/Swiftx/blob/master/Swiftx/Either.swift#L16" target="_blank" class="">https://github.com/typelift/Swiftx/blob/master/Swiftx/Either.swift#L16</a>).<br class=""></div>
<div class="">&gt;<br class=""></div>
<div class="">&gt;<br class=""></div>
<div class="">&gt; ~Robert Widmann (CodaFi)<br class=""></div>
<div class="">&gt; _______________________________________________<br class=""></div>
<div class="">&gt; swift-evolution mailing list<br class=""></div>
<div class="">&gt;<span class=""></span><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""></div>
<div class="">&gt;<span class=""></span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
<div class="">&nbsp;</div>
<div class="">_______________________________________________<br class=""></div>
<div class="">swift-evolution mailing list<br class=""></div>
<div class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""></div>
<div class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
</div>
</div>
</blockquote></div>
<div class="">&nbsp;</div>
</div>
</div>
</div>
</div>
</blockquote></div>
<div class="">&nbsp;</div>
<div class=""><img style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;min-height:1px!important;width:1px!important;border-top-width:0px!important;border-right-width:0px!important;border-bottom-width:0px!important;border-left-width:0px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;margin-left:0px!important;padding-top:0px!important;padding-right:0px!important;padding-bottom:0px!important;padding-left:0px!important" border="0" height="1" width="1" alt="" src="https://www.fastmailusercontent.com/proxy/4df6c17a672dbc1d79d49d287594fe30b7741153e237ed5ade771b61cb74d019/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d38777c4d223642474761705c627151396777615c633377447138346d407856683f62656d6a56565761394478515930744e4d223248645b6431533467603778677177556b6d405174395f60525575505d4462776873697b49387559453e41477a43424e4d6d2232474e40374474707d22324566414643324b4d22324277484a68577c626e686566533745544676525d4e65365e6b60525963443240366a663832737a7c4156565f6a6240746d655e6772755f4731336a7945693d2232425d6f446d22324353465a61723f4d423854736336756b417678534245623a627d4e43454e403c4b444053373240345a7d22324a40364e686c6e4867763f455d23344/open" class=""><span style="font-family:Helvetica" class=""><span style="font-size:12px" class=""><span class=""></span></span></span><span style="font-family:Helvetica" class="">_______________________________________________</span><br class=""></div>
<div class=""><span style="font-family:Helvetica" class="">swift-evolution mailing list</span><br class=""></div>
<div class=""><a style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""></div>
<div class=""><a style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
</div>
</blockquote></div>
<div class="">&nbsp;</div>
</div>
</div>
</div>
</blockquote></div>
<div class="">&nbsp;</div>
</div>
</div>
</div>
</blockquote></div>
<div class="">&nbsp;</div>
</div>
</div>
</div>
</div>
</blockquote></div>
<div class="">&nbsp;</div>
</div>
</div>
</div>
</blockquote></div>
<div class="">&nbsp;</div>
</div>
<div class=""><img style="min-height:1px!important;width:1px!important;border-top-width:0px!important;border-right-width:0px!important;border-bottom-width:0px!important;border-left-width:0px!important;margin-top:0px!important;margin-bottom:0px!important;margin-right:0px!important;margin-left:0px!important;padding-top:0px!important;padding-bottom:0px!important;padding-right:0px!important;padding-left:0px!important" border="0" height="1" width="1" alt="" src="https://www.fastmailusercontent.com/proxy/eaf8391373f58c23a00e2cd63ddca2382cb6699f0eab09dea9e411831e753659/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d333647466f63605267687b6e4b6d6a6567346a636b676939477d223247495953385632587a41347b65585b434f6f6d6a717444665360566a69314555447d223242315d22364c413d223647375651725c6c4630597857744e68676d466537636e667a464e474778573f68456a71624d22364e483a54583e4d2236456d4f6b62454a49396864653378764937474247683d647f6861623c4257735d466237567a754c603a674a76663231347979696759623a7d223641614f4c6b646338594d2232466b45717039673d4d6a577f4c67575a425d2236447f445d223641776d603d2236475a667838326a7e69487252646b66795878565576537d4c617a624774665e614d23344/open" class=""><br class=""></div>
</div>
</div>
</div>
<div class="">&nbsp;</div>
<div class="">_______________________________________________<br class=""></div>
<div class="">
swift-evolution mailing list<br class=""></div>
<div class=""> <a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""></div>
<div class=""> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
<div class="">&nbsp;</div>
</blockquote></div>
</div>
<div class=""><img style="min-height:1px!important;width:1px!important;border-top-width:0px!important;border-right-width:0px!important;border-bottom-width:0px!important;border-left-width:0px!important;margin-top:0px!important;margin-bottom:0px!important;margin-right:0px!important;margin-left:0px!important;padding-top:0px!important;padding-bottom:0px!important;padding-right:0px!important;padding-left:0px!important" border="0" height="1" width="1" alt="" src="https://www.fastmailusercontent.com/proxy/dac11682feb81afe48fd1697c255e91cacf8027bfe0f5271f04d9fc45023e85f/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d3148765176786c673171614a7d2236454230345272776e416d22324a503b62713275693462445d223643763d6a483148796f4a5e4b4b446950314161784f6a6e6d22324477393164614c403935386c4d223648457c49745452767867697438513b40743d22364c4c6d4167507c64496876403d666b637176723a7f6a623932336a40375957617b657535345639617631786a4a6558664b4d2232407030365c4436356a4d6b43414935326a4664665c4b69547f6d22364c4867617565707442694035303450536278683a4837536a693443766347775946423837495c444f4267725e47386f614d23344d23344/open" class=""><br class=""></div>
<div class=""><u class="">_______________________________________________</u><br class=""></div>
<div class="">swift-evolution mailing list<br class=""></div>
<div class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""></div>
<div class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div>
</blockquote><div class="">&nbsp;</div>

<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=Kyo40-2Fb6mK7qqe0u18o4nlmNW45gwtJGUNOsveb6UxNIz3Kk-2BnN6xYRMl0ogAPwyNCvSyc8NpF8AtzUSPUARBs8Qki8LEvltC5ipPaudKcIKtFxgCisoobKHRYzP6Ai2gxgSwMnPynjwTVs0JFawaA3EQaOxZT6JeWBSeWwFQMZJgMWYVkC8MQNjkES-2FYW0oozf8D-2BdHor8oEbK0sSNVNnCpyr3ERRte4OWHkPcf5Og-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" class="">
</div></div></div>


<br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=RoDF4MveSEMYBIqIJA6ub1g8cOZ-2BVYvqV-2FqygPhjPn-2BOTNfPjhRzF-2BdWFvoXLCno-2BAk1MMzw4kGqpVifwJTpvbbTnHPO34FoPGRyqLTvZRb8XZs6x-2BprxZXJb66lH-2F2gQv8-2FIkTvrMKsUUvHSz8WHyx7tibrGK-2FRSSIcHBIRcitBJXmz0M4ZT6cpIemSikDF83f6QVjrs4RczSa7N55aRqDqhxW30tiNBNNIVeemvmY-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=eLFMrKDT8iBxZ-2Fbnk-2BZqvSchNN-2FvYXdceA0T7VxwkAceocgQ-2FgFahTFS6zDwnqbbPEuqSqMf-2F2wxSVlyGKCxCjG3voW8CLYaj5aypczb7WcDYl-2FjgkPWE1-2BzY-2BZsUMpwA0dcRm4-2BUaR9xW9MiMMsGdn01bnpZxR5p8AwLirDwF-2FQy0FZTNkf2cWpEEO3yyHPi0Lyhf6SIo6w-2BCUKrlwBXrXQCwdJthZkXgEGzAq3Ock-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</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=""></body></html>