... | ... | @@ -121,16 +121,18 @@ code. TDNR is not "overloading" in the sense of type classes. |
|
|
The basic design is simple:
|
|
|
|
|
|
|
|
|
- There is a new lexeme, of the form `'.' varid`, which we call `dot_var`.
|
|
|
The part after the dot a simple unqualified name (not a qualified name).
|
|
|
|
|
|
- Extend the syntax of atoms:
|
|
|
|
|
|
```wiki
|
|
|
atom ::= var_qual -- Qualified variable name
|
|
|
| var_unqual -- Unqualified variable name
|
|
|
| '(' expr ')' -- Parenthesised expression
|
|
|
| atom '.' var_unqual -- TDNR invocation
|
|
|
| atom dot_var -- TDNR invocation
|
|
|
```
|
|
|
|
|
|
The part after the dot a simple unqualified name (not a qualified name).
|
|
|
For example, `a`, `a.f` and `a.f.g` are atoms.
|
|
|
|
|
|
- The dynamic semantcs of `a.f` is simply reverse application `(f a)`.
|
... | ... | @@ -342,3 +344,30 @@ propose *not* to apply it to record update, a construct that is already |
|
|
rather complicated to typecheck. I do not want to make it worse.
|
|
|
|
|
|
|
|
|
## section-style selection
|
|
|
|
|
|
|
|
|
|
|
|
We have the option to allow '(.x)' as a valid expression, with its meaning given by the translation
|
|
|
|
|
|
|
|
|
```wiki
|
|
|
(.x) === (\f -> f.x)
|
|
|
```
|
|
|
|
|
|
|
|
|
This allows things like
|
|
|
|
|
|
|
|
|
```wiki
|
|
|
map (.x) rs
|
|
|
```
|
|
|
|
|
|
|
|
|
and means that `(.x) f` is equivalent to `f.x`. The syntax and meaning is consistent with right-section, although it is not really a right-section.
|
|
|
|
|
|
|
|
|
|
|
|
What about `(.x.y)`? Does that expand to `(\f -> f.x.y)`?
|
|
|
|
|
|
|