|
|
|
|
|
Description |
Utility functions.
|
|
Synopsis |
|
debug :: Show a => a -> a | | debugFn :: Show b => (a -> b) -> a -> a | | debugXy :: Show a => a -> b -> b | | commaJoin :: [String] -> String | | sepSplit :: Eq a => a -> [a] -> [[a]] | | stdDev :: [Double] -> Double | | if' :: Bool -> a -> a -> a | | select :: a -> [(Bool, a)] -> a | | type JSRecord = [(String, JSValue)] | | fromJResult :: Monad m => String -> Result a -> m a | | readEitherString :: Monad m => JSValue -> m String | | loadJSArray :: Monad m => String -> String -> m [JSObject JSValue] | | fromObj :: (JSON a, Monad m) => JSRecord -> String -> m a | | maybeFromObj :: (JSON a, Monad m) => JSRecord -> String -> m (Maybe a) | | fromObjWithDefault :: (JSON a, Monad m) => JSRecord -> String -> a -> m a | | fromKeyValue :: (JSON a, Monad m) => String -> JSValue -> m a | | annotateResult :: String -> Result a -> Result a | | tryFromObj :: JSON a => String -> JSRecord -> String -> Result a | | fromJVal :: (Monad m, JSON a) => JSValue -> m a | | asJSObject :: Monad m => JSValue -> m (JSObject JSValue) | | asObjectList :: Monad m => [JSValue] -> m [JSObject JSValue] | | parseChoices :: (Monad m, Read a) => String -> String -> [(a, String)] -> m a | | tryRead :: (Monad m, Read a) => String -> String -> m a | | formatTable :: [[String]] -> [Bool] -> [[String]] | | defaultGroupID :: GroupID | | parseUnit :: (Monad m, Integral a, Read a) => String -> m a |
|
|
|
Debug functions
|
|
debug :: Show a => a -> a | Source |
|
To be used only for debugging, breaks referential integrity.
|
|
debugFn :: Show b => (a -> b) -> a -> a | Source |
|
Displays a modified form of the second parameter before returning
it.
|
|
debugXy :: Show a => a -> b -> b | Source |
|
Show the first parameter before returning the second one.
|
|
Miscellaneous
|
|
commaJoin :: [String] -> String | Source |
|
Comma-join a string list.
|
|
sepSplit :: Eq a => a -> [a] -> [[a]] | Source |
|
Split a list on a separator and return an array.
|
|
Mathematical functions
|
|
stdDev :: [Double] -> Double | Source |
|
Standard deviation function.
|
|
Logical functions
|
|
|
:: | | => Bool | "then" result
| -> a | "else" result
| -> a | "then" or else result depending on the condition
| -> a | | "if" as a function, rather than as syntactic sugar.
|
|
|
|
:: | | => a | list of "condition, result"
| -> [(Bool, a)] | first result which has a True condition, or default
| -> a | | Return the first result with a True condition, or the default otherwise.
|
|
|
JSON-related functions
|
|
type JSRecord = [(String, JSValue)] | Source |
|
A type alias for the list-based representation of J.JSObject.
|
|
fromJResult :: Monad m => String -> Result a -> m a | Source |
|
Converts a JSON Result into a monadic value.
|
|
readEitherString :: Monad m => JSValue -> m String | Source |
|
Tries to read a string from a JSON value.
In case the value was not a string, we fail the read (in the
context of the current monad.
|
|
|
:: Monad m | | => String | Input message
| -> String | | -> m [JSObject JSValue] | | Converts a JSON message into an array of JSON objects.
|
|
|
|
Reads the value of a key in a JSON object.
|
|
maybeFromObj :: (JSON a, Monad m) => JSRecord -> String -> m (Maybe a) | Source |
|
Reads the value of an optional key in a JSON object.
|
|
fromObjWithDefault :: (JSON a, Monad m) => JSRecord -> String -> a -> m a | Source |
|
Reads the value of a key in a JSON object with a default if missing.
|
|
|
:: (JSON a, Monad m) | | => String | The value to read
| -> JSValue | | -> m a | | Reads a JValue, that originated from an object key.
|
|
|
|
Annotate a Result with an ownership information.
|
|
|
:: JSON a | | => String | The object array
| -> JSRecord | The desired key from the object
| -> String | | -> Result a | | Try to extract a key from a object with better error reporting
than fromObj.
|
|
|
fromJVal :: (Monad m, JSON a) => JSValue -> m a | Source |
|
Small wrapper over readJSON.
|
|
asJSObject :: Monad m => JSValue -> m (JSObject JSValue) | Source |
|
Converts a JSON value into a JSON object.
|
|
asObjectList :: Monad m => [JSValue] -> m [JSObject JSValue] | Source |
|
Coneverts a list of JSON values into a list of JSON objects.
|
|
Parsing utility functions
|
|
parseChoices :: (Monad m, Read a) => String -> String -> [(a, String)] -> m a | Source |
|
Parse results from readsPrec.
|
|
tryRead :: (Monad m, Read a) => String -> String -> m a | Source |
|
Safe read function returning data encapsulated in a Result.
|
|
formatTable :: [[String]] -> [Bool] -> [[String]] | Source |
|
Format a table of strings to maintain consistent length.
|
|
|
Default group UUID (just a string, not a real UUID).
|
|
parseUnit :: (Monad m, Integral a, Read a) => String -> m a | Source |
|
Tries to extract number and scale from the given string.
Input must be in the format NUMBER+ SPACE* [UNIT]. If no unit is
specified, it defaults to MiB. Return value is always an integral
value in MiB.
|
|
Produced by Haddock version 2.6.0 |