Ok I found the key quote in one of the duplicate issues #31560:
This is a difficult parser corner case. I’ve wrestled with it, but there is no straightforward solution. The problem is that generally the right way to parse
f(x) :: A where B
is asf(x) :: (A where B)
becausewhere
makes types and the right side of::
has to be a type. For 1-line function definitions only though, we want(f(x) :: A) where B
, but we don’t know it’s a function definition until we see the following=
, and by then it’s too late. So you need to writefunction
(which I think is more readable for such elaborate definitions anyway), or parenthesize thef(x) :: A
part.
Basically function
tips off the parser soon enough to treat the where
clause properly, but the =
only shows up after the where
clause when it’s too late. Now I have a little bit more clarity to this old gripe I had, though I still don’t know the issues with the 2 anonymous forms. I at least would like the anonymous function
block to work as well as the named one if it were possible without breaking changes.