How to apply overlapping pragma to derived instance

154 views Asked by At

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)
1

There are 1 answers

0
dfeuer On BEST ANSWER

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)