-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Kitchen sink for querying JSON -- -- The library complements json-syntax by making available several common -- access patterns. The utilities provided by this library only query -- JSON. They do not update it. @package json-query @version 0.2.2.0 module Json.Path -- | A path to an object. data Path -- | JSON path element of a key into an object, "object.key". Key :: {-# UNPACK #-} !ShortText -> !Path -> Path -- | JSON path element of an index into an array, "array[index]". Negative -- numbers result in undefined behavior. Index :: {-# UNPACK #-} !Int -> !Path -> Path Nil :: Path encode :: Path -> ShortText builderUtf8 :: Path -> Builder -- | Search for an element at the given path. Returns Nothing if -- anything in the path is missing. query :: Path -> Value -> Maybe Value -- | Variant of query that returns Null if anything in the -- path is missing. query' :: Path -> Value -> Value reverse :: Path -> Path instance GHC.Show.Show Json.Path.Path instance GHC.Classes.Eq Json.Path.Path module Json.Context -- | A finger into a json value indicating where a parser is currently -- operating. When a parser focuses on a key-value pair in a map, it adds -- Key constructor to the context, and when it focuses on an -- element of an array, it adds an Index constructor. Like all -- zipper-like data structures, it is, in a sense, reversed, which makes -- it cheap to construct while parsing. data Context Top :: Context Key :: !ShortText -> !Context -> Context Index :: !Int -> !Context -> Context -- | Convert Context to textual representation using UTF-8 as the -- encoding scheme. This reverses the context to present it in the -- expected order. builderUtf8 :: Context -> Builder -- | Reverse the context, converting it to a Path. For example, -- toPath performs this conversion: -- --
-- 12.bar.foo.Top ==> foo.bar.12.Nil --toPath :: Context -> Path instance GHC.Show.Show Json.Context.Context instance GHC.Classes.Eq Json.Context.Context module Json.Error -- | A single error message. data Error Error :: !ShortText -> !Context -> Error [$sel:message:Error] :: Error -> !ShortText [$sel:context:Error] :: Error -> !Context encode :: Error -> ShortText builderUtf8 :: Error -> Builder instance GHC.Show.Show Json.Error.Error instance GHC.Classes.Eq Json.Error.Error module Json.Errors -- | A builder for errors that support efficient concatenation. data Errors encode :: Errors -> ShortText -- | Convert errors to builder. The errors are separated by a pair of -- characters: comma and space. builderUtf8 :: Errors -> Builder -- | Print errors to the provided handle. Typically, -- System.IO.stderr is provided as the handle. Each encoded -- error is suffixed with a newline. -- -- This is a convenience function for the common case where, after a -- failed parse, an application prints out all parse errors and then -- exits. hPut :: Handle -> Errors -> IO () singleton :: Error -> Errors -- | Convert errors to array. toSmallArray :: Errors -> SmallArray Error instance GHC.Base.Semigroup Json.Errors.Errors instance GHC.Show.Show Json.Errors.Errors instance GHC.Classes.Eq Json.Errors.Errors module Json.Parser newtype Parser a Parser :: (Context -> Either Errors a) -> Parser a [$sel:runParser:Parser] :: Parser a -> Context -> Either Errors a newtype MemberParser a MemberParser :: (Context -> SmallArray Member -> Either Errors a) -> MemberParser a [$sel:runMemberParser:MemberParser] :: MemberParser a -> Context -> SmallArray Member -> Either Errors a run :: Parser a -> Either Errors a key :: ShortText -> (Value -> Parser a) -> MemberParser a -- | Variant of key that supplies the JSON value null to -- the callback if the key is not found. Using this parser combinators -- implies that there is no distinction between null and an -- absent value in the encoding scheme. keyOptNull :: ShortText -> (Value -> Parser a) -> MemberParser a members :: MemberParser a -> SmallArray Member -> Parser a -- | Run the same parser against every element in a SmallArray. This -- adjusts the context at each element. smallArray :: (Value -> Parser a) -> SmallArray Value -> Parser (SmallArray a) -- | Run the parser against every element in a SmallArray, updating -- an accumulator at each step. Folds from left to right. This adjusts -- the context at each element. Typically, type a is -- Value. foldSmallArray :: (b -> a -> Parser b) -> b -> SmallArray a -> Parser b -- | Traverse the members. The adjusts the context at each member. traverseMembers :: (Member -> Parser a) -> SmallArray Member -> Parser (SmallArray a) object :: Value -> Parser (SmallArray Member) array :: Value -> Parser (SmallArray Value) number :: Value -> Parser Scientific boolean :: Value -> Parser Bool string :: Value -> Parser ShortText int :: Scientific -> Parser Int int32 :: Scientific -> Parser Int32 word16 :: Scientific -> Parser Word16 word64 :: Scientific -> Parser Word64 fail :: ShortText -> Parser a -- | Run a parser in a modified context. contextually :: (Context -> Context) -> Parser a -> Parser a instance GHC.Base.Functor Json.Parser.Parser instance GHC.Base.Functor Json.Parser.MemberParser instance GHC.Base.Applicative Json.Parser.MemberParser instance GHC.Base.Alternative Json.Parser.MemberParser instance GHC.Base.Monad Json.Parser.MemberParser instance GHC.Base.Applicative Json.Parser.Parser instance GHC.Base.Alternative Json.Parser.Parser instance GHC.Base.Monad Json.Parser.Parser module Json.Arrow data Parser a b type a ~> b = Parser a b run :: (a ~> b) -> a -> Either Errors b object :: Value ~> Members array :: Value ~> Elements string :: Value ~> ShortText -- | Parse an array of strings. For example: -- --
-- ["hello","world"] ---- -- Failure context includes the index of non-string value if any values -- in the array are not strings. strings :: Value ~> UnliftedArray ShortText number :: Value ~> Scientific boolean :: Value ~> Bool null :: Value ~> () newtype Members Members :: SmallArray Member -> Members [$sel:unMembers:Members] :: Members -> SmallArray Member member :: ShortText -> Members ~> Value -- | An optional member. Returns Nothing if the value is missing. memberOpt :: ShortText -> Members ~> Maybe Value foldMembers :: a -> (a -> Member ~> a) -> Members ~> a data Elements foldl' :: a -> (a -> Value ~> a) -> Elements ~> a map :: (Value ~> a) -> Elements ~> SmallArray a fail :: ShortText -> a ~> b failZero :: a ~> b withObject :: (Members ~> a) -> Value ~> a withArray :: (Value ~> a) -> Value ~> SmallArray a fromNull :: a -> Value ~> a int :: Value ~> Int word16 :: Value ~> Word16 word64 :: Value ~> Word64 liftMaybe :: ShortText -> (a -> Maybe b) -> a ~> b instance GHC.Base.Functor (Json.Arrow.Parser a) instance Data.Profunctor.Unsafe.Profunctor Json.Arrow.Parser instance GHC.Base.Applicative (Json.Arrow.Parser a) instance Control.Category.Category Json.Arrow.Parser instance Control.Arrow.Arrow Json.Arrow.Parser instance Control.Arrow.ArrowZero Json.Arrow.Parser instance Control.Arrow.ArrowPlus Json.Arrow.Parser instance Control.Arrow.ArrowChoice Json.Arrow.Parser instance Control.Arrow.ArrowApply Json.Arrow.Parser