Skip to content

Commit 7295b33

Browse files
authored
Add docs for UnusedName warning (#411)
* Add docs for `UnusedName` warning * Update example
1 parent d77e09a commit 7295b33

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

errors/UnusedName.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# `UnusedName` Warning
2+
3+
## Example
4+
5+
```purescript
6+
module UnusedNameExample where
7+
8+
plus :: Int -> Int -> Int
9+
plus x y = y -- Name x was introduced but not used.
10+
11+
ignore :: forall a. a -> Unit
12+
ignore value = unit -- Name value was introduced but not used.
13+
```
14+
15+
## Cause
16+
17+
This warning occurs when a name is introduced but is not used anywhere.
18+
19+
PureScript warns in this case because it could indicate a bug due to a value not being referenced where it should be.
20+
21+
## Fix
22+
23+
If the unused name was unintentional, make use of it to fix the warning:
24+
25+
```purescript
26+
plus :: Int -> Int -> Int
27+
plus x y = x + y
28+
```
29+
30+
If the unused name is intentional, mark the name as unused by prefixing it with a `_`:
31+
32+
```purescript
33+
ignore :: forall a. a -> Unit
34+
ignore _value = unit
35+
```
36+
37+
## Notes

0 commit comments

Comments
 (0)