Skip to content

Commit

Permalink
Add documentation for GHC-06202 (TcRnMisplacedInstSig)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyniec authored and BinderDavid committed Oct 11, 2024
1 parent 230bfed commit 91ddc73
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
9 changes: 9 additions & 0 deletions message-index/messages/GHC-06202/example1/after/Example1.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{-# LANGUAGE Haskell2010, InstanceSigs #-}
module Example1 where

data A = A | B
instance Eq A where
(==) :: A -> A -> Bool
A == A = True
B == B = True
_ == _ = False
9 changes: 9 additions & 0 deletions message-index/messages/GHC-06202/example1/before/Example1.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{-# LANGUAGE Haskell2010 #-}
module Example1 where

data A = A | B
instance Eq A where
(==) :: A -> A -> Bool
A == A = True
B == B = True
_ == _ = False
17 changes: 17 additions & 0 deletions message-index/messages/GHC-06202/example1/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Illegal type signature in instance declaration
---

## Error message

Type signatures are only allowed to be in instance declarations when the `InstanceSigs` language extension is enabled.

```
Example1.hs:6:13: error: [GHC-06202]
• Illegal type signature in instance declaration:
(==) :: A -> A -> Bool
• In the instance declaration for ‘Eq A’
Suggested fix: Perhaps you intended to use InstanceSigs
|
6 | (==) :: A -> A -> Bool
```
8 changes: 8 additions & 0 deletions message-index/messages/GHC-06202/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Illegal type signature in instance declaration
summary: Method in class instance has type signature, but extension InstanceSigs is not enabled
severity: error
introduced: 9.6.1
---

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 comments on commit 91ddc73

Please sign in to comment.