@@ -1,10 +1,14 @@
11{-# LANGUAGE CPP, DefaultSignatures, EmptyDataDecls, FlexibleInstances,
2− FunctionalDependencies, KindSignatures, OverlappingInstances,
2+ FunctionalDependencies, KindSignatures,
33 ScopedTypeVariables, TypeOperators, UndecidableInstances,
44 ViewPatterns, NamedFieldPuns, FlexibleContexts, PatternGuards,
55 RecordWildCards #-}
66{-# OPTIONS_GHC -fno-warn-orphans #-}
77
8+#if __GLASGOW_HASKELL__ < 710
9+{-# LANGUAGE OverlappingInstances #-}
10+#endif
11+
812-- |
913-- Module: Data.Aeson.Types.Generic
1014-- Copyright: (c) 2012-2015 Bryan O'Sullivan
@@ -45,7 +49,11 @@ import Data.Monoid (mempty)
4549--------------------------------------------------------------------------------
4650-- Generic toJSON
4751
48−instance (GToJSON a) => GToJSON (M1 i c a) where
52+instance
53+#if __GLASGOW_HASKELL__ >= 710
54+ {-# OVERLAPPABLE #-}
55+#endif
56+ (GToJSON a) => GToJSON (M1 i c a) where
4957 -- Meta-information, which is not handled elsewhere, is ignored:
5058 gToJSON opts = gToJSON opts . unM1
5159 {-# INLINE gToJSON #-}
@@ -338,7 +346,11 @@ instance (Selector s, GToJSON a) => RecordTo (S1 s a) where
338346 recordToEncoding = fieldToEncoding
339347 {-# INLINE recordToEncoding #-}
340348
341−instance (Selector s, ToJSON a) => RecordTo (S1 s (K1 i (Maybe a))) where
349+instance
350+#if __GLASGOW_HASKELL__ >= 710
351+ {-# OVERLAPPING #-}
352+#endif
353+ (Selector s, ToJSON a) => RecordTo (S1 s (K1 i (Maybe a))) where
342354 recordToPairs opts (M1 k1) | omitNothingFields opts
343355 , K1 Nothing <- k1 = empty
344356 recordToPairs opts m1 = fieldToPair opts m1
@@ -389,7 +401,11 @@ instance ( WriteProduct a
389401 encodeProduct opts b
390402 {-# INLINE encodeProduct #-}
391403
392−instance (GToJSON a) => WriteProduct a where
404+instance
405+#if __GLASGOW_HASKELL__ >= 710
406+ {-# OVERLAPPABLE #-}
407+#endif
408+ (GToJSON a) => WriteProduct a where
393409 writeProduct opts mv ix _ = VM.unsafeWrite mv ix . gToJSON opts
394410 {-# INLINE writeProduct #-}
395411
@@ -435,7 +451,11 @@ gbuilder opts = fromEncoding . gToEncoding opts
435451--------------------------------------------------------------------------------
436452-- Generic parseJSON
437453
438−instance (GFromJSON a) => GFromJSON (M1 i c a) where
454+instance
455+#if __GLASGOW_HASKELL__ >= 710
456+ {-# OVERLAPPABLE #-}
457+#endif
458+ (GFromJSON a) => GFromJSON (M1 i c a) where
439459 -- Meta-information, which is not handled elsewhere, is just added to the
440460 -- parsed value:
441461 gParseJSON opts = fmap M1 . gParseJSON opts
@@ -660,7 +680,11 @@ instance (Selector s, GFromJSON a) => FromRecord (S1 s a) where
660680 label = fieldLabelModifier opts $ selName (undefined :: t s a p)
661681 {-# INLINE parseRecord #-}
662682
663−instance (Selector s, FromJSON a) => FromRecord (S1 s (K1 i (Maybe a))) where
683+instance
684+#if __GLASGOW_HASKELL__ >= 710
685+ {-# OVERLAPPING #-}
686+#endif
687+ (Selector s, FromJSON a) => FromRecord (S1 s (K1 i (Maybe a))) where
664688 parseRecord _ (Just lab) obj = (M1 . K1) . join <$> obj .:? lab
665689 parseRecord opts Nothing obj = (M1 . K1) . join <$> obj .:? pack label
666690 where
@@ -729,7 +753,11 @@ class IsRecord (f :: * -> *) isRecord | f -> isRecord
729753
730754instance (IsRecord f isRecord) => IsRecord (f :*: g) isRecord
731755 where isUnary = const False
732−instance IsRecord (M1 S NoSelector f) False
756+instance
757+#if __GLASGOW_HASKELL__ >= 710
758+ {-# OVERLAPPING #-}
759+#endif
760+ IsRecord (M1 S NoSelector f) False
733761instance (IsRecord f isRecord) => IsRecord (M1 S c f) isRecord
734762instance IsRecord (K1 i c) True
735763instance IsRecord U1 False