I'm trying to figure out how to improve the transliteration from German umlauts to ASCII for id
identifiers in Pandoc. Currently there is only a mapping Char -> Maybe Char
, that converts ä
into a
and ß
into Nothing
etc., but the most common convention maps ä
into ae
and ß
into ss
and so on. Here is what I have so far:
import Data.Char (isAscii)
import qualified Data.Map as M
asciiMap' :: M.Map Char String
asciiMap' = M.fromList
[('\196',"Ae")
,('\214',"Oe")
,('\220',"Ue")
,('\223',"ss")
,('\228',"ae")
,('\246',"oe")
,('\252',"ue")
]
toAsciiStr :: Char -> String
toAsciiStr c | isAscii c = [c]
| otherwise = M.findWithDefault "" c asciiMap'
myTranslit :: String -> String
myTranslit [] = []
myTranslit (x:xs) = toAsciiStr x ++ myTranslit xs
My question is about myTranslit
.
Is there maybe already a built-in map-like function someMap :: (a -> [a]) -> [a] -> [a]
?