blob: 44cdf031a3e508ffd326fb088f5e8a5e2c78db7a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
module Utils.String
( capitalizeWords
, capitalizeFirstWord
, capitalizeWord
) where
import Data.Char
capitalizeWords :: String -> String
capitalizeWords = unwords . map capitalizeWord . words
capitalizeFirstWord :: String -> String
capitalizeFirstWord = unwords . mapFirst capitalizeWord . words
capitalizeWord :: String -> String
capitalizeWord [] = []
capitalizeWord (x:xs) = toUpper x : map toLower xs
mapFirst :: (a -> a) -> [a] -> [a]
mapFirst _ [] = []
mapFirst f (x:xs) = f x : xs
|