[Haskell-beginners] Maybe and Just

Greg Graham greg at grahamtx.net
Thu Mar 26 23:05:56 UTC 2015


On Thu, Mar 26, 2015 at 4:04 PM, martin <martin.drautzburg at web.de> wrote:
> Am 03/26/2015 um 11:06 AM schrieb Shishir Srivastava:
>> Hi,
>>
>> After reading and re-reading the haskell tutorials I don't happen to see a very convincing or appealing reason for
>> having these data types.
>>
>> Can anyone please explain where Maybe and Just provide the sort of functionality that cannot be achieved in other
>> languages which don't have these kind.

I'm reading the little book, _Maybe Haskell_ [1], and I'm finding it
very helpful on this topic. The whole Maybe paradigm is one of the
reasons I decided to learn Haskell.

I had previously started learning Go, and although I was initially
attracted by its simplicity, I came to dislike how it used return
values to indicate errors. Go typically returns a pair of values from
operations that can fail. One value is the normal return value, and
the other is an error code. At first look, I thought it was similar to
Haskell's Maybe. However, after doing a little Go programming, I
realized there's a big difference. The error codes in Go can be
ignored, sometimes accidentally, but you can't ignore Haskell's Maybe.
Sure, it's possible to respond poorly, but you do have to respond, all
because (Just 42) is not the same thing as (42).

1: https://robots.thoughtbot.com/maybe-haskell-our-newest-book


More information about the Beginners mailing list