Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Data/Aeson.hs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ throwDecodeStrict' = throwDecodeStrict
--
-- \-- this encodes directly to a bytestring Builder
-- 'toEncoding' (Person name age) =
-- 'pairs' (\"name\" '.=' 'name' '<>' \"age\" '.=' age)
-- 'pairs' (\"name\" '.=' name '<>' \"age\" '.=' age)
-- @
--
-- We can now encode a value like so:
Expand Down Expand Up @@ -524,7 +524,7 @@ throwDecodeStrict' = throwDecodeStrict
--
-- @
-- 'toEncoding' (Person name age) =
-- 'pairs' (\"name\" '.=' 'name' '<>' \"age\" '.=' age)
-- 'pairs' (\"name\" '.=' name '<>' \"age\" '.=' age)
-- @
--
-- Any container type that implements 'Foldable' can be encoded to a
Expand Down Expand Up @@ -566,3 +566,6 @@ throwDecodeStrict' = throwDecodeStrict
-- <https://hackage.haskell.org/package/time time>,
-- and <https://hackage.haskell.org/package/text-iso8601 text-iso8601>
-- (where the relevant parsers are defined).

-- $optionsFields
-- The functions here are in fact record fields of the 'Options' type.
7 changes: 1 addition & 6 deletions src/Data/Aeson/Key.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ fromText = Key
toText :: Key -> Text
toText = unKey

-- | @'coercing r1 r2'@ will evaluate to @r1@ if 'Key' is 'Coercible' to 'Text',
-- and to @r2@ otherwise.
--
-- Using 'coercing' we can make more efficient implementations
-- when 'Key' is backed up by 'Text' without exposing internals.
--
-- | Partially exposed coercion for forwards compatibility.
coercionToText :: Maybe (Coercion Key Text)
coercionToText = Just Coercion
{-# INLINE coercionToText #-}
Expand Down
8 changes: 4 additions & 4 deletions src/Data/Aeson/KeyMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ import qualified Witherable as W
-- Map
-------------------------------------------------------------------------------

-- | A map from JSON key type 'Key' to 'v'.
-- | A map from JSON key type 'Key' to @v@.
newtype KeyMap v = KeyMap { unKeyMap :: Map Key v }
deriving (Eq, Ord, Data, Functor)

Expand Down Expand Up @@ -268,7 +268,7 @@ difference :: KeyMap v -> KeyMap v' -> KeyMap v
difference tm1 tm2 = KeyMap (M.difference (unKeyMap tm1) (unKeyMap tm2))

-- | The (left-biased) union of two maps. It prefers the first map when duplicate
-- keys are encountered, i.e. ('union' == 'unionWith' 'const').
-- keys are encountered, i.e. ('union' == 'unionWith' 'Prelude.const').
union :: KeyMap v -> KeyMap v -> KeyMap v
union (KeyMap x) (KeyMap y) = KeyMap (M.union x y)

Expand Down Expand Up @@ -352,7 +352,7 @@ import Data.List (sortBy)
import Data.Ord (comparing)
import Prelude (fst)

-- | A map from JSON key type 'Key' to 'v'.
-- | A map from JSON key type 'Key' to @v@.
newtype KeyMap v = KeyMap { unKeyMap :: HashMap Key v }
deriving (Eq, Ord, Data, Functor)

Expand Down Expand Up @@ -477,7 +477,7 @@ difference :: KeyMap v -> KeyMap v' -> KeyMap v
difference tm1 tm2 = KeyMap (H.difference (unKeyMap tm1) (unKeyMap tm2))

-- | The (left-biased) union of two maps. It prefers the first map when duplicate
-- keys are encountered, i.e. ('union' == 'unionWith' 'const').
-- keys are encountered, i.e. ('union' == 'unionWith' 'Prelude.const').
union :: KeyMap v -> KeyMap v -> KeyMap v
union (KeyMap x) (KeyMap y) = KeyMap (H.union x y)

Expand Down
2 changes: 1 addition & 1 deletion src/Data/Aeson/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ deriveFromJSON1 = deriveFromJSONCommon fromJSON1Class
deriveFromJSON2 :: Options
-- ^ Encoding options.
-> Name
-- ^ Name of the type for which to generate a 'FromJSON3' instance
-- ^ Name of the type for which to generate a 'FromJSON2' instance
-- declaration.
-> Q [Dec]
deriveFromJSON2 = deriveFromJSONCommon fromJSON2Class
Expand Down
6 changes: 3 additions & 3 deletions src/Data/Aeson/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
-- Portability: portable
--
-- Most frequently, you'll probably want to encode straight to UTF-8
-- (the standard JSON encoding) using 'encode'.
-- (the standard JSON encoding) using 'Data.Aeson.encode'.
--
-- You can use the conversions to 'Builder's when embedding JSON messages as
-- parts of a protocol.
Expand Down Expand Up @@ -47,8 +47,8 @@ encodeToLazyText = LT.decodeUtf8 . encodingToLazyByteString . toEncoding
-- embedded efficiently in a text-based protocol.
--
-- If you are going to immediately encode straight to a
-- 'L.ByteString', it is more efficient to use 'encode' (lazy ByteString)
-- or @'fromEncoding' . 'toEncoding'@ (ByteString.Builder) instead.
-- 'Data.ByteString.Lazy.ByteString', it is more efficient to use 'Data.Aeson.encode' (lazy ByteString)
-- or @'Data.Aeson.fromEncoding' . 'toEncoding'@ ('Builder') instead.
--
-- /Note:/ Uses 'toJSON'
encodeToTextBuilder :: ToJSON a => a -> Builder
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Aeson/Types/FromJSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ instance {-# OVERLAPPING #-} FromTaggedObject' arity U1 False where
--------------------------------------------------------------------------------

-- | Constructors need to be decoded differently depending on whether they're
-- a record or not. This distinction is made by 'ConsParseJSON'.
-- a record or not. This distinction is made by 'ConsFromJSON'.
class ConsFromJSON arity f where
consParseJSON
:: ConName :* TypeName :* Options :* FromArgs arity a
Expand Down
8 changes: 5 additions & 3 deletions src/Data/Aeson/Types/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,9 @@ arbPartition k = case compare k 1 of
-- The ordering is total, consistent with 'Eq' instance.
-- However, nothing else about the ordering is specified,
-- and it may change from environment to environment and version to version
-- of either this package or its dependencies ('hashable' and 'unordered-containers').
-- of either this package or its dependencies
-- (<https://hackage.haskell.org/package/hashable hashable> and
-- <https://hackage.haskell.org/package/unordered-containers unordered-containers>).
--
-- @since 1.5.2.0
deriving instance Ord Value
Expand Down Expand Up @@ -731,7 +733,7 @@ data Options = Options
-- 'allowOmittedFieds' controls parsing behavior.
, allowOmittedFields :: Bool
-- ^ If 'True', missing fields of a record will be filled
-- with 'omittedField' values (if they are 'Just').
-- with 'Data.Aeson.FromJSON.omittedField' values (if they are 'Just').
-- If 'False', all fields will required to present in the record object.
, sumEncoding :: SumEncoding
-- ^ Specifies how to encode constructors of a sum datatype.
Expand Down Expand Up @@ -885,7 +887,7 @@ defaultJSONKeyOptions = JSONKeyOptions id
-- | Converts from CamelCase to another lower case, interspersing
-- the character between all capital letters and their previous
-- entries, except those capital letters that appear together,
-- like 'API'.
-- like \"API\".
--
-- For use by Aeson template haskell calls.
--
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Aeson/Types/ToJSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ instance value ~ Value => KeyValueOmit Value (KM.KeyMap value) where
-- > deriving (Show,Read,Eq,Ord)
--
-- It is possible to get the 'ToJSONKey' instance for free as we did
-- with 'Foo'. However, in this case, we have a natural way to go to
-- with @Foo@. However, in this case, we have a natural way to go to
-- and from 'Text' that does not require any escape sequences. So
-- 'ToJSONKeyText' can be used instead of 'ToJSONKeyValue' to encode maps
-- as objects instead of arrays of pairs. This instance may be
Expand Down