Stability | unstable |
---|---|
Safe Haskell | Safe |
Language | Haskell2010 |
- pluralize :: Int -> String -> String
- strip :: String -> String
- lineBreaksAt :: Int -> String -> [String]
- type Path = ([String], String)
- formatRequirement :: Path -> String
- filterPredicate :: String -> Path -> Bool
- safeTry :: IO a -> IO (Either SomeException a)
- formatException :: 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"
lineBreaksAt :: Int -> String -> [String] Source
ensure that lines are not longer then given n
, insert line breaks at word
boundaries
Working with paths
type Path = ([String], String) Source
A Path
represents the location of an example within the spec tree.
It consists of a list of group descriptions and a requirement description.
formatRequirement :: Path -> String Source
Try to create a proper English sentence from a path by applying some heuristics.
filterPredicate :: String -> Path -> Bool Source
A predicate that can be used to filter a spec tree.
Working with exception
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.
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 (divide by zero)"
For IOException
s the IOErrorType
is included, as well.