<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<style id="EHTipGlobalStyle">.EHTipToolTip * {background: inherit;font-family: inherit;font-size: inherit;font-size-adjust: none;font-stretch: normal;line-height: inherit;font-variant: normal;border: 0px;text-transform: inherit;color: inherit;font-style: inherit;text-decoration: inherit;margin: 0px 0px 0px 0px;padding: 0px 0px 0px 0px;float: none;display: inline;cursor: default;}
.EHTipReplacer, .EHTipKey, .EHTipAudio {cursor: pointer;}
.EHTipToolTip hr {margin: 0.4em 0;display: block;border: 1px inset;}
.EHTipTranslation {font-style: normal;}
.EHTipTranslation a {color: #000099;font-style: normal;text-decoration: none;}
.EHTipTranslation a:hover {background: inherit;color: #000000;text-decoration: underline;}
</style>
</head>
<body style="background-color: rgb(255, 255, 255); color: rgb(0, 0,
0);" bgcolor="#FFFFFF" text="#000000">
Hi Nickolay,<br>
<br>
Yes, that was my first idea too, but String is more often used in
reporting errors in Either's Left, so just an example.<br>
<br>
> ... or <em>can unambiguously determine the cause</em> ...<br>
Not always when Maybe is used.<br>
<br>
<br>
> ... is more readable ...<br>
The words Maybe (..) are fine, but the reason I asked is that it
seems to me that we have two distinct elements for the same thing,
instead of two distinct synonyms for the same thing.<br>
<br>
<br>
vlatko<br>
<br>
<blockquote style="border-left: 2px solid #330033 !important;
border-right: 2px solid #330033 !important; padding: 0px 15px 0px
15px; margin: 8px 2px;"
cite="mid:CAF1ivP-icfSB-pgDFRa7R1mibBq_m==t2-owD-oK-FvXLg3nQw@mail.gmail.com"
type="cite"><!--[if !IE]><DIV style="border-left: 2px solid #330033; border-right: 2px solid #330033; padding: 0px 15px; margin: 2px 0px;"><![endif]--><span
style="color:#000000;" class="headerSpan">
<div class="moz-cite-prefix">-------- Original Message --------<br>
Subject: Re: [Haskell-cafe] Why Maybe exists if there is
Either?<br>
From: Nickolay Kudasov <a class="moz-txt-link-rfc2396E" href="mailto:nickolay.kudasov@gmail.com"><nickolay.kudasov@gmail.com></a><br>
To: <a class="moz-txt-link-abbreviated" href="mailto:vlatko.basic@gmail.com">vlatko.basic@gmail.com</a><br>
Cc: <a class="moz-txt-link-rfc2396E" href="mailto:haskell-cafe@haskell.org">"haskell-cafe@haskell.org"</a>
<a class="moz-txt-link-rfc2396E" href="mailto:haskell-cafe@haskell.org"><haskell-cafe@haskell.org></a><br>
Date: 09.01.2014 16:14<br>
</div>
<br>
<br>
</span>
<div dir="ltr">
<div class="markdown-here-wrapper"
id="markdown-here-wrapper-638598" style="">
<p style="margin:1.2em 0px!important">Hi Vlatko,</p>
<p style="margin:1.2em 0px!important">Actually, <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">Maybe</code>
can be seen as <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">Either
() a</code>. Not <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">String</code>
or <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">Int</code>
because then you would have multiple <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">Nothing</code>s
(if <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">Left
""</code> is Nothing then what would <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">Left
"hello"</code> be?). So <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">Either
e a</code> is (generally) somewhat <em>bigger</em> than <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">Maybe
a</code>.</p>
<p style="margin:1.2em 0px!important">Since <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">Either</code>
can be used to represent strictly bigger types, you may not
want it sometimes. <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">lookup</code>
function (to find element in a list by its index) is an
example. It is unnecessary to keep extra information in <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">()</code>
or <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">String</code>
or <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">Int</code>
about what caused failure. So if we either <em>don’t care
what caused failure</em> or <em>can unambiguously
determine the cause</em> <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">Maybe</code>
suits better (is more readable) than <code
style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px
0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px
solid
rgb(234,234,234);background-color:rgb(248,248,248);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline">Either
()</code>.</p>
<p style="margin:1.2em 0px!important">Nick</p>
</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">2014/1/9 Vlatko Basic <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:vlatko.basic@gmail.com" target="_blank">vlatko.basic@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello Cafe,<br>
<br>
With my current knowledge of Haskell, I do not see why is
there Maybe if we have Either.<br>
<br>
For example, Functor and Monad instances (and many others)
of Maybe and Either are the same (except for fail).<br>
<br>
In other words, this should hold:<br>
<br>
Maybe a = Either String a -- String or something
else<br>
Nothing = Left ""<br>
Just a = Right a<br>
<br>
<br>
I'm curious to find out what was the reasoning to make
Maybe?<br>
What is the added value with introducing it?<br>
In which situations the above substitution does not hold?<br>
<br>
<br>
<br>
Best regards,<br>
<br>
vlatko<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a moz-do-not-send="true"
href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a moz-do-not-send="true"
href="http://www.haskell.org/mailman/listinfo/haskell-cafe"
target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote>
</div>
<br>
</div>
<!--[if !IE]></DIV><![endif]--></blockquote>
<br>
</body>
</html>