[Haskell-cafe] Why Maybe exists if there is Either?
Patrick Mylund Nielsen
haskell at patrickmylund.com
Thu Jan 9 17:17:42 UTC 2014
On Thu, Jan 9, 2014 at 12:12 PM, Brandon Allbery <allbery.b at gmail.com>wrote:
> On Thu, Jan 9, 2014 at 11:52 AM, Vlatko Basic <vlatko.basic at gmail.com>wrote:
>> > ... what exactly is the problem with using appropriate data types in
>> appropriate places ...
>> It is a good thing. Very good. But I do not think all library writers are
>> using it in correct places. But that's another problem.
> In Haskell it's even a solved one: use an appropriate typeclass. We have
> several error-like typeclasses. Admittedly, if some library does not take
> advantage of this your recourse may be to submit a patch.
> And you still seem to be fixated on the notion that Maybe is only for
> errors. What exactly is the error in "user did not provide an optional
Indeed. I use Maybe for non-errors, namely optional values, all the time.
To compare with some other languages: Maybe is like a nil vs. non-nil
pointer. Either is like returning two values/a tuple of Foo and Error.
(For that matter, I sometimes use Either when a value can be either
something or the other, but neither of them are errors.)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe