Ответ 1
Вы можете использовать Data.List.Utils заменить, он ленив, и вы можете обрабатывать большой файл с некоторыми типами:
main = getContents >>= putStr . replace "sourceString" "destinationString"
Что все!
Возможная функция замены может быть
rep a b [email protected](x:xs) = if isPrefixOf a s
-- then, write 'b' and replace jumping 'a' substring
then b++rep a b (drop (length a) s)
-- then, write 'x' char and try to replace tail string
else x:rep a b xs
rep _ _ [] = []
другой умный способ (из Data.String.Utils)
replace :: Eq a => [a] -> [a] -> [a] -> [a]
replace old new l = join new . split old $ l