Skip to content

Commit f2aa897

Browse files
kaitanieBinderDavid
authored andcommitted
Add documentation for GHC-83475 (Unused record wildcard)
1 parent 91ddc73 commit f2aa897

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{-# OPTIONS_GHC -fwarn-unused-record-wildcards #-}
2+
{-# LANGUAGE RecordWildCards #-}
3+
module Example1 where
4+
5+
data Foo = Foo { x :: Int, y :: Int, name :: String }
6+
7+
f :: Foo -> String
8+
f Foo{} = "Hello"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{-# OPTIONS_GHC -fwarn-unused-record-wildcards #-}
2+
{-# LANGUAGE RecordWildCards #-}
3+
module Example1 where
4+
5+
data Foo = Foo { x :: Int, y :: Int, name :: String }
6+
7+
f :: Foo -> String
8+
f Foo{..} = "Hello"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Pattern contains unused record wildcard
3+
---
4+
5+
None of the fields bound by `Foo{..}` are used in `f`, so the pattern may be safely removed.
6+
7+
## Warning
8+
9+
```
10+
GHC-83475/example1/before/Example1.hs:7:7: warning: [-Wunused-record-wildcards]
11+
No variables bound in the record wildcard match are used
12+
Possible fix: omit the ‘..’
13+
|
14+
7 | f Foo{..} = "Hello"
15+
| ^^
16+
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Unused Record Wildcard
3+
summary: Pattern contains record wildcard that is not used
4+
severity: warning
5+
flag: -Wunused-record-wildcards
6+
introduced: 9.6.1
7+
---
8+
9+
If `RecordWildCards` is enabled we can automatically bind fields of a record by using patterns like `MyRecord{..}`. Not using any of the record fields that were bound using the record wildcard syntax will result in a warning.

0 commit comments

Comments
 (0)