<br><br><div class="gmail_quote">On Wed, Jun 22, 2011 at 1:25 PM, pipoca <span dir="ltr">&lt;<a href="mailto:eliyahu.ben.miney@gmail.com">eliyahu.ben.miney@gmail.com</a>&gt;</span> wrote:</div><blockquote class="gmail_quote" 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; ">
<span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">Is there any reason why we don&#39;t have either anonymous disjoint union<br></span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">types, or why some of the proposals here (e.g. type (:|:) a b = Either<br>
</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">a b ) haven&#39;t been implemented, or put into the standard libraries<br></span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">(and publicised in beginner texts)?</span></blockquote>
<div><br></div><div>I know that {-# LANGUAGE TypeOperators #-} has been in GHC for a while, but I&#39;m not sure how widely accepted among other Haskell implementations it is. </div><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">It seems to me that you&#39;d need an additional function:</div>
either&#39; :: (a -&gt; c) -&gt; (b -&gt; d) -&gt; Either a b -&gt; Either c d<br></blockquote><div><br></div><div> import Control.Arrow (+++, |||)</div><div><br></div><div>The &#39;+++&#39; operator from ArrowChoice already does what you need here. And the &#39;|||&#39; operator is a more generic form of the &#39;???&#39; operator I mentioned earlier.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
if we want to map a and d over ad using either&#39; to get<br>
bcef :: [B :|: C :|: E :|: F]<br>
it wouldn&#39;t work, we&#39;d get<br>
bcef :: [(B :|: C) :|: (E :|: F)]<br>instead, which is presumably not what we wanted...<br></blockquote><div><br></div><div>Actually, we do want [(B :|: C) :|: (E :|: F)] in this case. It&#39;s important for generic programming.</div>
<div><br></div><div>However, these types are associative, so we could develop a standard set of re-association operators.</div><div><br></div></div>