Skip to content

TypeError is reported as "redundant constraint" starting with GHC 8.2

The following program compiles fine on GHC 8.0.2, but GHC 8.2.2 issues a warning, complaining that TypeError is a redundant constraint. This makes it very inconvenient to use TypeError with type classes.

{-# OPTIONS_GHC -Wredundant-constraints -Wall -Werror #-}
import GHC.TypeLits (TypeError, ErrorMessage(..))

class C a where f :: a -> a
instance {-# OVERLAPPING #-} C Int where f _ = 42
instance {-# OVERLAPPABLE #-} TypeError ( 'Text "Only Int is supported" ) => C a where f = undefined

main :: IO ()
main = print $ f (42::Int)
Trac metadata
Trac field Value
Version 8.2.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information