-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A combinator library on top of Text.JSON -- -- A combinator library on top of Text.JSON -- http:hackage.haskell.orgpackageJSONb @package JSON-Combinator @version 0.0.1 -- | Combinators for Text.JSONb data types. -- http://hackage.haskell.org/package/JSONb module Text.JSONb.Combinator -- | The type of JSON arrays. type JArray = [JSON] -- | The type of JSON objects. type JObject = Trie JSON -- | Inverts the JSON value if it is a boolean. jNot :: JSON -> JSON -- | Runs the given function if the JSON value is a number. withNumber :: (Rational -> Rational) -> JSON -> JSON -- | Runs the given function if the JSON value is a string. withString :: (ByteString -> ByteString) -> JSON -> JSON -- | Runs the given function if the JSON value is an array. withArray :: (JArray -> JArray) -> JSON -> JSON -- | Runs the given function if the JSON value is an object. withObject :: (JObject -> JObject) -> JSON -> JSON -- | Runs the given function on the fields if the JSON value is an object. withObjectFields :: (ByteString -> ByteString) -> JSON -> JSON -- | Runs the given function on the field values if the JSON value is an -- object. withObjectValues :: (JSON -> JSON) -> JSON -> JSON -- | Prepends the given association if the JSON is an object. (->:) :: (ByteString, JSON) -> JSON -> JSON -- | Prepends the given value if the JSON is an array. (-->>:) :: JSON -> JSON -> JSON -- | A JSON number with the value zero. jZero :: JSON -- | A JSON string with a value of empty. jEmptyString :: JSON -- | A JSON array with a value of empty. jEmptyArray :: JSON -- | A JSON object with a value of empty. jEmptyObject :: JSON -- | A JSON boolean with a value of true. jTrue :: JSON -- | A JSON boolean with a value of false. jFalse :: JSON -- | Returns a JSON array value with the given single value. jSingleArray :: JSON -> JSON -- | Returns a JSON object value with the given single association value. jSingleObject :: ByteString -> JSON -> JSON -- | Returns the potential boolean value of a JSON value. getBool :: JSON -> Maybe Bool -- | Returns the potential number value of a JSON value. getNumber :: JSON -> Maybe Rational -- | Returns the potential string value of a JSON value. getString :: JSON -> Maybe ByteString -- | Returns the potential array value of a JSON value. getArray :: JSON -> Maybe [JSON] -- | Returns the potential object value of a JSON value. getObject :: JSON -> Maybe (Trie JSON) -- | Returns the potential object fields of a JSON value. getObjectFields :: JSON -> Maybe [ByteString] -- | Returns the potential object field values of a JSON value. getObjectValues :: JSON -> Maybe [JSON] -- | Returns whether or not a JSON is a boolean value. isBool :: JSON -> Bool -- | Returns whether or not a JSON is a boolean with the value true. isTrue :: JSON -> Bool -- | Returns whether or not a JSON is a boolean with the value false. isFalse :: JSON -> Bool -- | Returns whether or not a JSON is a number value. isNumber :: JSON -> Bool -- | Returns whether or not a JSON is a string value. isString :: JSON -> Bool -- | Returns whether or not a JSON is an array value. isArray :: JSON -> Bool -- | Returns whether or not a JSON is an object value. isObject :: JSON -> Bool -- | Returns a number value from a JSON value or if it is not a number, -- returns the given default. numberOr :: Rational -> JSON -> Rational -- | Returns a string value from a JSON value or if it is not a string, -- returns the given default. stringOr :: ByteString -> JSON -> ByteString -- | Returns a rational value from a JSON value or if it is not a rational, -- returns the given default. arrayOr :: JArray -> JSON -> JArray -- | Returns an object value from a JSON value or if it is not an object, -- returns the given default. objectOr :: Trie JSON -> JSON -> Trie JSON -- | Returns an object's fields from a JSON value or if it is not an -- object, returns the given default. objectFieldsOr :: [ByteString] -> JSON -> [ByteString] -- | Returns an object's values from a JSON value or if it is not an -- object, returns the given default. objectValuesOr :: [JSON] -> JSON -> [JSON] -- | Returns a number value from a JSON value or if it is not a number, -- returns zero. numberOrZero :: JSON -> Rational -- | Returns a string value from a JSON value or if it is not a string, -- returns an empty string. stringOrEmpty :: JSON -> ByteString -- | Returns an array value from a JSON value or if it is not an array, -- returns an empty array. arrayOrEmpty :: JSON -> JArray -- | Returns an object value from a JSON value or if it is not an object, -- returns an empty object. objectOrEmpty :: JSON -> Trie JSON -- | Returns an object's fields from a JSON value or if it is not an -- object, returns no fields. objectFieldsOrEmpty :: JSON -> [ByteString] -- | Returns an object's values from a JSON value or if it is not an -- object, returns no values. objectValuesOrEmpty :: JSON -> [JSON] -- | Runs a function on the number of a JSON value or if it is not a -- number, returns the given default. usingNumber :: a -> (Rational -> a) -> JSON -> a -- | Runs a function on the string of a JSON value or if it is not a -- string, returns the given default. usingString :: a -> (ByteString -> a) -> JSON -> a -- | Runs a function on the array of a JSON value or if it is not an array, -- returns the given default. usingArray :: a -> ([JSON] -> a) -> JSON -> a -- | Runs a function on the object of a JSON value or if it is not an -- object, returns the given default. usingObject :: a -> (Trie JSON -> a) -> JSON -> a -- | 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 :: a -> ([ByteString] -> a) -> JSON -> 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 :: a -> ([JSON] -> a) -> JSON -> a -- | Whether or not a JSON value is an object with the given field. hasField :: ByteString -> JSON -> Bool -- | Whether or not a JSON value is an object with the given field. An -- alias for hasField. (-?) :: ByteString -> JSON -> Bool -- | Returns the possible value associated with the given field if this is -- an object. field :: ByteString -> JSON -> Maybe JSON -- | Returns the possible value associated with the given field if this is -- an object. An alias for field. (-|) :: ByteString -> JSON -> Maybe JSON -- | 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 :: ByteString -> JSON -> JSON -> JSON -- | 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 :: ByteString -> JSON -> JSON -- | 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 :: ByteString -> JSON -> JSON -- | 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 :: ByteString -> JSON -> JSON -- | 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 :: ByteString -> JSON -> JSON -- | 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 :: ByteString -> JSON -> JSON -- | 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 :: ByteString -> JSON -> JSON -- | 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 :: ByteString -> JSON -> JSON -- | Traverses down JSON objects with the association fields and returns -- true if the association graph exists. hasField' :: (Foldable t) => t ByteString -> JSON -> Bool -- | Traverses down JSON objects with the association fields and returns -- true if the association graph exists. An alias for hasField'. (-??) :: (Foldable t) => t ByteString -> JSON -> Bool -- | Traverses down JSON objects with the association fields and returns -- the potential value. field' :: (Foldable t) => t ByteString -> JSON -> Maybe JSON -- | Traverses down JSON objects with the association fields and returns -- the potential value. An alias for field'. (-||) :: (Foldable t) => t ByteString -> JSON -> Maybe JSON -- | Traverses down JSON objects with the association fields and returns -- the potential value or the given default. field'Or :: (Foldable t) => JSON -> t ByteString -> JSON -> JSON -- | Traverses down JSON objects with the association fields and returns -- the potential value or a JSON null. field'OrNull :: (Foldable t) => t ByteString -> JSON -> JSON -- | Traverses down JSON objects with the association fields and returns -- the potential value or a JSON true. field'OrTrue :: (Foldable t) => t ByteString -> JSON -> JSON -- | Traverses down JSON objects with the association fields and returns -- the potential value or a JSON false. field'OrFalse :: (Foldable t) => t ByteString -> JSON -> JSON -- | Traverses down JSON objects with the association fields and returns -- the potential value or a JSON zero. field'OrZero :: (Foldable t) => t ByteString -> JSON -> JSON -- | Traverses down JSON objects with the association fields and returns -- the potential value or a JSON empty string. field'OrEmptyString :: (Foldable t) => t ByteString -> JSON -> JSON -- | Traverses down JSON objects with the association fields and returns -- the potential value or a JSON empty array. field'OrEmptyArray :: (Foldable t) => t ByteString -> JSON -> JSON -- | Traverses down JSON objects with the association fields and returns -- the potential value or a JSON empty object. field'OrEmptyObject :: (Foldable t) => t ByteString -> JSON -> JSON -- | Interacts by parsing the standard input for JSON, passing the result -- to the given function, then printing the result to standard output. interactJSON :: (Either String JSON -> JSON) -> 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' :: (String -> JSON) -> (JSON -> JSON) -> 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 :: (String -> IO ()) -> (JSON -> JSON) -> 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 :: (Either String JSON -> JSON) -> 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' :: (String -> JSON) -> (JSON -> JSON) -> 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 :: (String -> IO ()) -> (JSON -> JSON) -> FilePath -> FilePath -> IO ()