Spurious overlapping instance with FlexibleInstances
Summary
GHC tells me of an overlapping instance when there is none.
Steps to reproduce
{-# LANGUAGE FlexibleInstances #-}
module Test where
class Thing p where
thing :: p -> String
class Thing1 p where
thing1 :: Thing a => p a -> String
instance (Thing1 f, Thing x) => Thing (f x) where
thing = thing1
data Token = Token
instance Thing x => Thing (Either x Token)
testF :: (Thing x) => Either x Token -> String -- overlap error!
testF = thing
testF' :: (Thing x) => x -> String -- no overlap here!
testF' = thing
Expected behavior
No error. This error made me question my understanding of overlapping instances, but it seems to me that either testF should compile fine, or both testF and testF' should fail.
Environment
- GHC version used: 9.2.4
Optional:
- Operating System:
- System Architecture: