-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Extra goodies for aeson -- -- Package provides extra functionality on top of aeson and -- aeson-compat @package aeson-extra @version 0.5 module Data.Aeson.Extra.CollapsedList -- | Collapsed list, singleton is represented as the value itself in JSON -- encoding. -- --
--   λ > decode "null" :: Maybe (CollapsedList [Int] Int)
--   Just (CollapsedList [])
--   λ > decode "42" :: Maybe (CollapsedList [Int] Int)
--   Just (CollapsedList [42])
--   λ > decode "[1, 2, 3]" :: Maybe (CollapsedList [Int] Int)
--   Just (CollapsedList [1,2,3])
--   
-- --
--   λ > encode (CollapsedList ([] :: [Int]))
--   "null"
--   λ > encode (CollapsedList ([42] :: [Int]))
--   "42"
--   λ > encode (CollapsedList ([1, 2, 3] :: [Int]))
--   "[1,2,3]"
--   
-- -- Documentation rely on f Alternative instance behaving -- like lists'. newtype CollapsedList f a CollapsedList :: f a -> CollapsedList f a getCollapsedList :: CollapsedList f a -> f a -- | Parses possibly collapsed array value from the object's field. -- --
--   λ > newtype V = V [Int] deriving (Show)
--   λ > instance FromJSON V where parseJSON = withObject "V" $ \obj -> V <$> parseCollapsedList obj "value"
--   λ > decode "{}" :: Maybe V
--   Just (V [])
--   λ > decode "{\"value\": null}" :: Maybe V
--   Just (V [])
--   λ > decode "{\"value\": 42}" :: Maybe V
--   Just (V [42])
--   λ > decode "{\"value\": [1, 2, 3, 4]}" :: Maybe V
--   Just (V [1,2,3,4])
--   
parseCollapsedList :: (FromJSON a, FromJSON1 f, Alternative f) => Object -> Text -> Parser (f a) instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Data.Aeson.Extra.CollapsedList.CollapsedList f) instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Data.Aeson.Extra.CollapsedList.CollapsedList f) instance GHC.Base.Functor f => GHC.Base.Functor (Data.Aeson.Extra.CollapsedList.CollapsedList f) instance GHC.Read.Read (f a) => GHC.Read.Read (Data.Aeson.Extra.CollapsedList.CollapsedList f a) instance GHC.Show.Show (f a) => GHC.Show.Show (Data.Aeson.Extra.CollapsedList.CollapsedList f a) instance GHC.Classes.Ord (f a) => GHC.Classes.Ord (Data.Aeson.Extra.CollapsedList.CollapsedList f a) instance GHC.Classes.Eq (f a) => GHC.Classes.Eq (Data.Aeson.Extra.CollapsedList.CollapsedList f a) instance (Data.Aeson.Types.FromJSON.FromJSON1 f, GHC.Base.Alternative f) => Data.Aeson.Types.FromJSON.FromJSON1 (Data.Aeson.Extra.CollapsedList.CollapsedList f) instance (Data.Aeson.Types.ToJSON.ToJSON1 f, Data.Foldable.Foldable f) => Data.Aeson.Types.ToJSON.ToJSON1 (Data.Aeson.Extra.CollapsedList.CollapsedList f) instance (Data.Aeson.Types.ToJSON.ToJSON1 f, Data.Foldable.Foldable f, Data.Aeson.Types.ToJSON.ToJSON a) => Data.Aeson.Types.ToJSON.ToJSON (Data.Aeson.Extra.CollapsedList.CollapsedList f a) instance (Data.Aeson.Types.FromJSON.FromJSON1 f, GHC.Base.Alternative f, Data.Aeson.Types.FromJSON.FromJSON a) => Data.Aeson.Types.FromJSON.FromJSON (Data.Aeson.Extra.CollapsedList.CollapsedList f a) -- | Helps writing recursive algorithms on Value, for example: -- --
--   stripNulls :: Value -> Value
--   stripNulls = cata (embed . f)
--    where
--      f (ObjectF a) = ObjectF $ HM.filter (== Null) a
--      f x = x
--   
module Data.Aeson.Extra.Recursive -- | An algebra of Value -- -- Since: aeson-extra-0.3.1.0 data ValueF a ObjectF :: ObjectF a -> ValueF a ArrayF :: !ArrayF a -> ValueF a StringF :: !Text -> ValueF a NumberF :: !Scientific -> ValueF a BoolF :: !Bool -> ValueF a NullF :: ValueF a -- | A JSON "object" (key/value map). -- -- Since: aeson-extra-0.3.1.0 type ObjectF a = HashMap Text a -- | A JSON "array" (sequence). -- -- Since: aeson-extra-0.3.1.0 type ArrayF a = Vector a instance Data.Traversable.Traversable Data.Aeson.Extra.Recursive.ValueF instance Data.Foldable.Foldable Data.Aeson.Extra.Recursive.ValueF instance GHC.Base.Functor Data.Aeson.Extra.Recursive.ValueF instance Data.Data.Data a => Data.Data.Data (Data.Aeson.Extra.Recursive.ValueF a) instance GHC.Show.Show a => GHC.Show.Show (Data.Aeson.Extra.Recursive.ValueF a) instance GHC.Read.Read a => GHC.Read.Read (Data.Aeson.Extra.Recursive.ValueF a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Aeson.Extra.Recursive.ValueF a) instance Data.Functor.Foldable.Recursive Data.Aeson.Types.Internal.Value instance Data.Functor.Foldable.Corecursive Data.Aeson.Types.Internal.Value module Data.Aeson.Extra.Merge -- | Generic merge. -- -- For example see lodashMerge. -- -- Since: aeson-extra-0.3.1.0 merge :: (forall a. (a -> a -> a) -> ValueF a -> ValueF a -> ValueF a) -> Value -> Value -> Value -- | Generic merge, in arbitrary context. -- -- Since: aeson-extra-0.3.1.0 mergeA :: Functor f => (forall a. (a -> a -> f a) -> ValueF a -> ValueF a -> f (ValueF a)) -> Value -> Value -> f Value -- | Example of using merge. see -- https://lodash.com/docs#merge: -- -- Note: not tested against JavaScript lodash, so may disagree in -- the results. lodashMerge :: Value -> Value -> Value -- | An algebra of Value -- -- Since: aeson-extra-0.3.1.0 data ValueF a ObjectF :: ObjectF a -> ValueF a ArrayF :: !ArrayF a -> ValueF a StringF :: !Text -> ValueF a NumberF :: !Scientific -> ValueF a BoolF :: !Bool -> ValueF a NullF :: ValueF a -- | A JSON "object" (key/value map). -- -- Since: aeson-extra-0.3.1.0 type ObjectF a = HashMap Text a -- | A JSON "array" (sequence). -- -- Since: aeson-extra-0.3.1.0 type ArrayF a = Vector a -- | Deprecated: Use Data.Aeson.Extra.Recursive module module Data.Aeson.Extra.Foldable module Data.Aeson.Extra.SingObject -- | Singleton value object -- --
--   λ > decode "{\"value\": 42 }" :: Maybe (SingObject "value" Int)
--   Just (SingObject 42)
--   
-- --
--   λ > encode (SingObject 42 :: SingObject "value" Int)
--   "{\"value\":42}"
--   
-- -- Available with: base >=4.7 newtype SingObject (s :: Symbol) a SingObject :: a -> SingObject (s :: Symbol) a mkSingObject :: Proxy s -> a -> SingObject s a getSingObject :: Proxy s -> SingObject s a -> a instance Data.Traversable.Traversable (Data.Aeson.Extra.SingObject.SingObject s) instance Data.Foldable.Foldable (Data.Aeson.Extra.SingObject.SingObject s) instance GHC.Base.Functor (Data.Aeson.Extra.SingObject.SingObject s) instance GHC.Read.Read a => GHC.Read.Read (Data.Aeson.Extra.SingObject.SingObject s a) instance GHC.Show.Show a => GHC.Show.Show (Data.Aeson.Extra.SingObject.SingObject s a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Aeson.Extra.SingObject.SingObject s a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Aeson.Extra.SingObject.SingObject s a) instance GHC.TypeLits.KnownSymbol s => Data.Aeson.Types.FromJSON.FromJSON1 (Data.Aeson.Extra.SingObject.SingObject s) instance GHC.TypeLits.KnownSymbol s => Data.Aeson.Types.ToJSON.ToJSON1 (Data.Aeson.Extra.SingObject.SingObject s) instance (GHC.TypeLits.KnownSymbol s, Data.Aeson.Types.FromJSON.FromJSON a) => Data.Aeson.Types.FromJSON.FromJSON (Data.Aeson.Extra.SingObject.SingObject s a) instance (GHC.TypeLits.KnownSymbol s, Data.Aeson.Types.ToJSON.ToJSON a) => Data.Aeson.Types.ToJSON.ToJSON (Data.Aeson.Extra.SingObject.SingObject s a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Data.Aeson.Extra.SingObject.SingObject s a) module Data.Aeson.Extra.Stream -- | Lazyly parse ByteString with top-level JSON array. -- -- Note: inspecting result's second field will force the list! -- --
--   let ~(values, err) = streamDecode bs
--   traverse_ processValue values
--   maybe (pure ()) printError err
--   
streamDecode :: forall a. FromJSON a => ByteString -> ([a], Maybe String) module Data.Aeson.Extra.SymTag -- | Singleton string encoded and decoded as ifself. -- --
--   λ> encode (SymTag :: SymTag "foobar")
--   "\"foobar\""
--   
-- --
--   decode "\"foobar\"" :: Maybe (SymTag "foobar")
--   Just SymTag
--   
-- --
--   decode "\"foobar\"" :: Maybe (SymTag "barfoo")
--   Nothing
--   
-- -- Available with: base >=4.7 data SymTag (s :: Symbol) SymTag :: SymTag (s :: Symbol) instance GHC.Enum.Bounded (Data.Aeson.Extra.SymTag.SymTag s) instance GHC.Enum.Enum (Data.Aeson.Extra.SymTag.SymTag s) instance GHC.Read.Read (Data.Aeson.Extra.SymTag.SymTag s) instance GHC.Show.Show (Data.Aeson.Extra.SymTag.SymTag s) instance GHC.Classes.Ord (Data.Aeson.Extra.SymTag.SymTag s) instance GHC.Classes.Eq (Data.Aeson.Extra.SymTag.SymTag s) instance GHC.TypeLits.KnownSymbol s => Data.Aeson.Types.FromJSON.FromJSON (Data.Aeson.Extra.SymTag.SymTag s) instance GHC.TypeLits.KnownSymbol s => Data.Aeson.Types.ToJSON.ToJSON (Data.Aeson.Extra.SymTag.SymTag s) instance Control.DeepSeq.NFData (Data.Aeson.Extra.SymTag.SymTag s) -- | In addition to mkValue and mkValue' helpers, this module -- exports Lift Value orphan instance for aeson <0.11 module Data.Aeson.Extra.TH -- | Create a Value from string representation. -- -- This is useful in tests. -- -- Since: aeson-extra-0.3.1.0 mkValue :: String -> Q Exp -- | Like mkValue, but replace single quotes with double quotes -- before. -- --
--   > $(mkValue' "{'a': 2 }")
--   Object (fromList [("a",Number 2.0)])
--   
-- -- Since: aeson-extra-0.3.1.0 mkValue' :: String -> Q Exp -- | More or less useful newtypes for writing FromJSON & -- ToJSON instances module Data.Aeson.Extra -- | Like encode, but produces strict ByteString. -- -- Since: 0.2.3.0 encodeStrict :: ToJSON a => a -> ByteString -- | Singleton string encoded and decoded as ifself. -- --
--   λ> encode (SymTag :: SymTag "foobar")
--   "\"foobar\""
--   
-- --
--   decode "\"foobar\"" :: Maybe (SymTag "foobar")
--   Just SymTag
--   
-- --
--   decode "\"foobar\"" :: Maybe (SymTag "barfoo")
--   Nothing
--   
-- -- Available with: base >=4.7 data SymTag (s :: Symbol) SymTag :: SymTag (s :: Symbol) -- | Singleton value object -- --
--   λ > decode "{\"value\": 42 }" :: Maybe (SingObject "value" Int)
--   Just (SingObject 42)
--   
-- --
--   λ > encode (SingObject 42 :: SingObject "value" Int)
--   "{\"value\":42}"
--   
-- -- Available with: base >=4.7 newtype SingObject (s :: Symbol) a SingObject :: a -> SingObject (s :: Symbol) a mkSingObject :: Proxy s -> a -> SingObject s a getSingObject :: Proxy s -> SingObject s a -> a -- | Collapsed list, singleton is represented as the value itself in JSON -- encoding. -- --
--   λ > decode "null" :: Maybe (CollapsedList [Int] Int)
--   Just (CollapsedList [])
--   λ > decode "42" :: Maybe (CollapsedList [Int] Int)
--   Just (CollapsedList [42])
--   λ > decode "[1, 2, 3]" :: Maybe (CollapsedList [Int] Int)
--   Just (CollapsedList [1,2,3])
--   
-- --
--   λ > encode (CollapsedList ([] :: [Int]))
--   "null"
--   λ > encode (CollapsedList ([42] :: [Int]))
--   "42"
--   λ > encode (CollapsedList ([1, 2, 3] :: [Int]))
--   "[1,2,3]"
--   
-- -- Documentation rely on f Alternative instance behaving -- like lists'. newtype CollapsedList f a CollapsedList :: f a -> CollapsedList f a getCollapsedList :: CollapsedList f a -> f a -- | Parses possibly collapsed array value from the object's field. -- --
--   λ > newtype V = V [Int] deriving (Show)
--   λ > instance FromJSON V where parseJSON = withObject "V" $ \obj -> V <$> parseCollapsedList obj "value"
--   λ > decode "{}" :: Maybe V
--   Just (V [])
--   λ > decode "{\"value\": null}" :: Maybe V
--   Just (V [])
--   λ > decode "{\"value\": 42}" :: Maybe V
--   Just (V [42])
--   λ > decode "{\"value\": [1, 2, 3, 4]}" :: Maybe V
--   Just (V [1,2,3,4])
--   
parseCollapsedList :: (FromJSON a, FromJSON1 f, Alternative f) => Object -> Text -> Parser (f a) -- | An algebra of Value -- -- Since: aeson-extra-0.3.1.0 data ValueF a ObjectF :: ObjectF a -> ValueF a ArrayF :: !ArrayF a -> ValueF a StringF :: !Text -> ValueF a NumberF :: !Scientific -> ValueF a BoolF :: !Bool -> ValueF a NullF :: ValueF a -- | A JSON "object" (key/value map). -- -- Since: aeson-extra-0.3.1.0 type ObjectF a = HashMap Text a -- | A JSON "array" (sequence). -- -- Since: aeson-extra-0.3.1.0 type ArrayF a = Vector a -- | Generic merge. -- -- For example see lodashMerge. -- -- Since: aeson-extra-0.3.1.0 merge :: (forall a. (a -> a -> a) -> ValueF a -> ValueF a -> ValueF a) -> Value -> Value -> Value -- | Example of using merge. see -- https://lodash.com/docs#merge: -- -- Note: not tested against JavaScript lodash, so may disagree in -- the results. lodashMerge :: Value -> Value -> Value -- | Lazyly parse ByteString with top-level JSON array. -- -- Note: inspecting result's second field will force the list! -- --
--   let ~(values, err) = streamDecode bs
--   traverse_ processValue values
--   maybe (pure ()) printError err
--   
streamDecode :: forall a. FromJSON a => ByteString -> ([a], Maybe String) -- | Create a Value from string representation. -- -- This is useful in tests. -- -- Since: aeson-extra-0.3.1.0 mkValue :: String -> Q Exp -- | Like mkValue, but replace single quotes with double quotes -- before. -- --
--   > $(mkValue' "{'a': 2 }")
--   Object (fromList [("a",Number 2.0)])
--   
-- -- Since: aeson-extra-0.3.1.0 mkValue' :: String -> Q Exp