@@ -5,9 +5,7 @@
55 RecordWildCards #-}
66{-# OPTIONS_GHC -fno-warn-orphans #-}
77
8−#if __GLASGOW_HASKELL__ < 710
9−{-# LANGUAGE OverlappingInstances #-}
10−#endif
8+#include "overlapping-compat.h"
119
1210-- |
1311-- Module: Data.Aeson.Types.Generic
@@ -49,11 +47,7 @@ import Data.Monoid (mempty)
4947--------------------------------------------------------------------------------
5048-- Generic toJSON
5149
52−instance
53−#if __GLASGOW_HASKELL__ >= 710
54− {-# OVERLAPPABLE #-}
55−#endif
56− (GToJSON a) => GToJSON (M1 i c a) where
50+instance OVERLAPPABLE_ (GToJSON a) => GToJSON (M1 i c a) where
5751 -- Meta-information, which is not handled elsewhere, is ignored:
5852 gToJSON opts = gToJSON opts . unM1
5953 {-# INLINE gToJSON #-}
@@ -346,11 +340,8 @@ instance (Selector s, GToJSON a) => RecordTo (S1 s a) where
346340 recordToEncoding = fieldToEncoding
347341 {-# INLINE recordToEncoding #-}
348342
349−instance
350−#if __GLASGOW_HASKELL__ >= 710
351− {-# OVERLAPPING #-}
352−#endif
353− (Selector s, ToJSON a) => RecordTo (S1 s (K1 i (Maybe a))) where
343+instance OVERLAPPING_ (Selector s, ToJSON a) =>
344+ RecordTo (S1 s (K1 i (Maybe a))) where
354345 recordToPairs opts (M1 k1) | omitNothingFields opts
355346 , K1 Nothing <- k1 = empty
356347 recordToPairs opts m1 = fieldToPair opts m1
@@ -401,11 +392,7 @@ instance ( WriteProduct a
401392 encodeProduct opts b
402393 {-# INLINE encodeProduct #-}
403394
404−instance
405−#if __GLASGOW_HASKELL__ >= 710
406− {-# OVERLAPPABLE #-}
407−#endif
408− (GToJSON a) => WriteProduct a where
395+instance OVERLAPPABLE_ (GToJSON a) => WriteProduct a where
409396 writeProduct opts mv ix _ = VM.unsafeWrite mv ix . gToJSON opts
410397 {-# INLINE writeProduct #-}
411398
@@ -451,11 +438,7 @@ gbuilder opts = fromEncoding . gToEncoding opts
451438--------------------------------------------------------------------------------
452439-- Generic parseJSON
453440
454−instance
455−#if __GLASGOW_HASKELL__ >= 710
456− {-# OVERLAPPABLE #-}
457−#endif
458− (GFromJSON a) => GFromJSON (M1 i c a) where
441+instance OVERLAPPABLE_ (GFromJSON a) => GFromJSON (M1 i c a) where
459442 -- Meta-information, which is not handled elsewhere, is just added to the
460443 -- parsed value:
461444 gParseJSON opts = fmap M1 . gParseJSON opts
@@ -680,11 +663,8 @@ instance (Selector s, GFromJSON a) => FromRecord (S1 s a) where
680663 label = fieldLabelModifier opts $ selName (undefined :: t s a p)
681664 {-# INLINE parseRecord #-}
682665
683−instance
684−#if __GLASGOW_HASKELL__ >= 710
685− {-# OVERLAPPING #-}
686−#endif
687− (Selector s, FromJSON a) => FromRecord (S1 s (K1 i (Maybe a))) where
666+instance OVERLAPPING_ (Selector s, FromJSON a) =>
667+ FromRecord (S1 s (K1 i (Maybe a))) where
688668 parseRecord _ (Just lab) obj = (M1 . K1) . join <$> obj .:? lab
689669 parseRecord opts Nothing obj = (M1 . K1) . join <$> obj .:? pack label
690670 where
@@ -753,11 +733,7 @@ class IsRecord (f :: * -> *) isRecord | f -> isRecord
753733
754734instance (IsRecord f isRecord) => IsRecord (f :*: g) isRecord
755735 where isUnary = const False
756−instance
757−#if __GLASGOW_HASKELL__ >= 710
758− {-# OVERLAPPING #-}
759−#endif
760− IsRecord (M1 S NoSelector f) False
736+instance OVERLAPPING_ IsRecord (M1 S NoSelector f) False
761737instance (IsRecord f isRecord) => IsRecord (M1 S c f) isRecord
762738instance IsRecord (K1 i c) True
763739instance IsRecord U1 False