I do like the idea of being able to end a function application with a
lambda, let, if, case, or do without having to use $ though. Would
something like the following grammar rules be problematic for parsing?
infixexp→ lexp qop infixexp
| - infixexp
| [fexp] lexp (*)
| aexp (*)
lexp → \ apat1 … apatn -> exp
| let decls in exp
| if exp [;] then exp [;] else exp
| case exp of { alts }
| do { stmts }
(*)
fexp → [fexp] aexp
aexp → qvar
| gcon
| literal
| ( exp )
| ( exp1 , … , expk )
| [ exp1 , … , expk ]
| [ exp1 [, exp2] .. [exp3] ]
| [ exp | qual1 , … , qualn ]
| ( infixexp qop )
| ( qop⟨-⟩ infixexp )
| qcon { fbind1 , … , fbindn }
| aexp⟨qcon⟩ { fbind1 , … , fbindn }
https://www.haskell.org/onlinereport/haskell2010/haskellch3.html
were I've added (*) to where I have added or removed lines (basically
I've moved function application from lexp to infixexp in order to allow
the last exp in a function application to be an lexp).
> At the moment the *only* robust way to pass a polymorphic function to a polymorphic function (here, you are passing Wrap to (.)) is to wrap it in a newtype, much as Wrap does.
Good to know.
Thanks! -Tyson