[ghc-steering-committee] Record syntax
Joachim Breitner
mail at joachim-breitner.de
Tue Jan 28 11:55:12 UTC 2020
Hi,
> Consider (f .x g .y h .z)
>
> (2) says this means ((((f .x) g) .y) h) .z), so that it parenthesises
> exactly like function application.
>
> (3) says it means (((f .x) (g .y)) (h .z)) which, while unambiguous,
> I dislike cordially.
>
> I propose to adopt (2).
I agree that “exactly like function application” is a great, simple
universal way of explaining the parsing.
But I can't stop pointing out that this is inconsistent if we insist
that `f r.x = f (r.x)`.
With function application, no space or space is irrelevant:
f r"" = f r "" ≠ f (r "") = f (r "")
You propose
f r.x ≠ f r .x = f (r .x) = f (r .x)
while I am still attached to
f r.x = f r .x ≠ f (r .x) = f (r .x)
I know that this will disappoint a few who want their code to look like
it does in some other languages (many object oriented langauges,
Ocaml), and who do not want to put in the extra parentheses. But in
this case I am leaning towards the elegance of _really_ saying “exactly
like function application”, not only syntactically, but also morally (a
record is a function on a finite set of field names.)
I find this very justifiable for a functional programming language.
And I find it very un-haskelly that going from a space to no space
between expressions makes a difference (I believe Simon Marlow shared
this reservation.)
If we do insist on “binds more tightly if no space”, then I am actually
in favor of “also binds more tightly if there is a space”, i.e. (3)
above, to avoid the whitespace-sensitivity.
So if it comes to a vote, I think these three options cover all
opinions so far?
* f r .x = (f r).x; f r.x = f (r.x) -- Simon’s (2)
* f r .x = (f r).x; f r.x = (f r).x) -- My take on it
* f r .x = f (r.x); f r.x = f (r.x) -- Simon’s (3)
Anything else?
If we vote, I hope we don't get too many abstinations. Nobody will be
personally offended if you vote “against” them (I hope), but whatever
outcome we have better have weight, and is supported by a high turnout.
And I think we should just vote; we keep rephrasing the same arguments
with different words.
Cheers,
Joachim
--
Joachim Breitner
mail at joachim-breitner.de
http://www.joachim-breitner.de/
More information about the ghc-steering-committee
mailing list