[Haskell-cafe] Why Maybe exists if there is Either?

Brandon Allbery allbery.b at gmail.com
Thu Jan 9 15:35:32 UTC 2014


On Thu, Jan 9, 2014 at 10:26 AM, Vlatko Basic <vlatko.basic at gmail.com>wrote:

> I put String because I'm currently thinking about error handling, and Left
> String is the usual way of reporting failure, and I see Maybe as a type for
> reporting errors, failures and similar.
>

Actually, the fact that all you can convey is "something failed" makes
Maybe not a good error reporting type. And this is fine; there is still the
"no value" niche (Perl's undefined, SQL's NULL, etc.) --- and the evidence
from C's NULL that an *out of band* representation is often a very good
idea (and from IEEE754's NaN that multiple out of band values is often a
very bad idea).

Also, a point that seems to often be missed in considering what is "more
important": ultimately, what is *most* important is letting the programmer
do what they need to do with a minimum of fuss or extra work. Predefining
very useful stuff like Maybe which could be reinvented on the fly based on
Either is about minimizing even the trivial extra work. Pedagogy is only
rarely a useful design goal.

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140109/851c00c2/attachment.html>


More information about the Haskell-Cafe mailing list