... | ... | @@ -419,14 +419,63 @@ muliple types with the same field; but not multiple functions with the |
|
|
same name.
|
|
|
|
|
|
|
|
|
## Qualified import
|
|
|
|
|
|
|
|
|
|
|
|
Consider this
|
|
|
|
|
|
|
|
|
```wiki
|
|
|
module R where
|
|
|
data R = MkR { x,y::Int }
|
|
|
|
|
|
module Foo where
|
|
|
import qualified R -- Note qualified
|
|
|
f1, f2 :: R -> Int
|
|
|
f1 r = R.y r
|
|
|
f2 r = r.x
|
|
|
```
|
|
|
|
|
|
|
|
|
Here the `R.y` in `f1` is an ordinary qualified name. But what should
|
|
|
`r.x` be allowed? Remember plain `x` isn't in scope; only `R.x` is. But
|
|
|
we don't want to have to force you to write `r.R.x`, even if we could parse
|
|
|
it! Maybe TDNR should choose among in-scope x's regardless of whether they are
|
|
|
qualified or not.
|
|
|
|
|
|
|
|
|
## Record syntax
|
|
|
|
|
|
|
|
|
|
|
|
TDNR can apply to record construction and pattern-matching, as indeed
|
|
|
already happens in GHC with `-XDisambiguteRecordFields`. However I
|
|
|
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.
|
|
|
already happens in GHC with `-XDisambiguteRecordFields`. For example,
|
|
|
you could say
|
|
|
|
|
|
|
|
|
```wiki
|
|
|
a = R { x = 3 }
|
|
|
f (R {x = xval}) = xval
|
|
|
```
|
|
|
|
|
|
|
|
|
even if there were many x's in scope.
|
|
|
|
|
|
|
|
|
|
|
|
However I propose *not* to apply it to record update. Specifically
|
|
|
I propose not to take the expression
|
|
|
|
|
|
|
|
|
```wiki
|
|
|
r { x=3 }
|
|
|
```
|
|
|
|
|
|
|
|
|
and try to figure out which of many in-scope x's you mean by looking at the type of 'r'.
|
|
|
That's be possible, but it gets complicated: what about `(f v) {x=3}`? Record update
|
|
|
is already rather complicated to typecheck. I do not want to make it worse.
|
|
|
|
|
|
|
|
|
## Section-style selection
|
... | ... | |