Skip to content

Commit 99a2d9a

Browse files
committed
Added another example of error GHC-39999
1 parent 7e2013c commit 99a2d9a

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Data.Functor.Classes (Show1(..))
2+
3+
newtype Foo a = Foo a
4+
5+
instance Show a => Show (Foo a) where
6+
show (Foo a) = "Foo " ++ show a
7+
8+
instance Show1 Foo where
9+
liftShowsPrec showsPrec _showList prec (Foo a) rest = "Foo " ++ showsPrec prec a rest
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Data.Functor.Classes (Show1(..))
2+
3+
newtype Foo a = Foo a
4+
5+
instance Show1 Foo where
6+
liftShowsPrec showsPrec _showList prec (Foo a) rest = "Foo " ++ showsPrec prec a rest
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: Missing superclass declaration
3+
---
4+
5+
### Error message on GHC 9.6.2
6+
7+
```
8+
Main.hs:5:10: error: [GHC-39999]
9+
• Could not deduce ‘Show (Foo a)’
10+
arising from the head of a quantified constraint
11+
arising from the superclasses of an instance declaration
12+
from the context: Show a
13+
bound by a quantified context at Main.hs:5:10-18
14+
• In the instance declaration for ‘Show1 Foo’
15+
|
16+
5 | instance Show1 Foo where
17+
| ^^^^^^^^^
18+
```
19+
20+
## Explanation
21+
22+
The [`Show1`](https://hackage.haskell.org/package/base-4.18.0.0/docs/Data-Functor-Classes.html#t:Show1) class has
23+
changed in GHC 9.6 to require a quantified superclass constraint `Show`. To fix this error, for every `instance
24+
Show1` declaration add a corresponding `instance Show` declaration for the same data type.

0 commit comments

Comments
 (0)