<div dir="ltr">A tuple of (A?, B?) has four states: (nil, nil) / (A, nil) / (nil, B) / (B, nil)<div><br></div><div>Whereas Either<A,B> has only two states: .Left(A) or .Right(B).</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Jacob<br></div></div></div></div>
<br><div class="gmail_quote">On Wed, Dec 9, 2015 at 3:41 PM, Ilias Karim <span dir="ltr"><<a href="mailto:ilias.karim@gmail.com" target="_blank">ilias.karim@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>What are the advantage over using a tuple? One great feature about tuples is being able to name parameters so you can dispel ambiguity.</div><div><div class="h5"><div><br></div><br><div><blockquote type="cite"><div>On Dec 9, 2015, at 3:35 PM, Jacob Bandes-Storch <<a href="mailto:jtbandes@gmail.com" target="_blank">jtbandes@gmail.com</a>> wrote:</div><br><div><div dir="ltr">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<Int, String>, not just Either<ErrorType, T>.<div><br></div><div>While I'm not sure Left & 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 & error cases.<br><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr"><div>Jacob<br></div></div></div></div>
<br><div class="gmail_quote">On Wed, Dec 9, 2015 at 3:32 PM, Ilias Karim via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Robert,<br>
<br>
I agree with your recommendation of a generic Either type.<br>
<br>
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>
<br>
Ilias<br>
<div><div><br>
> On Dec 9, 2015, at 3:06 PM, Developer via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br>
><br>
> 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. 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. 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" rel="noreferrer" target="_blank">https://github.com/typelift/Swiftx/blob/master/Swiftx/Either.swift#L16</a>).<br>
><br>
><br>
> ~Robert Widmann (CodaFi)<br>
> _______________________________________________<br>
> swift-evolution mailing list<br>
> <a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div></div></blockquote></div><br></div></div></div>
</div></blockquote></div><br></div></div></div></blockquote></div><br></div></div>