[Haskell-cafe] Why Maybe exists if there is Either?
bgamari.foss at gmail.com
Thu Jan 9 19:29:04 UTC 2014
Brandon Allbery <allbery.b at gmail.com> writes:
> On Thu, Jan 9, 2014 at 12:11 PM, Ben Foppa <benjamin.foppa at gmail.com> wrote:
>> Aside from the point made about typeclass instances, I don't see an issue
>> type Maybe = Either ()
>> nothing :: Maybe a
>> nothing = Left ()
>> just :: a -> Maybe a
>> just = Right
> Not until you try to pattern match on it....
Although with pattern synonyms this will become possible if I'm
pattern Nothing = Left ()
pattern Just a = Right a
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 489 bytes
Desc: not available
More information about the Haskell-Cafe