<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>Well yeah, that's why I objected to this proposal. You keep talking as though you think I agree with you and are just quibbling on the name. But that's not true at all. You very specifically want to have a type that's more generic than a Result enum, and I very specifically want to avoid having a type that's that generic in the stdlib. Hence my vocal objections.<br></div>
<div>&nbsp;</div>
<div>-Kevin Ballard</div>
<div>&nbsp;</div>
<div>On Tue, Jan 26, 2016, at 01:57 PM, Developer wrote:<br></div>
<blockquote type="cite"><div>Because nowhere in the proposal do we use the words “Result Type”.<br></div>
<div>&nbsp;</div>
<div><blockquote type="cite"><span class="highlight" style="background-color: rgb(255, 255, 255)"><span class="colour" style="color:rgb(51, 51, 51)"><span class="font" style="font-family:'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'"><span class="size" style="font-size:16px">This proposal details the addition of a left-biased sum type to the Swift Standard Library. Earlier attempts at adding this have been too specifically focused on error handling (duplicating functionality&nbsp;</span></span></span></span><code style="font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size:14px;padding-top:0.2em;padding-right:0px;padding-bottom:0.2em;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:rgba(0, 0, 0, 0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51, 51, 51);">throws</code><span class="highlight" style="background-color: rgb(255, 255, 255)"><span class="colour" style="color:rgb(51, 51, 51)"><span class="font" style="font-family:'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'"><span class="size" style="font-size:16px">&nbsp;already provides), whereas this implementation will focus on data, organization, and type safety. We believe that adding the type to the standard library and simultaneously emphasizing its use cases -that is, when you need a type that represents exactly 2 disjoint possibilities- can dispel the confusion caused in other languages and quell the conflict with&nbsp;</span></span></span></span><code style="font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size:14px;padding-top:0.2em;padding-right:0px;padding-bottom:0.2em;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;background-color:rgba(0, 0, 0, 0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51, 51, 51);">throws</code><span class="highlight" style="background-color: rgb(255, 255, 255)"><span class="colour" style="color:rgb(51, 51, 51)"><span class="font" style="font-family:'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'"><span class="size" style="font-size:16px">.</span></span></span></span><br></blockquote></div>
<div>&nbsp;</div>
<div><blockquote type="cite"><div>On Jan 26, 2016, at 4:55 PM, Kevin Ballard &lt;<a href="mailto:kevin@sb.org">kevin@sb.org</a>&gt; wrote:<br></div>
<div>&nbsp;</div>
<div><div><div>By my count, this is the third time I've said this: I don't want genericity of type. The Result type is only useful because it carries the specific meaning of having one "success" variant and one "failure" variant. It may look structurally identical to a left-biased Either type, but the specific naming here is very important. By trying for genericity, you're losing the specific meaning of the Result type and thus defeating the entire point of having a Result type.<br></div>
<div>&nbsp;</div>
<div>-Kevin Ballard<br></div>
<div>&nbsp;</div>
<div>On Tue, Jan 26, 2016, at 01:50 PM, Developer wrote:<br></div>
<blockquote type="cite"><div>Ah, so that’s what this has been. &nbsp;When I say “Either” you immediately jump to “Haskell’s Either” when what I really mean is the structure forming the Either type. &nbsp;Because I get the feeling you and Chris are coming from this from two different directions I’ve tried to be generic in my speech. &nbsp;To me, both implementations are the same, one just happens to have a more immediately scintillating naming scheme. &nbsp;By my count, this is the third time I’ve said this:<br></div>
<div>&nbsp;</div>
<div>I am open to name changes, but we must preserve the genericity of the type. &nbsp;<br></div>
<div>&nbsp;</div>
<div>You haven’t yet convinced me of the latter half of that point. &nbsp;Perhaps we should start again: How does Result, and the semantics is carries with it, maintain the genericity of the type over, say, something called Choice or XOR? &nbsp;Down the road, when Swift decides to adopt a more generic approach or attempts to abstract over this kind of type, I’d like to say we were forward-thinking enough to have anticipated this rather than have to deal with un-Resultifying a datatype that should have been generic to start with.<br></div>
<div>&nbsp;</div>
<blockquote type="cite"><div>On Jan 26, 2016, at 4:40 PM, Kevin Ballard &lt;<a href="mailto:kevin@sb.org">kevin@sb.org</a>&gt; wrote:<br></div>
<div>&nbsp;</div>
<div>You've mentioned Rust many times, but I don't understand why. Rust does _not_ have an Either type. In fact, Rust's success is a great example of how Either is unnecessary. What Rust does have is a Result&lt;T,E&gt; type, and the lack of a more generically-named Either type was an intentional decision (with pretty much the same rationale that I've been giving).<br></div>
<div>&nbsp;</div>
<div>-Kevin Ballard<br></div>
<div>&nbsp;</div>
<div>On Tue, Jan 26, 2016, at 09:25 AM, Developer wrote:<br></div>
<blockquote type="cite"><div>Which is why I hope the proposal doesn't come off as "let's play copycat". &nbsp;That said, its success in languages that share either paradigms or common heritage with Swift cannot be discounted so easily. &nbsp;Rust, for example, with no exceptions mechanism in place has used an Either to great effect. &nbsp;F# with one in place offers the even more general Core.Choice that is often wrapped by framework authors and augmented with library-specific semantics as they see fit. &nbsp;C++ (through boost) and D chose to implement this pattern without tags, and made the type variadic instead. &nbsp;In all cases the result is the same: An increase in the power of each language, a new class of declarative programs being written, and richer libraries because of all these.<br></div>
<div>&nbsp;</div>
<div>Currently, swift does not have the necessary language features to produce a variant, nor does it have the ability or the desire to factor this out with a structural typing scheme (see the last round of discussions). &nbsp;So I see inclusion as the next most logical path.<br></div>
<div>&nbsp;</div>
<div>If 3rd party packages are supposed to be first-class, then I have no problem dropping this. &nbsp;But for now if I import two packages that both export this type I have no recourse other than to drop one or the other or risk linker errors or needless qualification that reduces readability and muddies intent. &nbsp;A stronger module system or a stronger inclusion/exclusion mechanism invalidates one of our core motivations - to reduce duplicate implementations - but for now I don't see movement on that front.<br></div>
<div>&nbsp;</div>
<div>~Robert Widmann<br></div>
<div>&nbsp;</div>
<div>2016/01/26 10:59、Chris Lattner &lt;<a href="mailto:clattner@apple.com">clattner@apple.com</a>&gt; のメッセージ:<br></div>
<div>&nbsp;</div>
<blockquote type="cite"><blockquote type="cite"><div>On Jan 25, 2016, at 11:20 PM, Developer &lt;<a href="mailto:devteam.codafi@gmail.com">devteam.codafi@gmail.com</a>&gt; wrote:<br></div>
<div>&nbsp;</div>
<div>The proposal does not exist because it is "hard or bad" to define the type, but because it factors out a common pattern. &nbsp;<br></div>
</blockquote><div>&nbsp;</div>
<div>I know you intend that to be a positive statement, but design patterns are not always seen as a good thing. &nbsp;See the criticism section of: <a href="https://en.m.wikipedia.org/wiki/Software_design_pattern">https://en.m.wikipedia.org/wiki/Software_design_pattern</a> for example.<br></div>
<div>&nbsp;</div>
<div>We have a good language feature (enums/ADTs) that makes the win of Either extremely small or a loss (when you factor in the loss of specificity for a problem domain).<br></div>
<div>&nbsp;</div>
<div>The bar for getting something into the stdlib is very high, and intentionally so. &nbsp;Merely existing in some other language isn't enough, it needs to pull its weight given the context of Swift, and even there it needs to have strong justification. &nbsp;Swift is intentionally designed so that third party packages can be on the same level as the standard library.<br></div>
<div>&nbsp;</div>
<div>-Chris<br></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<blockquote type="cite"><div>Adding language features on top of it should only serve to increase the power of the pattern, not decrease the effectiveness of the data type. &nbsp;An Either with optional projections, for example, is literally the partial projection functions (called in Haskell [sometimes] fromLeft and fromRight).<br></div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>~Robert Widmann<br></div>
<div>&nbsp;</div>
<div>2016/01/26 2:02、Chris Lattner &lt;<a href="mailto:clattner@apple.com">clattner@apple.com</a>&gt; のメッセージ:<br></div>
<div>&nbsp;</div>
<blockquote type="cite"><div>&nbsp;</div>
<blockquote type="cite"><div>On Jan 25, 2016, at 10:27 PM, Developer via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div>
<div>&nbsp;</div>
<div>Are you opposed to the name or the semantics?<br></div>
<div>&nbsp;</div>
<div>I will not accept a revision that reduces the level of abstraction of the current proposal. &nbsp;I will, however, accept name changes. &nbsp;Result, though, I believe is out of the question. &nbsp;It strongly implies a common but pointed set of semantics that discourage thinking of this type as data and more as an alternative to throws. &nbsp;I do not wish to emphasize the error case, or the theoretical case, I wish to encourage the general case. &nbsp;We must remember that despite Rust's success, they do not have to live alongside an exceptions mechanism like Either does.<br></div>
</blockquote><div>&nbsp;</div>
<div>Here is my concern: &nbsp;Swift enums should be good enough that we don’t need an Either type. &nbsp;If defining your own custom enum is hard or bad, then we should fix that.<br></div>
<div>&nbsp;</div>
<div>There are a number of concepts floating around that would make enums better in various ways. &nbsp;One specific one would be to synthesize optional accessors that line up with enum cases.<br></div>
<div>&nbsp;</div>
<div>What will the advantage of Either be once enums get even more fully baked?<br></div>
<div>&nbsp;</div>
<div>-Chris<br></div>
</blockquote></blockquote></blockquote></blockquote></blockquote></blockquote></div>
</div>
</blockquote></div>
</blockquote><div>&nbsp;</div>
</body>
</html>