<div dir="ltr">Is there not precedent for having both &quot;mapLeft&lt;T&gt;(f: L -&gt; T) -&gt; Either&lt;T, R&gt;&quot; and &quot;mapRight&lt;T&gt;(f: R -&gt; T) -&gt; Either&lt;L, T&gt;&quot; ?<div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Jacob Bandes-Storch<br></div></div></div></div>
<br><div class="gmail_quote">On Wed, Dec 9, 2015 at 3:49 PM, Developer <span dir="ltr">&lt;<a href="mailto:devteam.codafi@gmail.com" target="_blank">devteam.codafi@gmail.com</a>&gt;</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">How would you write `map` for an unbiased Either.  You have to pick a side!<div><br></div><div>Our implementation happens to be the one standardized on by Scala, Haskell, ML, (and to a limited extent) F#.  For a less arbitrary reason, the use of &quot;Right as Correct&quot; is because Either, in all it’s Bifunctor-ial ways, has to admit two ways to map “across” itself.  To paraphrase the words of a friend &quot;There are lots of things in computer science we can leftMap”.  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.  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: <a href="https://github.com/non/cats/issues/189" target="_blank">https://github.com/non/cats/issues/189</a>).</div><div><div class="h5"><div><br></div><div><div><blockquote type="cite"><div>On Dec 9, 2015, at 6:44 PM, Ilias Karim &lt;<a href="mailto:ilias.karim@gmail.com" target="_blank">ilias.karim@gmail.com</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word">I’m sorry, I misunderstood. I guess an enum would be the appropriate choice, instead.<div><br></div><div>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.</div><div><br></div><div>Ilias</div><div><br><div><blockquote type="cite"><div>On Dec 9, 2015, at 3:43 PM, Dave DeLong &lt;<a href="mailto:delong@apple.com" target="_blank">delong@apple.com</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word">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.<div><br></div><div>Dave</div><div><br><div><blockquote type="cite"><div>On Dec 9, 2015, at 4:41 PM, Ilias Karim via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><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">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 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"><br></div><br 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"><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"><blockquote type="cite"><div>On Dec 9, 2015, at 3:35 PM, Jacob Bandes-Storch &lt;<a href="mailto:jtbandes@gmail.com" target="_blank">jtbandes@gmail.com</a>&gt; 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&#39;s feasible a user might want Either&lt;Int, String&gt;, not just Either&lt;ErrorType, T&gt;.<div><br></div><div>While I&#39;m not sure Left &amp; Right are the best choices, I don&#39;t think it&#39;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><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> </span><span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span><span> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style: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>&gt; On Dec 9, 2015, at 3:06 PM, Developer via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>&gt;<br>&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.  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>&gt;<br>&gt;<br>&gt; ~Robert Widmann (CodaFi)<br>&gt; _______________________________________________<br>&gt; swift-evolution mailing list<br>&gt;<span> </span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>&gt;<span> </span><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 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"><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=xwL-2FBGgqPlrQ1iwgQl3sGt18dMpXf8obemZVVg1ItXQ9pDN-2BhTk4Q3dg0whwqWekMPq4YoPRuUPMdrgxcyK9xUI5NAwJCBNm-2BGN0Gttp-2BeFAF3BK-2BrGHjXwlbnheV3GUDvVRMn5VnkPRiC4B0fj68rszLQVVojBpdmUnwrUO71czIe9-2BRmOd-2BSCVjq2OM2Xtc3veKqvXCBe2jrMNCEN0LKDP37B0Tz-2BJ0FnhlNhw6OU-3D" alt="" width="1" height="1" border="0" 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-width:0px!important;margin:0px!important;padding:0px!important"><span 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;float:none;display:inline!important"><span> </span></span><span 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;float:none;display:inline!important">_______________________________________________</span><br 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"><span 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;float:none;display:inline!important">swift-evolution mailing list</span><br 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"><a href="mailto:swift-evolution@swift.org" 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" target="_blank">swift-evolution@swift.org</a><br 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"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" 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" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br></div></div></div></blockquote></div><br></div></div></div></blockquote></div><br></div></div></div></div></blockquote></div><br></div></div>