LicenseGNU LGPLv3
Maintainerpaul.bittner@uni-ulm.de
Safe HaskellSafe

Util

Description

A module containing various utility functions.

Synopsis

Documentation

genIndent :: Int -> String Source #

Generates a string of i spaces where i is the given indent.

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.