[ghc-steering-committee] Records again
Joachim Breitner
mail at joachim-breitner.de
Tue Dec 17 10:36:53 UTC 2019
[continuation, hit sent too soon, sorry]
Oh, and here is a nice way to justify the JS variant in a very
functionally motivated way. Not sure if it is helpful, though, but it
certainly is a cute angleā¦
A record r with fields foo and bar can be thought of as a _function_
with domain {.foo, .bar} (and a dependent return type, but we are
talking syntax, not types).
With that point of view, the syntax
r .foo
_is_ simply function application. And we do not need _any_ custom
mental parsing rules at all, and get
f r.field y = ((f r).field) y
f r .field y = ((f r).field) y
and now of course you write
f (r.x)
or
f (r .x)
just like you would write
f (g x)
Cheers,
Joachim
--
Joachim Breitner
mail at joachim-breitner.de
http://www.joachim-breitner.de/
More information about the ghc-steering-committee
mailing list