on master help sign in
Add ToJSON1 Proxy, and ToJSON2 Tagged
a110629Oleg Grenrus
Data/Aeson/Types/FromJSON.hs+9
@@ -1725,12 +1725,21 @@ instance FromJSON a => FromJSON (Semigroup.Option a) where
1725-- tagged
1725-- tagged
1726-------------------------------------------------------------------------------
1726-------------------------------------------------------------------------------
1727
1727
1728+instance FromJSON1 Proxy where
1729+ {-# INLINE liftParseJSON #-}
1730+ liftParseJSON _ _ Null = pure Proxy
1731+ liftParseJSON _ _ v = typeMismatch "Proxy" v
1732+
1728instance FromJSON (Proxy a) where
1733instance FromJSON (Proxy a) where
1729 {-# INLINE parseJSON #-}
1734 {-# INLINE parseJSON #-}
1730 parseJSON Null = pure Proxy
1735 parseJSON Null = pure Proxy
1731 parseJSON v = typeMismatch "Proxy" v
1736 parseJSON v = typeMismatch "Proxy" v
1732
1737
1733
1738
1739+instance FromJSON2 Tagged where
1740+ liftParseJSON2 _ _ p _ = fmap Tagged . p
1741+ {-# INLINE liftParseJSON2 #-}
1742+
1734instance FromJSON1 (Tagged a) where
1743instance FromJSON1 (Tagged a) where
1735 liftParseJSON p _ = fmap Tagged . p
1744 liftParseJSON p _ = fmap Tagged . p
1736 {-# INLINE liftParseJSON #-}
1745 {-# INLINE liftParseJSON #-}
Data/Aeson/Types/ToJSON.hs+14−1
@@ -2165,6 +2165,13 @@ instance ToJSON a => ToJSON (Semigroup.Option a) where
2165-- tagged
2165-- tagged
2166-------------------------------------------------------------------------------
2166-------------------------------------------------------------------------------
2167
2167
2168+instance ToJSON1 Proxy where
2169+ liftToJSON _ _ _ = Null
2170+ {-# INLINE liftToJSON #-}
2171+
2172+ liftToEncoding _ _ _ = E.null_
2173+ {-# INLINE liftToEncoding #-}
2174+
2168instance ToJSON (Proxy a) where
2175instance ToJSON (Proxy a) where
2169 toJSON _ = Null
2176 toJSON _ = Null
2170 {-# INLINE toJSON #-}
2177 {-# INLINE toJSON #-}
@@ -2173,6 +2180,13 @@ instance ToJSON (Proxy a) where
2173 {-# INLINE toEncoding #-}
2180 {-# INLINE toEncoding #-}
2174
2181
2175
2182
2183+instance ToJSON2 Tagged where
2184+ liftToJSON2 _ _ t _ (Tagged x) = t x
2185+ {-# INLINE liftToJSON2 #-}
2186+
2187+ liftToEncoding2 _ _ t _ (Tagged x) = t x
2188+ {-# INLINE liftToEncoding2 #-}
2189+
2176instance ToJSON1 (Tagged a) where
2190instance ToJSON1 (Tagged a) where
2177 liftToJSON t _ (Tagged x) = t x
2191 liftToJSON t _ (Tagged x) = t x
2178 {-# INLINE liftToJSON #-}
2192 {-# INLINE liftToJSON #-}
@@ -2187,7 +2201,6 @@ instance ToJSON b => ToJSON (Tagged a b) where
2187 toEncoding = toEncoding1
2201 toEncoding = toEncoding1
2188 {-# INLINE toEncoding #-}
2202 {-# INLINE toEncoding #-}
2189
2203
2190−
2191instance ToJSONKey b => ToJSONKey (Tagged a b) where
2204instance ToJSONKey b => ToJSONKey (Tagged a b) where
2192 toJSONKey = contramapToJSONKeyFunction unTagged toJSONKey
2205 toJSONKey = contramapToJSONKeyFunction unTagged toJSONKey
2193 toJSONKeyList = contramapToJSONKeyFunction (fmap unTagged) toJSONKeyList
2206 toJSONKeyList = contramapToJSONKeyFunction (fmap unTagged) toJSONKeyList