module Music.Theory.String where
import Data.Char
import Data.List
str_eq_ci :: String -> String -> Bool
str_eq_ci :: [Char] -> [Char] -> Bool
str_eq_ci [Char]
x [Char]
y = forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper [Char]
x forall a. Eq a => a -> a -> Bool
== forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper [Char]
y
filter_cr :: String -> String
filter_cr :: [Char] -> [Char]
filter_cr = forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => a -> a -> Bool
(==) Char
'\r')
delete_trailing_whitespace :: String -> String
delete_trailing_whitespace :: [Char] -> [Char]
delete_trailing_whitespace = forall a. [a] -> [a]
reverse forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
dropWhile Char -> Bool
isSpace forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> [a]
reverse
unwords_nil :: [String] -> String
unwords_nil :: [[Char]] -> [Char]
unwords_nil = [[Char]] -> [Char]
unwords forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t a -> Bool
null)
unlines_nil :: [String] -> String
unlines_nil :: [[Char]] -> [Char]
unlines_nil = [[Char]] -> [Char]
unlines forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t a -> Bool
null)
unlinesNoTrailingNewline :: [String] -> String
unlinesNoTrailingNewline :: [[Char]] -> [Char]
unlinesNoTrailingNewline = forall a. [a] -> [[a]] -> [a]
intercalate [Char]
"\n"
capitalise :: String -> String
capitalise :: [Char] -> [Char]
capitalise [Char]
x = Char -> Char
toUpper (forall a. [a] -> a
head [Char]
x) forall a. a -> [a] -> [a]
: forall a. [a] -> [a]
tail [Char]
x
unCapitalise :: String -> String
unCapitalise :: [Char] -> [Char]
unCapitalise [Char]
x = Char -> Char
toLower (forall a. [a] -> a
head [Char]
x) forall a. a -> [a] -> [a]
: forall a. [a] -> [a]
tail [Char]
x
on_lines :: (String -> String) -> String -> String
on_lines :: ([Char] -> [Char]) -> [Char] -> [Char]
on_lines [Char] -> [Char]
f = [[Char]] -> [Char]
unlines forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map [Char] -> [Char]
f forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> [[Char]]
lines