... | ... | @@ -290,7 +290,7 @@ where `f .(g x)` means `(g x f)`. The oddness here is that the TDNR invocation |
|
|
I think this is probably worth it, although it's a little odd. To me, the ability to "stack up" postfix operations is rather important, and the fact that it doesn't fit nicely is the biggest shortcoming of this whole proposal. Can anyone improve it?
|
|
|
|
|
|
|
|
|
## Discussion
|
|
|
## Discussion and other design choices
|
|
|
|
|
|
|
|
|
### Works with any function
|
... | ... | @@ -419,7 +419,45 @@ muliple types with the same field; but not multiple functions with the |
|
|
same name.
|
|
|
|
|
|
|
|
|
## Qualified import
|
|
|
### Top-level disambiguation only
|
|
|
|
|
|
|
|
|
|
|
|
Consider this
|
|
|
|
|
|
|
|
|
```wiki
|
|
|
data R = MkR { x,y :: Int }
|
|
|
|
|
|
f1 :: R -> Int -> R
|
|
|
f1 r x = r { x = x }
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
Function `f1` is already allowed in Haskell 98; in the update `r {x=x}` the first `x`
|
|
|
can only be a field name, while the second binds as usual to the local
|
|
|
variable that shadows the top-level name. This is good because it's convenient
|
|
|
to use similar names for field names as for local variables. Indeed GHC's support
|
|
|
for punning makes this even more attractive.
|
|
|
|
|
|
|
|
|
|
|
|
But now look at `f2`:
|
|
|
|
|
|
|
|
|
```wiki
|
|
|
f2 :: R -> Int
|
|
|
f2 r x = r.x + x
|
|
|
```
|
|
|
|
|
|
|
|
|
Arguably the same story should apply. Just as the update notation tells which is
|
|
|
a field name, the dot notation does the same. So perhaps in TDNR, the `r.x` should
|
|
|
choose among **top-level** bindings for `x`, ignoring nested ones.
|
|
|
|
|
|
|
|
|
### Qualified import
|
|
|
|
|
|
|
|
|
|
... | ... | @@ -445,7 +483,12 @@ it! Maybe TDNR should choose among in-scope x's regardless of whether they are |
|
|
qualified or not.
|
|
|
|
|
|
|
|
|
## Record syntax
|
|
|
|
|
|
NB: GHC 6.12's existing record field disambiguation makes exactly this choice already.
|
|
|
See the [ user manual 7.3.14](http://www.haskell.org/ghc/dist/current/docs/html/users_guide/syntax-extns.html#disambiguate-fields).
|
|
|
|
|
|
|
|
|
### Record syntax
|
|
|
|
|
|
|
|
|
|
... | ... | |