"Elvis" operator (?:) as a reverse infix form of "fromMaybe"

Brandon Allbery allbery.b at gmail.com
Sun Oct 13 13:23:10 UTC 2013

On Sun, Oct 13, 2013 at 12:30 AM, Edward Kmett <ekmett at gmail.com> wrote:

> Seen in code without prior knowledge `fromMaybe` can have its meaning
> intuited. (?:) on the other hand comes across as gratuitous.

Worse, if you're at all familiar with C or languages which borrowed its
ternary operator, your expectation is that it will be related to Bool, not
Maybe a. (And no, I wouldn't recommend it for that either; the next
question is figuring out how the then and else legs are distinguished...
and I don't consider the ternary operator particularly readable anyway.)

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/libraries/attachments/20131013/bd9c6a65/attachment.html>

More information about the Libraries mailing list