GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2023-02-21T15:33:32Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/23004Typed holes should take record wildcards into account2023-02-21T15:33:32ZJaro ReindersTyped holes should take record wildcards into account## Summary
When using record wildcards together with typed holes, you don't get very useful information.
This is especially painful if you are using record wildcards as a workaround for #12376 (as suggested in comment https://gitlab.ha...## Summary
When using record wildcards together with typed holes, you don't get very useful information.
This is especially painful if you are using record wildcards as a workaround for #12376 (as suggested in comment https://gitlab.haskell.org/ghc/ghc/-/issues/12376#note_125684). And also if you are using typed holes in combination with tools like [wingman](https://haskellwingman.dev/) which gives typed holes superpowers.
## Steps to reproduce
```haskell
{-# LANGUAGE RecordWildCards #-}
data Foo = Foo {foo :: Int}
test :: Foo
test = Foo {..}
where
foo = _
```
Gives the suggestion:
```
T.hs:8:11: error:
• Found hole: _ :: p
Where: ‘p’ is a rigid type variable bound by
the inferred type of foo :: p
at T.hs:8:5-11
• In an equation for ‘foo’: foo = _
In an equation for ‘test’:
test
= Foo {..}
where
foo = _
• Relevant bindings include
foo :: p (bound at T.hs:8:5)
test :: Foo (bound at T.hs:6:1)
|
8 | foo = _
| ^
```
## Expected behavior
GHC should say that the type of the hole must be `Int` because that is the type of the `foo` field. The typed holes should be consistent with the type error you get when you use a wrong type, e.g.:
```haskell
{-# LANGUAGE RecordWildCards #-}
data Foo = Foo {foo :: Int}
test :: Foo
test = Foo {..}
where
foo = ()
```
Gives the error:
```
T.hs:6:13: error:
• Couldn't match expected type ‘Int’ with actual type ‘()’
• In the ‘foo’ field of a record
In the expression: Foo {..}
In an equation for ‘test’:
test
= Foo {..}
where
foo = ()
|
6 | test = Foo {..}
| ^^
```
So GHC does know that `foo :: Int` should hold.
## Environment
* GHC version used: 9.2.4https://gitlab.haskell.org/ghc/ghc/-/issues/20193RecordWildCards undocumented behavior2021-08-16T08:33:20ZYuriy SyrovetskiyRecordWildCards undocumented behavior## Summary
https://downloads.haskell.org/ghc/latest/docs/html/users_guide/exts/record_wildcards.html
There are two behaviors of RecordWildCards (RWC) undocumented or documented unclearly.
### 1. Unclear qualified names
> For both pat...## Summary
https://downloads.haskell.org/ghc/latest/docs/html/users_guide/exts/record_wildcards.html
There are two behaviors of RecordWildCards (RWC) undocumented or documented unclearly.
### 1. Unclear qualified names
> For both pattern and expression wildcards, the “`..`” expands to the missing in-scope record fields...
>
> The record field `f` is in scope somehow (either qualified or unqualified).
>
> ```hs
> module M where
> data R = R { a,b,c :: Int }
> module X where
> import M( R(R,a,c) )
> f a b = R { .. }
> ```
>
> The `R{..}` expands to `R{a=a}`
There should be an example of qualified in-scope presence, which I find very useful
```hs
module M where
data R = R{a, b, c :: Int}
module X where
import M (R (R))
import M qualified
f a b = R{..}
```
The `R{..}` expands to `R{M.a = a, M.b = b}`, so you can use fields without messing with getters.
### 2. RWC interferes with NamedFieldPuns
With NamedFieldPuns (NFP) enabled and RWC disabled:
```hs
import M (R (R))
import M qualified
f foo = R{foo} -- use of NFP syntax, not RWC
```
```
error:
Not in scope: ‘foo’
Perhaps you want to add ‘foo’ to the import list in the import of
```
With RWC additionally enabled, the same code is compiled successfully!
So, RWC desugars NFP syntax `R{foo}` to `R{M.foo = foo}`, which must be documented.
## Proposed improvements or changes
I'm not sure about specific wording.
## Environment
* GHC version used: 8.10.4https://gitlab.haskell.org/ghc/ghc/-/issues/17834Support RecordWildCards in HPC2020-06-29T20:59:20ZBrandon ChinnSupport RecordWildCards in HPC## Summary
Data type records are marked as "never executed" when I use them only with RecordWildCards. The same could probably be said for NamedFieldPuns as well.
## Steps to reproduce
```haskell
{-# LANGUAGE RecordWildCards #-}
data...## Summary
Data type records are marked as "never executed" when I use them only with RecordWildCards. The same could probably be said for NamedFieldPuns as well.
## Steps to reproduce
```haskell
{-# LANGUAGE RecordWildCards #-}
data Foo = Foo
{ foo1 :: Int
, foo2 :: Int
}
showFoo :: Foo -> IO ()
showFoo Foo{..} = print (foo1, foo2)
main = showFoo (Foo 1 2)
```
Running the above with coverage shows `foo1` and `foo2` as uncovered.
[Main.hs](/uploads/1c2bf48faab46d8da7a7cc10bd50aaae/Main.hs)
[Main.hs.html](/uploads/da8184b460bc0d399de6f498997191ab/Main.hs.html)
## Expected behavior
`foo1` and `foo2` should be marked as "hit"
## Environment
* GHC version used: 8.8.1
Optional:
* Operating System: MacOS 10.14.6
* System Architecture: