@@ -165,7 +165,11 @@ deriveToJSON opts name =
165165 where
166166 fromCons :: [TyVarBndr] -> [Con] -> Q Dec
167167 fromCons tvbs cons =
168+#if __GLASGOW_HASKELL__ >= 709
169+ instanceD (return $ map (\t -> AppT (ConT ''ToJSON) (VarT t)) typeNames)
170+#else
168171 instanceD (return $ map (\t -> ClassP ''ToJSON [VarT t]) typeNames)
172+#endif
169173 (classType `appT` instanceType)
170174 [ funD 'toJSON
171175 [ clause []
@@ -372,7 +376,11 @@ deriveFromJSON opts name =
372376 where
373377 fromCons :: [TyVarBndr] -> [Con] -> Q Dec
374378 fromCons tvbs cons =
379+#if __GLASGOW_HASKELL__ >= 709
380+ instanceD (return $ map (\t -> AppT (ConT ''FromJSON) (VarT t)) typeNames)
381+#else
375382 instanceD (return $ map (\t -> ClassP ''FromJSON [VarT t]) typeNames)
383+#endif
376384 (classType `appT` instanceType)
377385 [ funD 'parseJSON
378386 [ clause []