-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation for GHC-83475 (Unused record wildcard)
- Loading branch information
Showing
4 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{-# OPTIONS_GHC -fwarn-unused-record-wildcards #-} | ||
{-# LANGUAGE RecordWildCards #-} | ||
module Example1 where | ||
|
||
data Foo = Foo { x :: Int, y :: Int, name :: String } | ||
|
||
f :: Foo -> String | ||
f Foo{} = "Hello" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{-# OPTIONS_GHC -fwarn-unused-record-wildcards #-} | ||
{-# LANGUAGE RecordWildCards #-} | ||
module Example1 where | ||
|
||
data Foo = Foo { x :: Int, y :: Int, name :: String } | ||
|
||
f :: Foo -> String | ||
f Foo{..} = "Hello" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
title: Pattern contains unused record wildcard | ||
--- | ||
|
||
None of the fields bound by `Foo{..}` are used in `f`, so the pattern may be safely removed. | ||
|
||
## Warning | ||
|
||
``` | ||
GHC-83475/example1/before/Example1.hs:7:7: warning: [-Wunused-record-wildcards] | ||
No variables bound in the record wildcard match are used | ||
Possible fix: omit the ‘..’ | ||
| | ||
7 | f Foo{..} = "Hello" | ||
| ^^ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: Unused Record Wildcard | ||
summary: Pattern contains record wildcard that is not used | ||
severity: warning | ||
flag: -Wunused-record-wildcards | ||
introduced: 9.6.1 | ||
--- | ||
|
||
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. |