|
|
|
Description |
String and other utilities
|
|
Synopsis |
|
|
|
Documentation |
|
|
:: | | => [a] | Glue to join with
| -> [[a]] | Elements to glue together
| -> [a] | Result: glued-together list
| concatWith joins lists with the given glue elements. Example:
concatWith ", " ["one","two","three"] ===> "one, two, three"
|
|
|
|
:: Eq a | | => [a] | Glue that holds pieces together
| -> [a] | List to break into pieces
| -> [[a]] | Result: list of pieces
| Split a list into pieces that were held together by glue. Example:
split ", " "one, two, three" ===> ["one","two","three"]
|
|
|
|
|
|
:: Eq a | | => [a] | Glue that holds pieces together
| -> [a] | List from which to break off a piece
| -> ([a], [a]) | Result: (first piece, glue ++ rest of list)
| Break off the first piece of a list held together by glue,
leaving the glue attached to the remainder of the list. Example:
Like break, but works with a [a] match.
breakOnGlue ", " "one, two, three" ===> ("one", ", two, three")
|
|
|
|
clean takes a Char x and returns [x] unless the Char is '\CR' in
case [] is returned.
|
|
|
dropSpace takes as input a String and strips spaces from the
prefix as well as the suffix of the String. Example:
dropSpace " abc " ===> "abc"
|
|
|
Drop space from the end of the string
|
|
|
|
|
:: | | => a | Element to be added
| -> [a] | List to add to
| -> [a] | Result: List ++ [Element]
| Reverse cons. Add an element to the back of a list. Example:
snoc 3 [2, 1] ===> [2, 1, 3]
|
|
|
|
:: String | Prefix string
| -> String | Data string
| -> String | Result: Data string with Prefix string and excess whitespace
removed
| after takes 2 strings, called the prefix and data. A necessary
precondition is that
Data.List.isPrefixOf prefix data ===> True
after returns a string based on data, where the prefix has been
removed as well as any excess space characters. Example:
after "This is" "This is a string" ===> "a string"
|
|
|
|
:: String | String to be broken
| -> (String, String) | | Break a String into it's first word, and the rest of the string. Example:
split_first_word "A fine day" ===> ("A", "fine day)
|
|
|
|
Get the first word of a string. Example:
first_word "This is a fine day" ===> "This"
|
|
|
debugStr checks if we have the verbose flag turned on. If we have
it outputs the String given. Else, it is a no-op.
|
|
|
debugStrLn is a version of debugStr that adds a newline to the end
of the string outputted.
|
|
|
lowerCaseString transforms the string given to lower case.
Example: lowerCaseString "MiXeDCaSe" ===> "mixedcase"
|
|
|
upperCaseString transforms the string given to upper case.
Example: upperCaseString "MiXeDcaSe" ===> "MIXEDCASE"
|
|
|
upperize forces the first char of a string to be uppercase.
if the string is empty, the empty string is returned.
|
|
|
lowerize forces the first char of a string to be lowercase.
if the string is empty, the empty string is returned.
|
|
|
quote puts a string into quotes but does not escape quotes in
the string itself.
|
|
|
|
|
Form a list of terms using a single conjunction. Example:
listToStr "and" ["a", "b", "c"] ===> "a, b and c"
|
|
|
:: Int | Width to fill to
| -> Int | Number to show
| -> String | Padded string
| Show a number, padded to the left with zeroes up to the specified width
|
|
|
|
Like listToMaybe, but take a function to use in case of a non-null list.
I.e. listToMaybe = listToMaybeWith head
|
|
|
listToMaybeAll = listToMaybeWith id |
|
|
:: RandomGen g | | => [a] | The list to pick a random item from
| -> g | The RNG to use
| -> (a, g) | A pair of the item, and the new RNG seed
| getRandItem takes as input a list and a random number generator. It
then returns a random element from the list, paired with the altered
state of the RNG
|
|
|
|
stdGetRandItem is the specialization of getRandItem to the standard
RNG embedded within the IO monad. The advantage of using this is that
you use the Operating Systems provided RNG instead of rolling your own
and the state of the RNG is hidden, so one don't need to pass it
explicitly.
|
|
|
|
|
show a list without heavyweight formatting
|
|
|
untab an string
|
|
|
Find string in list with smallest levenshtein distance from first
argument, return the string and the distance from pat it is. Will
return the alphabetically first match if there are multiple matches
(this may not be desirable, e.g. mroe -> moo, not more
|
|
|
|
|
Thread-safe modification of an MVar.
|
|
|
|
|
run an action with a timeout
|
|
choice :: (r -> Bool) -> (r -> a) -> (r -> a) -> r -> a | Source |
|
|
|
|
|
|
|
|
|
/>, <. : join two path components
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Data.Maybe.mapMaybe for Maps
|
|
|
This makes way more sense than insertWith because we don't need to
remember the order of arguments of f.
|
|
|
|
|
|
|
Two functions that really should be in Data.Either
|
|
|
Another useful Either function to easily get out of an Either
|
|
|
|
|
|
|
|
|
|
Produced by Haddock version 2.4.2 |