-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A combinator library on top of a generalised JSON type
--
-- A combinator library on top of a generalised JSON type. The
-- highest-level module is Text.JSON.Combinator and it is
-- expected that no other module need to be explicitly imported.
--
-- Instances for the combinators are provided for two libraries available
-- on hackage:
--
--
-- - json (Text.JSON)
-- - JSONb (Text.JSONb)
--
@package JSON-Combinator
@version 0.1.1
-- | A generalisation on functions to read and write files.
module Text.JSON.InteractFile
class InteractFile z
readFile' :: InteractFile z => FilePath -> IO z
writeFile' :: InteractFile z => FilePath -> z -> IO ()
instance InteractFile ByteString
instance InteractFile [Char]
-- | A generalisation on functions to interact with standard input and
-- standard output.
module Text.JSON.Interact
class Interact z
getContents' :: Interact z => IO z
putStr' :: Interact z => z -> IO ()
interact' :: Interact z => (z -> z) -> IO ()
instance Interact ByteString
instance Interact [Char]
-- | Pretty-printing JSON values.
module Text.JSON.JSONPrint
-- | Pretty-printing JSON values.
class JSONPrint j s | j -> s
printJSON :: JSONPrint j s => j -> s
instance JSONPrint JSValue [Char]
instance JSONPrint JSON ByteString
-- | Prepending values to existing JSON association values.
module Text.JSON.JSONPrepend
-- | Prepending values to existing JSON association values.
class JSONPrepend j s | j -> s
(->:) :: JSONPrepend j s => (s, j) -> j -> j
(-->>:) :: JSONPrepend j s => j -> j -> j
instance JSONPrepend JSValue [Char]
instance JSONPrepend JSON ByteString
-- | Parsing JSON object values.
module Text.JSON.JSONParse
-- | Parsing JSON object values.
class JSONParse j p e | j -> p, j -> e
parseJSON :: JSONParse j p e => String -> p -> Either e j
-- | Parse a value with an empty source name.
parseJSON' :: JSONParse j p e => p -> Either e j
instance JSONParse JSValue [Char] ParseError
instance JSONParse JSON ByteString [Char]
-- | The base functions for accessing JSON object fields.
module Text.JSON.JSONField
class JSONField j f | j -> f
field :: JSONField j f => f -> j -> Maybe j
fields :: JSONField j f => j -> Maybe [f]
values :: JSONField j f => j -> Maybe [j]
instance JSONField JSValue [Char]
instance JSONField JSON ByteString
-- | The generalisation of a JSON object.
module Text.JSON.JSONLike
-- | The generalisation of a JSON object.
class JSONLike j s a o f | j -> s, j -> a, j -> o, o -> f
foldJSON :: JSONLike j s a o f => x -> x -> x -> (Rational -> x) -> (s -> x) -> (a j -> x) -> (o j -> x) -> j -> x
jnull :: JSONLike j s a o f => j
jtrue :: JSONLike j s a o f => j
jfalse :: JSONLike j s a o f => j
jnumber :: JSONLike j s a o f => Rational -> j
jstring :: JSONLike j s a o f => s -> j
jarray :: JSONLike j s a o f => a j -> j
jobject :: JSONLike j s a o f => o j -> j
instance JSONLike JSValue [Char] [] JSObject [Char]
instance JSONLike JSON ByteString [] Trie ByteString
-- | Combinators for JSON data types.
module Text.JSON.Combinator
-- | Inverts the JSON value if it is a boolean.
jnot :: JSONLike j s a o f => j -> j
-- | Runs the given function if the JSON value is a number.
withNumber :: JSONLike j s a o f => (Rational -> Rational) -> j -> j
-- | Runs the given function if the JSON value is a string.
withString :: JSONLike j s a o f => (s -> s) -> j -> j
-- | Runs the given function if the JSON value is an array.
withArray :: JSONLike j s a o f => (a j -> a j) -> j -> j
-- | Runs the given function if the JSON value is an object.
withObject :: JSONLike j s a o f => (o j -> o j) -> j -> j
-- | Runs the given function on the fields if the JSON value is an object.
withObjectFields :: (Functor o, JSONLike j s a o f) => (j -> j) -> j -> j
-- | The JSON value zero.
jzero :: JSONLike j s a o f => j
-- | The JSON value empty string.
jemptystring :: (Monoid s, JSONLike j s a o f) => j
-- | The JSON value empty array.
jemptyarray :: (Monoid (a j), JSONLike j s a o f) => j
-- | The JSON value empty object.
jemptyobject :: (Monoid (o j), JSONLike j s a o f) => j
-- | Puts a single value into a JSON array.
jsinglearray :: (Applicative a, JSONLike j s a o f) => j -> j
-- | Puts a single value into a JSON object.
jsingleobject :: (Applicative o, JSONLike j s a o f) => j -> j
-- | Returns the potential boolean value of a JSON value.
getBool :: JSONLike j s a o f => j -> Maybe Bool
-- | Returns the potential number value of a JSON value.
getNumber :: JSONLike j s a o f => j -> Maybe Rational
-- | Returns the potential string value of a JSON value.
getString :: JSONLike j s a o f => j -> Maybe s
-- | Returns the potential array value of a JSON value.
getArray :: JSONLike j s a o f => j -> Maybe (a j)
-- | Returns the potential object value of a JSON value.
getObject :: JSONLike j s a o f => j -> Maybe (o j)
-- | Returns whether or not a JSON is a boolean value.
isBool :: JSONLike j s a o f => j -> Bool
-- | Returns whether or not a JSON is a boolean with the value true.
isTrue :: JSONLike j s a o f => j -> Bool
-- | Returns whether or not a JSON is a boolean with the value false.
isFalse :: JSONLike j s a o f => j -> Bool
-- | Returns whether or not a JSON is a number value.
isNumber :: JSONLike j s a o f => j -> Bool
-- | Returns whether or not a JSON is a string value.
isString :: JSONLike j s a o f => j -> Bool
-- | Returns whether or not a JSON is an array value.
isArray :: JSONLike j s a o f => j -> Bool
-- | Returns whether or not a JSON is an object value.
isObject :: JSONLike j s a o f => j -> Bool
-- | Returns a number value from a JSON value or if it is not a number,
-- returns the given default.
numberOr :: JSONLike j s a o f => Rational -> j -> Rational
-- | Returns a string value from a JSON value or if it is not a string,
-- returns the given default.
stringOr :: JSONLike j s a o f => s -> j -> s
-- | Returns a rational value from a JSON value or if it is not a rational,
-- returns the given default.
arrayOr :: JSONLike j s a o f => a j -> j -> a j
-- | Returns an object value from a JSON value or if it is not an object,
-- returns the given default.
objectOr :: JSONLike j s a o f => o j -> j -> o j
-- | Returns an object's fields from a JSON value or if it is not an
-- object, returns the given default.
fieldsOr :: JSONField j f => [f] -> j -> [f]
-- | Returns an object's values from a JSON value or if it is not an
-- object, returns the given default.
valuesOr :: JSONField j f => [j] -> j -> [j]
-- | Returns a number value from a JSON value or if it is not a number,
-- returns zero.
numberOrZero :: JSONLike j s a o f => j -> Rational
-- | Returns a string value from a JSON value or if it is not a string,
-- returns an empty string.
stringOrEmpty :: (JSONLike j s a o f, Monoid s) => j -> s
-- | Returns an array value from a JSON value or if it is not an array,
-- returns an empty array.
arrayOrEmpty :: (JSONLike j s a o f, Monoid (a j)) => j -> a j
-- | Returns an object value from a JSON value or if it is not an object,
-- returns an empty object.
objectOrEmpty :: (JSONLike j s a o f, Monoid (o j)) => j -> o j
-- | Returns an object's fields from a JSON value or if it is not an
-- object, returns no fields.
objectFieldsOrEmpty :: (JSONField j f, Monoid (o j)) => j -> [f]
-- | Returns an object's values from a JSON value or if it is not an
-- object, returns no values.
objectValuesOrEmpty :: (JSONField j f, Monoid (o j)) => j -> [j]
-- | Runs a function on the number of a JSON value or if it is not a
-- number, returns the given default.
usingNumber :: JSONLike j s a o f => x -> (Rational -> x) -> j -> x
-- | Runs a function on the string of a JSON value or if it is not a
-- string, returns the given default.
usingString :: JSONLike j s a o f => x -> (s -> x) -> j -> x
-- | Runs a function on the array of a JSON value or if it is not an array,
-- returns the given default.
usingArray :: JSONLike j s a o f => x -> (a j -> x) -> j -> x
-- | Runs a function on the object of a JSON value or if it is not an
-- object, returns the given default.
usingObject :: JSONLike j s a o f => x -> (o j -> x) -> j -> x
-- | Runs a function on the fields of an object of a JSON value or if it is
-- not an object, returns the given default.
usingObjectFields :: JSONField j f => a -> ([f] -> a) -> j -> a
-- | Runs a function on the values of an object of a JSON value or if it is
-- not an object, returns the given default.
usingObjectValues :: JSONField j f => a -> ([j] -> a) -> j -> a
-- | Whether or not a JSON value is an object with the given field.
hasField :: JSONField j f => f -> j -> Bool
-- | Whether or not a JSON value is an object with the given field. An
-- alias for hasField.
(-?) :: JSONField j f => f -> j -> Bool
-- | Returns the possible value associated with the given field if this is
-- an object. An alias for field.
(-|) :: JSONField j s => s -> j -> Maybe j
-- | Returns the value associated with the given field or if this is not an
-- object or has no associated value, return the given default.
fieldOr :: JSONField j f => f -> j -> j -> j
-- | Returns the value associated with the given field or if this is not an
-- object or has no associated value, return a JSON null.
fieldOrNull :: (JSONLike j s a o f, JSONField j f) => f -> j -> j
-- | Returns the value associated with the given field or if this is not an
-- object or has no associated value, return a JSON true.
fieldOrTrue :: (JSONLike j s a o f, JSONField j f) => f -> j -> j
-- | Returns the value associated with the given field or if this is not an
-- object or has no associated value, return a JSON false.
fieldOrFalse :: (JSONLike j s a o f, JSONField j f) => f -> j -> j
-- | Returns the value associated with the given field or if this is not an
-- object or has no associated value, return a JSON zero.
fieldOrZero :: (JSONLike j s a o f, JSONField j f) => f -> j -> j
-- | Returns the value associated with the given field or if this is not an
-- object or has no associated value, return a JSON string that is empty.
fieldOrEmptyString :: (JSONLike j s a o f, JSONField j f, Monoid s) => f -> j -> j
-- | Returns the value associated with the given field or if this is not an
-- object or has no associated value, return a JSON array that is empty.
fieldOrEmptyArray :: (JSONLike j s a o f, JSONField j f, Monoid (a j)) => f -> j -> j
-- | Returns the value associated with the given field or if this is not an
-- object or has no associated value, return a JSON object that is empty.
fieldOrEmptyObject :: (JSONLike j s a o f, JSONField j f, Monoid (o j)) => f -> j -> j
-- | Traverses down JSON objects with the association fields and returns
-- true if the association graph exists.
hasField' :: (JSONField j f, Foldable t) => t f -> j -> Bool
-- | Traverses down JSON objects with the association fields and returns
-- true if the association graph exists. An alias for hasField'.
(-??) :: (JSONField j f, Foldable t) => t f -> j -> Bool
-- | Traverses down JSON objects with the association fields and returns
-- the potential value.
field' :: (JSONField j f, Foldable t) => t f -> j -> Maybe j
-- | Traverses down JSON objects with the association fields and returns
-- the potential value. An alias for field'.
(-||) :: (JSONField j f, Foldable t) => t f -> j -> Maybe j
-- | Traverses down JSON objects with the association fields and returns
-- the potential value or the given default.
field'Or :: (JSONField j f, Foldable t) => j -> t f -> j -> j
-- | Traverses down JSON objects with the association fields and returns
-- the potential value or a JSON null.
field'OrNull :: (JSONLike j s a o f, JSONField j f, Foldable t) => t f -> j -> j
-- | Traverses down JSON objects with the association fields and returns
-- the potential value or a JSON true.
field'OrTrue :: (JSONLike j s a o f, JSONField j f, Foldable t) => t f -> j -> j
-- | Traverses down JSON objects with the association fields and returns
-- the potential value or a JSON false.
field'OrFalse :: (JSONLike j s a o f, JSONField j f, Foldable t) => t f -> j -> j
-- | Traverses down JSON objects with the association fields and returns
-- the potential value or a JSON zero.
field'OrZero :: (JSONLike j s a o f, JSONField j f, Foldable t) => t f -> j -> j
-- | Traverses down JSON objects with the association fields and returns
-- the potential value or a JSON empty string.
field'OrEmptyString :: (JSONLike j s a o f, JSONField j f, Foldable t, Monoid s) => t f -> j -> j
-- | Traverses down JSON objects with the association fields and returns
-- the potential value or a JSON empty array.
field'OrEmptyArray :: (JSONLike j s a o f, JSONField j f, Foldable t, Monoid (a j)) => t f -> j -> j
-- | Traverses down JSON objects with the association fields and returns
-- the potential value or a JSON empty object.
field'OrEmptyObject :: (JSONLike j s a o f, JSONField j f, Foldable t, Monoid (o j)) => t f -> j -> j
-- | Interacts by parsing the standard input for JSON, passing the result
-- to the given function, then printing the result to standard output.
interactJSON :: (JSONPrint j' s, JSONParse j s e, Interact s) => (Either e j -> j') -> IO ()
-- | Interacts by parsing the standard input for JSON, passing a failed
-- result with a string error message to the given function, or a
-- successful result to the given function, then printing the result to
-- standard output.
interactJSON' :: (JSONPrint j' s, JSONParse j s e, Interact s) => (e -> j') -> (j -> j') -> IO ()
-- | Interacts by parsing the standard input for JSON, executing the given
-- function for a failed result with a string error message, or printing
-- a successful result to the given function and passing the result to
-- standard output.
withJSON :: (Interact p, Interact s, JSONPrint j' s, JSONParse j p e) => (e -> IO ()) -> (j -> j') -> IO ()
-- | Parses a JSON file into a possible JSON object.
readJSONFile :: (JSONParse j a e, InteractFile a) => String -> IO (Either e j)
-- | Writes a JSON object to a file.
writeJSONFile :: (InteractFile b, JSONPrint a b) => FilePath -> a -> IO ()
-- | Interacts by parsing the given file for JSON, passing the result to
-- the given function, then writing the result to the given file.
interactJSONFile :: (InteractFile p, InteractFile s, JSONPrint j' s, JSONParse j p e) => (Either e j -> j') -> FilePath -> FilePath -> IO ()
-- | Interacts by parsing the given file for JSON, passing a failed result
-- with a string error message to the given function, or a successful
-- result to the given function, then writing the result to the given
-- file.
interactJSONFile' :: (InteractFile p, InteractFile s, JSONPrint j' s, JSONParse j p e) => (e -> j') -> (j -> j') -> FilePath -> FilePath -> IO ()
-- | Interacts by parsing the given file for JSON, executing the given
-- function for a failed result with a string error message, or printing
-- a successful result to the given function and writing the result to
-- the given file.
withJSONFile :: (InteractFile p, InteractFile s, JSONPrint j' s, JSONParse j p e) => (e -> IO ()) -> (j -> j') -> FilePath -> FilePath -> IO ()