@@ -87,7 +87,7 @@ import Data.Hashable (Hashable(..))
87import Data.Int (Int16, Int32, Int64, Int8)
87import Data.Int (Int16, Int32, Int64, Int8)
88import Data.List.NonEmpty (NonEmpty(..))
88import Data.List.NonEmpty (NonEmpty(..))
89import Data.Maybe (fromMaybe)
89import Data.Maybe (fromMaybe)
90−import Data.Monoid ((<>), Dual(..), First (..), Last (..))
90+import Data.Monoid ((<>))
91import Data.Proxy (Proxy(..))
91import Data.Proxy (Proxy(..))
92import Data.Ratio ((%), Ratio)
92import Data.Ratio ((%), Ratio)
93import Data.Scientific (Scientific)
93import Data.Scientific (Scientific)
@@ -112,7 +112,9 @@ import qualified Data.HashSet as HashSet
112import qualified Data.IntMap as IntMap
112import qualified Data.IntMap as IntMap
113import qualified Data.IntSet as IntSet
113import qualified Data.IntSet as IntSet
114import qualified Data.Map as M
114import qualified Data.Map as M
115+import qualified Data.Monoid as Monoid
115import qualified Data.Scientific as Scientific
116import qualified Data.Scientific as Scientific
117+import qualified Data.Semigroup as Semigroup
116import qualified Data.Sequence as Seq
118import qualified Data.Sequence as Seq
117import qualified Data.Set as Set
119import qualified Data.Set as Set
118import qualified Data.Text as T
120import qualified Data.Text as T
@@ -124,6 +126,7 @@ import qualified Data.Vector.Generic as VG
124import qualified Data.Vector.Primitive as VP
126import qualified Data.Vector.Primitive as VP
125import qualified Data.Vector.Storable as VS
127import qualified Data.Vector.Storable as VS
126import qualified Data.Vector.Unboxed as VU
128import qualified Data.Vector.Unboxed as VU
127import Unsafe.Coerce (unsafeCoerce)
130import Unsafe.Coerce (unsafeCoerce)
129#ifndef HAS_COERCIBLE
132#ifndef HAS_COERCIBLE
@@ -1314,6 +1317,8 @@ instance (FromJSON a) => FromJSON (NonEmpty a) where
1314 parseJSON = parseJSON1
1317 parseJSON = parseJSON1
1315 {-# INLINE parseJSON #-}
1318 {-# INLINE parseJSON #-}
1317-------------------------------------------------------------------------------
1322-------------------------------------------------------------------------------
1318-- scientific
1323-- scientific
1319-------------------------------------------------------------------------------
1324-------------------------------------------------------------------------------
@@ -1605,29 +1610,113 @@ instance FromJSON NominalDiffTime where
1605-- base Monoid/Semigroup
1610-- base Monoid/Semigroup
1606-------------------------------------------------------------------------------
1611-------------------------------------------------------------------------------
1608−instance FromJSON1 Dual where
1613+instance FromJSON1 Monoid.Dual where
1609− liftParseJSON p _ = fmap Dual . p
1614+ liftParseJSON p _ = fmap Monoid.Dual . p
1615+ {-# INLINE liftParseJSON #-}
1617+instance FromJSON a => FromJSON (Monoid.Dual a) where
1618+ parseJSON = parseJSON1
1619+ {-# INLINE parseJSON #-}
1622+instance FromJSON1 Monoid.First where
1623+ liftParseJSON p p' = fmap Monoid.First . liftParseJSON p p'
1624+ {-# INLINE liftParseJSON #-}
1626+instance FromJSON a => FromJSON (Monoid.First a) where
1627+ parseJSON = parseJSON1
1628+ {-# INLINE parseJSON #-}
1631+instance FromJSON1 Monoid.Last where
1632+ liftParseJSON p p' = fmap Monoid.Last . liftParseJSON p p'
1633+ {-# INLINE liftParseJSON #-}
1635+instance FromJSON a => FromJSON (Monoid.Last a) where
1636+ parseJSON = parseJSON1
1637+ {-# INLINE parseJSON #-}
1640+instance FromJSON1 Semigroup.Min where
1641+ liftParseJSON p _ a = Semigroup.Min <$> p a
1642+ {-# INLINE liftParseJSON #-}
1644+ liftParseJSONList _ p a = fmap Semigroup.Min <$> p a
1645+ {-# INLINE liftParseJSONList #-}
1647+instance (FromJSON a) => FromJSON (Semigroup.Min a) where
1648+ parseJSON = parseJSON1
1649+ {-# INLINE parseJSON #-}
1651+ parseJSONList = liftParseJSONList parseJSON parseJSONList
1652+ {-# INLINE parseJSONList #-}
1655+instance FromJSON1 Semigroup.Max where
1656+ liftParseJSON p _ a = Semigroup.Max <$> p a
1610 {-# INLINE liftParseJSON #-}
1657 {-# INLINE liftParseJSON #-}
1659+ liftParseJSONList _ p a = fmap Semigroup.Max <$> p a
1660+ {-# INLINE liftParseJSONList #-}
1612−instance FromJSON a => FromJSON (Dual a) where
1662+instance (FromJSON a) => FromJSON (Semigroup.Max a) where
1663+ parseJSON = parseJSON1
1664+ {-# INLINE parseJSON #-}
1666+ parseJSONList = liftParseJSONList parseJSON parseJSONList
1667+ {-# INLINE parseJSONList #-}
1670+instance FromJSON1 Semigroup.First where
1671+ liftParseJSON p _ a = Semigroup.First <$> p a
1672+ {-# INLINE liftParseJSON #-}
1674+ liftParseJSONList _ p a = fmap Semigroup.First <$> p a
1675+ {-# INLINE liftParseJSONList #-}
1677+instance (FromJSON a) => FromJSON (Semigroup.First a) where
1678+ parseJSON = parseJSON1
1679+ {-# INLINE parseJSON #-}
1681+ parseJSONList = liftParseJSONList parseJSON parseJSONList
1682+ {-# INLINE parseJSONList #-}
1685+instance FromJSON1 Semigroup.Last where
1686+ liftParseJSON p _ a = Semigroup.Last <$> p a
1687+ {-# INLINE liftParseJSON #-}
1689+ liftParseJSONList _ p a = fmap Semigroup.Last <$> p a
1690+ {-# INLINE liftParseJSONList #-}
1692+instance (FromJSON a) => FromJSON (Semigroup.Last a) where
1613 parseJSON = parseJSON1
1693 parseJSON = parseJSON1
1614 {-# INLINE parseJSON #-}
1694 {-# INLINE parseJSON #-}
1696+ parseJSONList = liftParseJSONList parseJSON parseJSONList
1697+ {-# INLINE parseJSONList #-}
1617−instance FromJSON1 First where
1700+instance FromJSON1 Semigroup.WrappedMonoid where
1618− liftParseJSON p p' = fmap First . liftParseJSON p p'
1701+ liftParseJSON p _ a = Semigroup.WrapMonoid <$> p a
1619 {-# INLINE liftParseJSON #-}
1702 {-# INLINE liftParseJSON #-}
1704+ liftParseJSONList _ p a = fmap Semigroup.WrapMonoid <$> p a
1705+ {-# INLINE liftParseJSONList #-}
1621−instance FromJSON a => FromJSON (First a) where
1707+instance (FromJSON a) => FromJSON (Semigroup.WrappedMonoid a) where
1622 parseJSON = parseJSON1
1708 parseJSON = parseJSON1
1623 {-# INLINE parseJSON #-}
1709 {-# INLINE parseJSON #-}
1711+ parseJSONList = liftParseJSONList parseJSON parseJSONList
1712+ {-# INLINE parseJSONList #-}
1626−instance FromJSON1 Last where
1715+instance FromJSON1 Semigroup.Option where
1627− liftParseJSON p p' = fmap Last . liftParseJSON p p'
1716+ liftParseJSON p p' = fmap Semigroup.Option . liftParseJSON p p'
1628 {-# INLINE liftParseJSON #-}
1717 {-# INLINE liftParseJSON #-}
1630−instance FromJSON a => FromJSON (Last a) where
1719+instance FromJSON a => FromJSON (Semigroup.Option a) where
1631 parseJSON = parseJSON1
1720 parseJSON = parseJSON1
1632 {-# INLINE parseJSON #-}
1721 {-# INLINE parseJSON #-}