Add fixity for (==) and (/=)
Eric Mertens
emertens at gmail.com
Tue Sep 18 15:34:41 UTC 2018
Do we have any other good examples where we've got an operator that is
considered associative where the result type isn't identical to the
argument types? It's much more common to allow the types to vary when
there's only one associativity that makes sense for the way an operator is
intended to be used.
a -> a -> a
While it's true that focusing on Bool, (==) satisfies associativity in its
truth table, the types don't work out so cleanly. Outside of Bool it starts
to matter which associativity you pick.
(\x y z -> (x == y) == z) :: Eq a => a -> a -> Bool -> Bool
(\x y z -> x == (y == z)) :: Eq a => Bool -> a -> a -> Bool
Making == associative is just going to lead to harder to understand code
and will require people to memorize which arbitrary choice about the
associativity of the operation was selected by the mailing list in order to
make sense of the types of code using multiple ==.
I see no gain here, and I'd prefer to leave == as is.
Best regards,
Eric Mertens
On Tue, Sep 18, 2018 at 2:34 AM C Maeder <chr.maeder at web.de> wrote:
> Hi,
>
> infixr seeems right for an equivalence (==) since implication is usually
> also right associative.
>
> Implication "==>" corresponds to "<=" on Bool, which might be confusing.
> Reverse implication (>=) should be left associative, then.
>
> Cheers Christian
>
> Am 17.09.2018 um 11:28 schrieb Dannyu NDos:
> > Well, infixr is friendlier to parsers.
> >
> > 2018년 9월 17일 (월) 오후 6:22, David Feuer <david.feuer at gmail.com
> > <mailto:david.feuer at gmail.com>>님이 작성:
> >
> > Looks good to me! Do you have an opinion about infixl vs infixr?
> >
> > Libraries mailing list
> > Libraries at haskell.org <mailto:Libraries at haskell.org>
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
> >
> >
> >
> > _______________________________________________
> > Libraries mailing list
> > Libraries at haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
> >
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20180918/a8058f79/attachment.html>
More information about the Libraries
mailing list