Skip to content

Commit 91ddc73

Browse files
dyniecBinderDavid
authored andcommitted
Add documentation for GHC-06202 (TcRnMisplacedInstSig)
1 parent 230bfed commit 91ddc73

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{-# LANGUAGE Haskell2010, InstanceSigs #-}
2+
module Example1 where
3+
4+
data A = A | B
5+
instance Eq A where
6+
(==) :: A -> A -> Bool
7+
A == A = True
8+
B == B = True
9+
_ == _ = False
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{-# LANGUAGE Haskell2010 #-}
2+
module Example1 where
3+
4+
data A = A | B
5+
instance Eq A where
6+
(==) :: A -> A -> Bool
7+
A == A = True
8+
B == B = True
9+
_ == _ = False
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Illegal type signature in instance declaration
3+
---
4+
5+
## Error message
6+
7+
Type signatures are only allowed to be in instance declarations when the `InstanceSigs` language extension is enabled.
8+
9+
```
10+
Example1.hs:6:13: error: [GHC-06202]
11+
• Illegal type signature in instance declaration:
12+
(==) :: A -> A -> Bool
13+
• In the instance declaration for ‘Eq A’
14+
Suggested fix: Perhaps you intended to use InstanceSigs
15+
|
16+
6 | (==) :: A -> A -> Bool
17+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Illegal type signature in instance declaration
3+
summary: Method in class instance has type signature, but extension InstanceSigs is not enabled
4+
severity: error
5+
introduced: 9.6.1
6+
---
7+
8+
This error is emitted when class instance has type signature, but extension [InstanceSigs](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/instances.html#instance-signatures-type-signatures-in-instance-declarations) is not enabled. Note that `InstanceSigs` is part of `GHC2021` and `GHC2024` [editions](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/control.html), so you won't encounter this error in new code unless you explicitely opt-out.

0 commit comments

Comments
 (0)