License | GNU LGPLv3 |
---|---|
Maintainer | paul.bittner@uni-ulm.de |
Safe Haskell | Safe |
A module containing various utility functions.
Synopsis
- genIndent :: Int -> String
- safeFromJust :: Maybe a -> (() -> a) -> a
- reversefoldr :: (a -> b -> b) -> b -> [a] -> b
- parenIf :: Bool -> String -> String
- takeIf :: (a -> Bool) -> Maybe a -> Maybe a
- nothingIf :: (a -> Bool) -> a -> Maybe a
- removeFirstAndLast :: [a] -> [a]
- removeQuotes :: String -> String
Documentation
safeFromJust :: Maybe a -> (() -> a) -> a Source #
Returns x
iff the given Maybe is Just x
.
Otherwise, returns the value produced by the given generator function.
reversefoldr :: (a -> b -> b) -> b -> [a] -> b Source #
Folds the given list after reversing it.
parenIf :: Bool -> String -> String Source #
Generates parenthesis around the given string iff the given bool is true.
takeIf :: (a -> Bool) -> Maybe a -> Maybe a Source #
Filters the given Maybe.
If the maybe's element satisfies the given predicate, the element will be kept.
Otherwise, returns Nothing
.
nothingIf :: (a -> Bool) -> a -> Maybe a Source #
Lifts a value to a Maybe
based on a predicate.
Iff the element satisfies the predicate, the result is Nothing
.
Otherwise returns the Just
the element.
removeFirstAndLast :: [a] -> [a] Source #
Removes the first and the last element of a list.
removeQuotes :: String -> String Source #
If the given string starts and ends with quotes "
(i.e., it is of the form ""something""
), those parenthesis will be removed (i.e., turned to just "something"
).
This is used for showing strings from a polymorphic context.