<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Alternatively :) or more like, something to think about, an Alt
instance for Either.<br>
<br>
class Alt f where<br>
(<!>) :: f a -> f a -> f a<br>
<br>
instance Alt Either where<br>
Right b <!> _ = Right b<br>
Left a <!> x = x</p>
<p><a class="moz-txt-link-freetext" href="https://hackage.haskell.org/package/semigroupoids/docs/Data-Functor-Alt.html">https://hackage.haskell.org/package/semigroupoids/docs/Data-Functor-Alt.html</a></p>
<p>There is something iffy about Monoid e => Alternative (Either
e) but I can't put my finger on it.<br>
</p>
<br>
<div class="moz-cite-prefix">On 06/14/2018 08:37 PM, Nathan van
Doorn wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CA+reurVFo3SEP1tZ2oDm9Mn9CTD0bW8fX23Bxd1hfOJ2W+avUw@mail.gmail.com">
<div dir="ltr">Proposal: add:
<div><br>
</div>
<div><font face="monospace, monospace">instance Monoid e =>
Alternative (Either e) where</font></div>
<div><font face="monospace, monospace"> empty = Left mempty</font></div>
<div><font face="monospace, monospace"> Left a <|> Left b
= Left (a `mappend` b)</font></div>
<div><font face="monospace, monospace"> Right a <|> _ =
Right a</font></div>
<div><font face="monospace, monospace"> _ <|> Right b =
Right b</font></div>
<div><font face="monospace, monospace"><br>
</font></div>
<div><font face="monospace, monospace">instance Monoid e =>
MonadPlus (Either e) where</font></div>
<div><font face="monospace, monospace"> ...</font></div>
<div><font face="monospace, monospace"><br>
</font></div>
<div><font face="arial, helvetica, sans-serif">to base.</font></div>
<div><font face="arial, helvetica, sans-serif"><br>
</font></div>
<div><font face="arial, helvetica, sans-serif">This is a
reasonably obvious instance which I am pretty sure is law
abiding.</font></div>
<div><font face="arial, helvetica, sans-serif"><br>
</font></div>
<div><font face="arial, helvetica, sans-serif">It'd be useful
for defining a series of computations which may fail, where
we only care about one success.</font></div>
</div>
<!--'"--><br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Libraries mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Libraries@haskell.org">Libraries@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a>
</pre>
</blockquote>
<br>
</body>
</html>