Illegal type signature in instance declaration [GHC-06202]
This error is emitted when class instance has type signature, but extension InstanceSigs is not enabled. Note that InstanceSigs is part of GHC2021 and GHC2024 editions, so you won’t encounter this error in new code unless you explicitely opt-out.
Examples
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
Example1.hs
Before
{-# LANGUAGE Haskell2010 #-}
module Example1 where
data A = A | B
instance Eq A where
(==) :: A -> A -> Bool
A == A = True
B == B = True
_ == _ = False
After
{-# LANGUAGE Haskell2010, InstanceSigs #-}
module Example1 where
data A = A | B
instance Eq A where
(==) :: A -> A -> Bool
A == A = True
B == B = True
_ == _ = False