I have a function that takes two filenames, and reads the contents of those two files into
Strings, and then returns if they match or not. Here's the function:
f :: String -> String -> IO Bool f fileName1 fileName2 = do str1 <- readFile fileName1 str2 <- readFile fileName2 return (str1 == str2)
And if I use it like this from inside
main = do res <- f "A.txt" "B.txt" print res
It works and prints either
False. What I want to do is, apply this function
f to a list (of tuples) of filenames. For something like:
[("a.txt", "b.txt"), ("c.txt", "d.txt")]
b.txt have the same content and
d.txt are different).
I want to transform it (the list of file names) into a
Bool list like:
[True, False]. I tried using
mapM, but that doesn't appear to map anything (when I print the list after using
mapM, it prints the same list of tuples).
So my question is: What am I doing wrong, and how can I get a list of
Bools like I mentioned above?
Please go easy on me as I'm still quite new to Haskell and functional programming :)