@@ -1,10 +1,14 @@
1{-# LANGUAGE CPP, DefaultSignatures, EmptyDataDecls, FlexibleInstances,
1{-# LANGUAGE CPP, DefaultSignatures, EmptyDataDecls, FlexibleInstances,
2− FunctionalDependencies, KindSignatures, OverlappingInstances,
2+ FunctionalDependencies, KindSignatures,
3 ScopedTypeVariables, TypeOperators, UndecidableInstances,
3 ScopedTypeVariables, TypeOperators, UndecidableInstances,
4 ViewPatterns, NamedFieldPuns, FlexibleContexts, PatternGuards,
4 ViewPatterns, NamedFieldPuns, FlexibleContexts, PatternGuards,
5 RecordWildCards #-}
5 RecordWildCards #-}
6{-# OPTIONS_GHC -fno-warn-orphans #-}
6{-# OPTIONS_GHC -fno-warn-orphans #-}
8+#if __GLASGOW_HASKELL__ < 710
9+{-# LANGUAGE OverlappingInstances #-}
9-- Module: Data.Aeson.Types.Generic
13-- Module: Data.Aeson.Types.Generic
10-- Copyright: (c) 2012-2015 Bryan O'Sullivan
14-- Copyright: (c) 2012-2015 Bryan O'Sullivan
@@ -45,7 +49,11 @@ import Data.Monoid (mempty)
45--------------------------------------------------------------------------------
49--------------------------------------------------------------------------------
46-- Generic toJSON
50-- Generic toJSON
53+#if __GLASGOW_HASKELL__ >= 710
48−instance (GToJSON a) => GToJSON (M1 i c a) where
56+ (GToJSON a) => GToJSON (M1 i c a) where
49 -- Meta-information, which is not handled elsewhere, is ignored:
57 -- Meta-information, which is not handled elsewhere, is ignored:
50 gToJSON opts = gToJSON opts . unM1
58 gToJSON opts = gToJSON opts . unM1
51 {-# INLINE gToJSON #-}
59 {-# INLINE gToJSON #-}
@@ -338,7 +346,11 @@ instance (Selector s, GToJSON a) => RecordTo (S1 s a) where
338 recordToEncoding = fieldToEncoding
346 recordToEncoding = fieldToEncoding
339 {-# INLINE recordToEncoding #-}
347 {-# INLINE recordToEncoding #-}
350+#if __GLASGOW_HASKELL__ >= 710
341−instance (Selector s, ToJSON a) => RecordTo (S1 s (K1 i (Maybe a))) where
353+ (Selector s, ToJSON a) => RecordTo (S1 s (K1 i (Maybe a))) where
342 recordToPairs opts (M1 k1) | omitNothingFields opts
354 recordToPairs opts (M1 k1) | omitNothingFields opts
343 , K1 Nothing <- k1 = empty
355 , K1 Nothing <- k1 = empty
344 recordToPairs opts m1 = fieldToPair opts m1
356 recordToPairs opts m1 = fieldToPair opts m1
@@ -389,7 +401,11 @@ instance ( WriteProduct a
389 encodeProduct opts b
401 encodeProduct opts b
390 {-# INLINE encodeProduct #-}
402 {-# INLINE encodeProduct #-}
405+#if __GLASGOW_HASKELL__ >= 710
406+ {-# OVERLAPPABLE #-}
392−instance (GToJSON a) => WriteProduct a where
408+ (GToJSON a) => WriteProduct a where
393 writeProduct opts mv ix _ = VM.unsafeWrite mv ix . gToJSON opts
409 writeProduct opts mv ix _ = VM.unsafeWrite mv ix . gToJSON opts
394 {-# INLINE writeProduct #-}
410 {-# INLINE writeProduct #-}
@@ -435,7 +451,11 @@ gbuilder opts = fromEncoding . gToEncoding opts
435--------------------------------------------------------------------------------
451--------------------------------------------------------------------------------
436-- Generic parseJSON
452-- Generic parseJSON
455+#if __GLASGOW_HASKELL__ >= 710
456+ {-# OVERLAPPABLE #-}
438−instance (GFromJSON a) => GFromJSON (M1 i c a) where
458+ (GFromJSON a) => GFromJSON (M1 i c a) where
439 -- Meta-information, which is not handled elsewhere, is just added to the
459 -- Meta-information, which is not handled elsewhere, is just added to the
440 -- parsed value:
460 -- parsed value:
441 gParseJSON opts = fmap M1 . gParseJSON opts
461 gParseJSON opts = fmap M1 . gParseJSON opts
@@ -660,7 +680,11 @@ instance (Selector s, GFromJSON a) => FromRecord (S1 s a) where
660 label = fieldLabelModifier opts $ selName (undefined :: t s a p)
680 label = fieldLabelModifier opts $ selName (undefined :: t s a p)
661 {-# INLINE parseRecord #-}
681 {-# INLINE parseRecord #-}
684+#if __GLASGOW_HASKELL__ >= 710
663−instance (Selector s, FromJSON a) => FromRecord (S1 s (K1 i (Maybe a))) where
687+ (Selector s, FromJSON a) => FromRecord (S1 s (K1 i (Maybe a))) where
664 parseRecord _ (Just lab) obj = (M1 . K1) . join <$> obj .:? lab
688 parseRecord _ (Just lab) obj = (M1 . K1) . join <$> obj .:? lab
665 parseRecord opts Nothing obj = (M1 . K1) . join <$> obj .:? pack label
689 parseRecord opts Nothing obj = (M1 . K1) . join <$> obj .:? pack label
@@ -729,7 +753,11 @@ class IsRecord (f :: * -> *) isRecord | f -> isRecord
730instance (IsRecord f isRecord) => IsRecord (f :*: g) isRecord
754instance (IsRecord f isRecord) => IsRecord (f :*: g) isRecord
731 where isUnary = const False
755 where isUnary = const False
757+#if __GLASGOW_HASKELL__ >= 710
732−instance IsRecord (M1 S NoSelector f) False
760+ IsRecord (M1 S NoSelector f) False
733instance (IsRecord f isRecord) => IsRecord (M1 S c f) isRecord
761instance (IsRecord f isRecord) => IsRecord (M1 S c f) isRecord
734instance IsRecord (K1 i c) True
762instance IsRecord (K1 i c) True
735instance IsRecord U1 False
763instance IsRecord U1 False