Sections for associative operators: Parse `(x ++ y ++)` as `(\ z -> x ++ y ++ z)`
Motivation
I rather often run into this issue with sections, in situation where I generalize code from one individual thing to a list of things, e.g. when trying to go from x ++ y ++ z
to map (x ++ y ++) zs
. This usually does not parse:
lambda = (\ s -> "hello" ++ ", " ++ s) "world!"
section = ("hello" ++ ", " ++) "world!"
{- ERROR:
The operator ‘++’ [infixr 5] of a section
must have lower precedence than that of the operand,
namely ‘++’ [infixr 5]
in the section: ‘"hello" ++ ", " ++’
-}
Proposal
Couldn't we parse sections like (x ++ y ++)
as (\ dummy -> x ++ y ++ dummy)
?
What else could (x ++ y ++)
mean, so we refuse to parse it?