@@ -5,9 +5,7 @@
5 RecordWildCards #-}
5 RecordWildCards #-}
6{-# OPTIONS_GHC -fno-warn-orphans #-}
6{-# OPTIONS_GHC -fno-warn-orphans #-}
8−#if __GLASGOW_HASKELL__ < 710
8+#include "overlapping-compat.h"
9−{-# LANGUAGE OverlappingInstances #-}
13-- Module: Data.Aeson.Types.Generic
11-- Module: Data.Aeson.Types.Generic
@@ -49,11 +47,7 @@ import Data.Monoid (mempty)
49--------------------------------------------------------------------------------
47--------------------------------------------------------------------------------
50-- Generic toJSON
48-- Generic toJSON
53−#if __GLASGOW_HASKELL__ >= 710
56− (GToJSON a) => GToJSON (M1 i c a) where
50+instance OVERLAPPABLE_ (GToJSON a) => GToJSON (M1 i c a) where
57 -- Meta-information, which is not handled elsewhere, is ignored:
51 -- Meta-information, which is not handled elsewhere, is ignored:
58 gToJSON opts = gToJSON opts . unM1
52 gToJSON opts = gToJSON opts . unM1
59 {-# INLINE gToJSON #-}
53 {-# INLINE gToJSON #-}
@@ -346,11 +340,8 @@ instance (Selector s, GToJSON a) => RecordTo (S1 s a) where
346 recordToEncoding = fieldToEncoding
340 recordToEncoding = fieldToEncoding
347 {-# INLINE recordToEncoding #-}
341 {-# INLINE recordToEncoding #-}
349−instance
343+instance OVERLAPPING_ (Selector s, ToJSON a) =>
350−#if __GLASGOW_HASKELL__ >= 710
353− (Selector s, ToJSON a) => RecordTo (S1 s (K1 i (Maybe a))) where
344+ RecordTo (S1 s (K1 i (Maybe a))) where
354 recordToPairs opts (M1 k1) | omitNothingFields opts
345 recordToPairs opts (M1 k1) | omitNothingFields opts
355 , K1 Nothing <- k1 = empty
346 , K1 Nothing <- k1 = empty
356 recordToPairs opts m1 = fieldToPair opts m1
347 recordToPairs opts m1 = fieldToPair opts m1
@@ -401,11 +392,7 @@ instance ( WriteProduct a
401 encodeProduct opts b
392 encodeProduct opts b
402 {-# INLINE encodeProduct #-}
393 {-# INLINE encodeProduct #-}
405−#if __GLASGOW_HASKELL__ >= 710
406− {-# OVERLAPPABLE #-}
408− (GToJSON a) => WriteProduct a where
395+instance OVERLAPPABLE_ (GToJSON a) => WriteProduct a where
409 writeProduct opts mv ix _ = VM.unsafeWrite mv ix . gToJSON opts
396 writeProduct opts mv ix _ = VM.unsafeWrite mv ix . gToJSON opts
410 {-# INLINE writeProduct #-}
397 {-# INLINE writeProduct #-}
@@ -451,11 +438,7 @@ gbuilder opts = fromEncoding . gToEncoding opts
451--------------------------------------------------------------------------------
438--------------------------------------------------------------------------------
452-- Generic parseJSON
439-- Generic parseJSON
455−#if __GLASGOW_HASKELL__ >= 710
456− {-# OVERLAPPABLE #-}
458− (GFromJSON a) => GFromJSON (M1 i c a) where
441+instance OVERLAPPABLE_ (GFromJSON a) => GFromJSON (M1 i c a) where
459 -- Meta-information, which is not handled elsewhere, is just added to the
442 -- Meta-information, which is not handled elsewhere, is just added to the
460 -- parsed value:
443 -- parsed value:
461 gParseJSON opts = fmap M1 . gParseJSON opts
444 gParseJSON opts = fmap M1 . gParseJSON opts
@@ -680,11 +663,8 @@ instance (Selector s, GFromJSON a) => FromRecord (S1 s a) where
680 label = fieldLabelModifier opts $ selName (undefined :: t s a p)
663 label = fieldLabelModifier opts $ selName (undefined :: t s a p)
681 {-# INLINE parseRecord #-}
664 {-# INLINE parseRecord #-}
683−instance
666+instance OVERLAPPING_ (Selector s, FromJSON a) =>
684−#if __GLASGOW_HASKELL__ >= 710
687− (Selector s, FromJSON a) => FromRecord (S1 s (K1 i (Maybe a))) where
667+ FromRecord (S1 s (K1 i (Maybe a))) where
688 parseRecord _ (Just lab) obj = (M1 . K1) . join <$> obj .:? lab
668 parseRecord _ (Just lab) obj = (M1 . K1) . join <$> obj .:? lab
689 parseRecord opts Nothing obj = (M1 . K1) . join <$> obj .:? pack label
669 parseRecord opts Nothing obj = (M1 . K1) . join <$> obj .:? pack label
@@ -753,11 +733,7 @@ class IsRecord (f :: * -> *) isRecord | f -> isRecord
754instance (IsRecord f isRecord) => IsRecord (f :*: g) isRecord
734instance (IsRecord f isRecord) => IsRecord (f :*: g) isRecord
755 where isUnary = const False
735 where isUnary = const False
757−#if __GLASGOW_HASKELL__ >= 710
760− IsRecord (M1 S NoSelector f) False
736+instance OVERLAPPING_ IsRecord (M1 S NoSelector f) False
761instance (IsRecord f isRecord) => IsRecord (M1 S c f) isRecord
737instance (IsRecord f isRecord) => IsRecord (M1 S c f) isRecord
762instance IsRecord (K1 i c) True
738instance IsRecord (K1 i c) True
763instance IsRecord U1 False
739instance IsRecord U1 False