<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">On 05/30/2013 01:45 PM, Dan Burton
wrote:<br>
</div>
<blockquote
cite="mid:CALSygwe8F-nz=3p3j4npUm+WU9Sw+x8sseq+cfnyfNzG7nxfAg@mail.gmail.com"
type="cite">We have already right-biased Eithers in Haskell for
Functor, Applicative, and Monad. We should be consistent and
right-bias it for Foldable, Traversable, and similar typeclasses.
Left-biasing can still be accomplished with a newtype wrapper, and
perhaps we should consider including this in the standard
libraries as well.
<div>
<br>
</div>
</blockquote>
Keep in mind that `errors` can provide the `Left`-biased versions
because it already has the appropriate newtype for doing so:
`EitherR`.<br>
<blockquote
cite="mid:CALSygwe8F-nz=3p3j4npUm+WU9Sw+x8sseq+cfnyfNzG7nxfAg@mail.gmail.com"
type="cite">
<div>Until the change happens, I'd suggest recommending that
"errors" users requiring this functionality lean on the "lens"
instances.</div>
<div><br>
</div>
<div>-- Dan Burton</div>
<div>
<br>
<br>
<div class="gmail_quote">On Thu, May 30, 2013 at 1:12 PM,
Shachaf Ben-Kiki <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:shachaf@gmail.com"
target="_blank">shachaf@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 class="im">On Thu, May 30, 2013 at 12:53 PM, Gabriel
Gonzalez <<a moz-do-not-send="true"
href="mailto:gabriel439@gmail.com">gabriel439@gmail.com</a>>
wrote:<br>
> I'm surprised that `Either` does not have a
`Foldable` instance of the form:<br>
><br>
> import Data.Foldable<br>
> import Data.Monoid<br>
><br>
> instance Foldable (Either e) where<br>
> foldMap f (Left _) = mempty<br>
> foldMap f (Right r) = f r<br>
><br>
> foldr _ z (Left _) = z<br>
> foldr f z (Right r) = f r z<br>
><br>
> In other words, the above instance would behave like
the `Maybe` `Foldable`<br>
> instance, treating `Left` in the same way as
`Nothing`.<br>
><br>
> This came up in the context of an issue raised on the
`errors` package:<br>
><br>
> <a moz-do-not-send="true"
href="https://github.com/Gabriel439/Haskell-Errors-Library/issues/16"
target="_blank">https://github.com/Gabriel439/Haskell-Errors-Library/issues/16</a><br>
><br>
> I could provide an orphan instance for `Either` in
the `errors` package, but<br>
> I wanted to ask if it was possible to incorporate the
instance directly into<br>
> `Data.Foldable`.<br>
><br>
<br>
</div>
This instance should exist. There's been a couple of
discussion on<br>
libraries@ before. One of them is at<br>
<<a moz-do-not-send="true"
href="http://www.haskell.org/pipermail/libraries/2012-July/018246.html"
target="_blank">http://www.haskell.org/pipermail/libraries/2012-July/018246.html</a>>.<br>
<br>
I wrote a patch for base at one point --<br>
<<a moz-do-not-send="true"
href="http://shachaf.net/0001-Add-Foldable-and-Traversable-instances-for-Either-e-.patch"
target="_blank">http://shachaf.net/0001-Add-Foldable-and-Traversable-instances-for-Either-e-.patch</a>><br>
-- but didn't go through the rest of the process at the
time.<br>
<br>
Right now `lens` has an orphan instance for this, by the
way.<br>
<span class="HOEnZb"><font color="#888888"><br>
Shachaf<br>
</font></span>
<div class="HOEnZb">
<div class="h5"><br>
_______________________________________________<br>
Libraries mailing list<br>
<a moz-do-not-send="true"
href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
<a moz-do-not-send="true"
href="http://www.haskell.org/mailman/listinfo/libraries"
target="_blank">http://www.haskell.org/mailman/listinfo/libraries</a><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>