Skip to content

Commit

Permalink
Merge pull request haskellfoundation#396 from BinderDavid/add-error-4…
Browse files Browse the repository at this point in the history
…4432

Add error message for error GHC-44432
  • Loading branch information
david-christiansen authored Apr 12, 2023
2 parents 8433ca5 + 35d3607 commit ee4d3d8
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 0 deletions.
8 changes: 8 additions & 0 deletions message-index/messages/GHC-44432/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Type signature lacks an accompanying binding
summary: A type signature was provided, but no binding was given.
severity: error
introduced: 9.6.1
---

If a type signature is given for a name, then that name also needs to be defined.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module MissingBinding where

fortytwo :: Integer
fortytwo =
let
two :: Integer
two = 2
in
40 + two
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module MissingBinding where

fortytwo :: Integer
fortytwo =
let
two :: Integer
in
40 + two
18 changes: 18 additions & 0 deletions message-index/messages/GHC-44432/let-binding/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Type signature lacks an accompanying binding
---

If a type signature is given for a name in a local let expression, then the name also needs to be defined.

In this example, a type signature was given for the name `two` in a let expression, but no definition was specified.
This error can be fixed by adding a definition which accompanies the type signature.

## Error Message

```
MissingBinding.hs:6:5: error: [GHC-44432]
The type signature for ‘two’ lacks an accompanying binding
|
6 | two :: Integer
| ^^^
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MissingBinding where

someBoolean :: Bool
someBoolean = True
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module MissingBinding where

someBoolean :: Bool
18 changes: 18 additions & 0 deletions message-index/messages/GHC-44432/toplevel/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Type signature lacks an accompanying binding
---

If a type signature is given for a name in a Haskell module, then the name also needs to be defined.

In this example, a type signature was given for the name `someBoolean` in a Haskell module, but no definition was specified.
This error can be fixed by adding a definition which accompanies the type signature.

## Error Message

```
MissingBinding.hs:3:1: error: [GHC-44432]
The type signature for ‘someBoolean’ lacks an accompanying binding
|
3 | someBoolean :: Bool
| ^^^^^^^^^^^
```
8 changes: 8 additions & 0 deletions message-index/messages/GHC-44432/typo/after/MissingBinding.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module MissingBinding where

import Numeric.Natural

factorial :: Natural -> Natural
factorial n
| n == 0 = 1
| otherwise = n * factorial (n - 1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module MissingBinding where

import Numeric.Natural

factorial :: Natural -> Natural
fatcorial n
| n == 0 = 1
| otherwise = n * factorial (n - 1)
20 changes: 20 additions & 0 deletions message-index/messages/GHC-44432/typo/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: Type signature lacks an accompanying binding
---

If a type signature is given for a name in a Haskell module, then the name also needs to be defined.

In this example, the programmer misspelt the name `factorial`.
GHC helpfully suggests that `fatcorial` might be the intended spelling.
The error can be fixed by correcting the typo.

## Error Message

```
MissingBinding.hs:5:1: error: [GHC-44432]
The type signature for ‘factorial’ lacks an accompanying binding
Suggested fix: Perhaps use ‘fatcorial’ (Defined at Main.hs:6:1)
|
5 | factorial :: Natural -> Natural
| ^^^^^^^^^
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module MissingBinding where

fortytwo :: Integer
fortytwo = 40 + two
where
two :: Integer
two = 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module MissingBinding where

fortytwo :: Integer
fortytwo = 40 + two
where
two :: Integer
18 changes: 18 additions & 0 deletions message-index/messages/GHC-44432/where-clause/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Type signature lacks an accompanying binding
---

If a type signature is given for a name in a where clause, then the name also needs to be defined.

In this example, a type signature was given for the name `two` in a where clause, but no definition was specified.
This error can be fixed by adding a definition which accompanies the type signature.

## Error Message

```
MissingBinding.hs:6:5: error: [GHC-44432]
The type signature for ‘two’ lacks an accompanying binding
|
6 | two :: Integer
| ^^^
```

0 comments on commit ee4d3d8

Please sign in to comment.