Let's look at the types:
map :: (a -> b) -> [a] -> [b]
"\r" :: [Char] -- Which is equivalent to String
["abcd\r","alo\r"] :: [[Char]] -- Same as [String]
remplacer :: Char -> [Char] -> [Char]
Notice remplacer takes Char, not [Char]. But replacing "\r" with '\r' alone won't work, because then we are making the first argument of map remplacer and the second '\r', in other words ((map remplacer) '\r') . This will not type check. What we want is make ramplacer '\r' the first argument:
λ> map (remplacer '\r') ["abcd\r","alo\r"]
["abcd ","alo "]
Edit: I couldn't resist exploring your how map remplacer ".." would work. For amusement, check how different of a function it is:
λ> :t map remplacer "ab"
map remplacer "ab" :: [[Char] -> [Char]]
λ> ($ "abc") <$> (map remplacer ['a', 'b'])
[" bc","a c"]
$ is simply \f a -> f a, regular function application. The original question/answer uses map twice, this one uses map three times.
remPlaceris taking chars but you are using it on strings ([char])Stringin a list ofStrings with Haskell, lists are homogeneous.