Skip to content

Commit

Permalink
Add docs for UnusedName warning (#411)
Browse files Browse the repository at this point in the history
* Add docs for `UnusedName` warning

* Update example
  • Loading branch information
maxdeviant authored Nov 15, 2021
1 parent d77e09a commit 7295b33
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions errors/UnusedName.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# `UnusedName` Warning

## Example

```purescript
module UnusedNameExample where
plus :: Int -> Int -> Int
plus x y = y -- Name x was introduced but not used.
ignore :: forall a. a -> Unit
ignore value = unit -- Name value was introduced but not used.
```

## Cause

This warning occurs when a name is introduced but is not used anywhere.

PureScript warns in this case because it could indicate a bug due to a value not being referenced where it should be.

## Fix

If the unused name was unintentional, make use of it to fix the warning:

```purescript
plus :: Int -> Int -> Int
plus x y = x + y
```

If the unused name is intentional, mark the name as unused by prefixing it with a `_`:

```purescript
ignore :: forall a. a -> Unit
ignore _value = unit
```

## Notes

0 comments on commit 7295b33

Please sign in to comment.