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

Vlatko Basic vlatko.basic at gmail.com
Thu Jan 9 16:36:06 UTC 2014


Hi Artyom,

Yes, indeed.

But instance declarations wouldn't be needed because we already have all the 
instances for Either. The point would be to have them unified.
But it is a problem that there are no data constructor synonyms in Haskell. So 
at least pattern matching wouldn't be possible the simple way. Maybe 
ViewPatterns could (partially) solve that.


vlatko

-------- Original Message  --------
Subject: Re: [Haskell-cafe] Why Maybe exists if there is Either?
From: Artyom Kazak <yom at artyom.me>
To: haskell-cafe at haskell.org
Date: 09.01.2014 16:23

> Besides, even defining
>
> type Maybe a = Either () a
>
> in standard library wouldn’t be the same as
>
> data Maybe a = Nothing | Just a
>
> since in Haskell 98 type synonyms aren’t allowed in instance declarations, which
> means that programmers would still have to remember that `Maybe` is actually
> `Either ()` under-the-hood every time when writing an instance.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list