Skip to content

Commit b0e5d77

Browse files
authored
Merge pull request #447 from haskellfoundation/GHC-64088
Add message for GHC-64088 : Use of forall identifier
2 parents 6952d48 + e537502 commit b0e5d77

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ForallIdentifier where
2+
3+
forAll :: (a -> Bool) -> [a] -> Bool
4+
forAll f ls = and (fmap f ls)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ForallIdentifier where
2+
3+
forall :: (a -> Bool) -> [a] -> Bool
4+
forall f ls = and (map f ls)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: The identifier "forall" should not be used
3+
---
4+
5+
In this example the programmer implemented a function which checks whether all elements of a list satisfy a given predicate. The programmer has chosen the sensible name "forall" for this function, but this name will become a reserved keyword in a future version of GHC.
6+
The function should therefore be renamed, for example to the name "forAll".
7+
8+
```
9+
ForallIdentifier.hs:4:1: warning: [GHC-64088] [-Wforall-identifier]
10+
The use of ‘forall’ as an identifier
11+
will become an error in a future GHC release.
12+
Suggested fix:
13+
Consider using another name, such as
14+
‘forAll’, ‘for_all’, or ‘forall_’.
15+
|
16+
4 | forall f ls = and (fmap f ls)
17+
| ^^^^^^
18+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: Use of "forall" as an identifier
3+
summary: Use of "forall" as an identifier is discouraged
4+
severity: warning
5+
flag: -Wforall-identifier
6+
introduced: 9.6.1
7+
---
8+
9+
The string "forall" is not a keyword in the Haskell 2010 standard.
10+
It is therefore possible to declare a top-level function in Haskell 2010 which uses `forall` as a name.
11+
As a result of the accepted [GHC proposal 281](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0281-visible-forall.rst) the string `"forall"` will become a reserved keyword in a future version of GHC, so GHC warns against the use of `forall` as an identifier.

0 commit comments

Comments
 (0)