2

Pragma OverlappingInstances is deprecated in GHC for quite awhile and OVERLAPPING pragma is a substitute for that.

instance {-# OVERLAPPING #- } ...

Though this is not the only way in Haskell to define a class instance. I cannot define overlapping instance through deriving and avoid pesky warning about deprecated OverlappingInstances.

None of below cases are working:

  deriving {-# OVERLAPPING #-} (Lift)
  deriving ({-# OVERLAPPING #-} Lift)
Daniil Iaitskov
  • 5,525
  • 8
  • 39
  • 49
  • 2
    Of course, my real opinion about overlapping instances is "don't do that", but I know others see it differently. – dfeuer Apr 28 '21 at 16:31

1 Answers1

3

You need to use StandaloneDeriving for such instances, as well as for ones that need specialized instance contexts.

{-# language StandaloneDeriving, FlexibleInstances #-}

data T a = T

deriving instance {-# OVERLAPPING #-} Show (T Int)
instance {-# OVERLAPPABLE #-} Show (T a) where
  show ~T = "Tee-hee"

main = do
  print (T :: T Int)
  print (T :: T Char)
dfeuer
  • 48,079
  • 5
  • 63
  • 167