lambdabot-core-5.3.1.2: Lambdabot core functionality

Safe Haskell | None
Language | Haskell98

Lambdabot.Util

Description

String and other utilities

Synopsis

- strip :: (a -> Bool) -> [a] -> [a]
- dropFromEnd :: (a -> Bool) -> [a] -> [a]
- splitFirstWord :: String -> (String, String)
- limitStr :: Int -> String -> String
- listToStr :: String -> [String] -> String
- showClean :: Show a => [a] -> String
- expandTab :: Int -> String -> String
- arePrefixesWithSpaceOf :: [String] -> String -> Bool
- arePrefixesOf :: [String] -> String -> Bool
- io :: MonadIO m => IO a -> m a
- forkUnmasked :: MonadBaseControl IO m => m () -> m ThreadId
- random :: MonadIO m => [a] -> m a
- randomFailureMsg :: (MonadIO m, MonadConfig m) => m String
- randomSuccessMsg :: MonadIO m => m String

# Documentation

strip :: (a -> Bool) -> [a] -> [a] Source #

`strip` takes as input a predicate and a list and strips elements matching the predicate from the prefix as well as the suffix of the list. Example:

    strip isSpace "   abc  " ===> "abc"

dropFromEnd :: (a -> Bool) -> [a] -> [a] Source #

Drop elements matching a predicate from the end of a list

splitFirstWord Source #

Arguments

:: 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)

limitStr :: Int -> String -> String Source #

Truncate a string to the specified length, putting ellipses at the end if necessary.

listToStr :: String -> [String] -> String Source #

Form a list of terms using a single conjunction. Example:

    listToStr "and" ["a", "b", "c"] ===> "a, b and c"

showClean :: Show a => [a] -> String Source #

show a list without heavyweight formatting NB: assumes show instance outputs a quoted `String`. under that assumption, strips the outer quotes.

expandTab :: Int -> String -> String Source #

untab an string

arePrefixesWithSpaceOf :: [String] -> String -> Bool Source #

arePrefixesOf :: [String] -> String -> Bool Source #

io :: MonadIO m => IO a -> m a Source #

forkUnmasked :: MonadBaseControl IO m => m () -> m ThreadId Source #

random :: MonadIO m => [a] -> m a Source #

Pick a random element of the list.

randomFailureMsg :: (MonadIO m, MonadConfig m) => m String Source #

randomSuccessMsg :: MonadIO m => m String Source #