on master help sign in
Rename Pairable (ugh) to KeyValue (better-ish)
commit9ac92bd24964de119cd407a00596bb2c07d6d2a4 authorBryan O'Sullivan <bos@serpentine.com> dateTue 26 May 2015, 13:09 (11 years ago) parent921a6c7
4 files changed+9−8
Data/Aeson.hs+1−1 Data/Aeson/Types.hs+1−1 Data/Aeson/Types/Class.hs+4−3 Data/Aeson/Types/Instances.hs+3−3
Data/Aeson.hs+1−1
@@ -54,6 +54,7 @@ module Data.Aeson
5454 , Result(..)
5555 , fromJSON
5656 , ToJSON(..)
57+ , KeyValue(..)
5758 -- ** Generic JSON classes
5859 , GFromJSON(..)
5960 , GToJSON(..)
@@ -68,7 +69,6 @@ module Data.Aeson
6869 , withScientific
6970 , withBool
7071 -- * Constructors and accessors
71− , Pairable(..)
7272 , series
7373 , (.:)
7474 , (.:?)
Data/Aeson/Types.hs+1−1
@@ -31,6 +31,7 @@ module Data.Aeson.Types
3131 , parseEither
3232 , parseMaybe
3333 , ToJSON(..)
34+ , KeyValue(..)
3435 , modifyFailure
3536 , JSONPath
3637 , formatError
@@ -50,7 +51,6 @@ module Data.Aeson.Types
5051 , withBool
5152
5253 -- * Constructors and accessors
53− , Pairable(..)
5454 , series
5555 , (.:)
5656 , (.:?)
Data/Aeson/Types/Class.hs+4−3
@@ -23,7 +23,7 @@ module Data.Aeson.Types.Class
2323 , genericToEncoding
2424 , genericParseJSON
2525 -- * Object key-value pairs
26− , Pairable(..)
26+ , KeyValue(..)
2727 ) where
2828
2929import Data.Text (Text)
@@ -199,5 +199,6 @@ class FromJSON a where
199199 default parseJSON :: (Generic a, GFromJSON (Rep a)) => Value -> Parser a
200200 parseJSON = genericParseJSON defaultOptions
201201
202−class Pairable t where
203− (.=) :: ToJSON a => Text -> a -> t
202+-- | A key-value pair for a JSON object.
203+class KeyValue t where
204+ (.=) :: ToJSON v => Text -> v -> t
Data/Aeson/Types/Instances.hs+3−3
@@ -24,6 +24,7 @@ module Data.Aeson.Types.Instances
2424 -- ** Core JSON classes
2525 FromJSON(..)
2626 , ToJSON(..)
27+ , KeyValue(..)
2728 -- ** Generic JSON classes
2829 , GFromJSON(..)
2930 , GToJSON(..)
@@ -46,7 +47,6 @@ module Data.Aeson.Types.Instances
4647 , (.:)
4748 , (.:?)
4849 , (.!=)
49− , Pairable(..)
5050 , series
5151 , typeMismatch
5252 ) where
@@ -1424,11 +1424,11 @@ withBool _ f (Bool arr) = f arr
14241424withBool expected _ v = typeMismatch expected v
14251425{-# INLINE withBool #-}
14261426
1427−instance Pairable Pair where
1427+instance KeyValue Pair where
14281428 name .= value = (name, toJSON value)
14291429 {-# INLINE (.=) #-}
14301430
1431−instance Pairable Series where
1431+instance KeyValue Series where
14321432 name .= value = Value (E.text name <> B.char7 ':' <> toEncoding value)
14331433 {-# INLINE (.=) #-}
14341434