module HolyProject.StringUtils
( projectNameFromString
, capitalize
, checkProjectName
) where
import Data.Char (toUpper,toLower,isLetter,isNumber)
import Data.List (intercalate)
import Data.List.Split (splitOneOf)
projectNameFromString :: String -> String
projectNameFromString str = intercalate "-" (splitOneOf " -" (map toLower str))
capitalize :: String -> String
capitalize str = concatMap capitalizeWord (splitOneOf " -" str)
where
capitalizeWord :: String -> String
capitalizeWord (x:xs) = toUpper x:map toLower xs
capitalizeWord _ = []
checkProjectName :: String -> Bool
checkProjectName [] = False
checkProjectName str = all (\c -> isLetter c || isNumber c || c=='-' || c==' ' ) str