Stability | unstable |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- pluralize :: Int -> String -> String
- strip :: String -> String
- lineBreaksAt :: Int -> String -> [String]
- stripAnsi :: String -> String
- type Path = ([String], String)
- joinPath :: Path -> String
- formatRequirement :: Path -> String
- filterPredicate :: String -> Path -> Bool
- safeTry :: IO a -> IO (Either SomeException a)
- formatException :: SomeException -> String
- formatExceptionWith :: (SomeException -> String) -> SomeException -> String
String functions
pluralize :: Int -> String -> String Source #
pluralize count singular
pluralizes the given singular
word unless given
count
is 1.
Examples:
>>>
pluralize 0 "example"
"0 examples"
>>>
pluralize 1 "example"
"1 example"
>>>
pluralize 2 "example"
"2 examples"
Since: 2.0.0
lineBreaksAt :: Int -> String -> [String] Source #
Ensure that lines are not longer than given n
, insert line breaks at word
boundaries
Since: 2.0.0
Working with paths
type Path = ([String], String) Source #
A Path
describes the location of a spec item within a spec tree.
It consists of a list of group descriptions and a requirement description.
Since: 2.0.0
joinPath :: Path -> String Source #
Join a Path
with slashes. The result will have a leading and a trailing
slash.
Since: 2.5.4
formatRequirement :: Path -> String Source #
Try to create a proper English sentence from a path by applying some heuristics.
Since: 2.0.0
filterPredicate :: String -> Path -> Bool Source #
A predicate that can be used to filter a spec tree.
Since: 2.0.0
Working with exceptions
safeTry :: IO a -> IO (Either SomeException a) Source #
safeTry
evaluates given action and returns its result. If an exception
occurs, the exception is returned instead. Unlike try
it is agnostic to
asynchronous exceptions.
Since: 2.0.0
formatException :: SomeException -> String Source #
The function formatException
converts an exception to a string.
This is different from show
. The type of the exception is included, e.g.:
>>>
formatException (toException DivideByZero)
"ArithException\ndivide by zero"
For IOException
s the IOErrorType
is included, as well.
Since: 2.0.0
formatExceptionWith :: (SomeException -> String) -> SomeException -> String Source #
Since: 2.11.5