3 ms·
> Functions which are designed to read well as infix operators usually require operator sections or `flip` to adapt them for use as combinators. It occurs to m
by nybble41 6y ago
> Functions which are designed to read well as infix operators usually require operator sections or `flip` to adapt them for use as combinators.
It occurs to me that this could have been avoided at the language level by defining infix notation to implicitly flip the arguments. For example,
x / 3 == (/ 3) x == (/) 3 x
x ++ "suffix" == (++ "suffix") x == (++) "suffix" x
x `splitBy` "," == (`splitBy` ",") x == splitBy "," x
(The left and center forms are valid and equivalent Haskell code today; the right form has the arguments flipped.) I think on the whole this would have made it easier to transition between the curried forms and the infix forms, since it's more common to want to bind the RHS of an infix operator than the LHS. I would also say that e.g. `(/) 3` reads more naturally as "divided by three" than its actual definition as "three divided by …". No doubt we could find a few counterexamples where it reads better to have the LHS first, though I can't think of any at the moment.
Of course, it's much too late to be changing something so fundamental at this point. Even as an extension it would cause far too much confusion.