-- Contains a function that removes special characters from a string.
module Utils.Drasil.Strings where

import Utils.Drasil.Lists (replaceAll)

-- | Replace occurences of special characters (@",~`-=!@#$%^&*+[]\\;'/|\"<>? "@)
--   with underscores (@"_"@).
-- 
--   TODO: This can probably become a bit more comprehensive, anything other
--   than a-z, A-Z, or 0-9 could probably be replaced.
toPlainName :: String -> String
toPlainName :: String -> String
toPlainName = String -> Char -> String -> String
forall a. Eq a => [a] -> a -> [a] -> [a]
replaceAll String
",~`-=!@#$%^&*+[]\\;'/|\"<>? " Char
'_'

-- | Replace underscores in a string with periods (@.@).
repUnd :: String -> String
repUnd :: String -> String
repUnd = (Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
rep
  where
    rep :: Char -> Char
    rep :: Char -> Char
rep Char
'_' = Char
'.'
    rep Char
c = Char
c