I need to run a function that takes two arguments multiple times. I have two lists containing these arguments, and I would like to be able to use map
or something similar to call a function with the corresponding arguments.
The function I want to call has this type:
runParseTest :: String -> String -> IO()
Lists are created as follows:
-- Get list of files in libraries directory files <- getDirectoryContents "tests/libraries" -- Filter out ".." and "." and add path let names = filter (\x -> head x /= '.') files let libs = ["tests/libraries/" ++ f | f <- names]
So, let's say that names
contains ["test1.js", "test2.js", "test3.js"]
and libs
contains ["tests/libraries/test1.js", "tests/libraries/test2.js", "tests/libraries/test3.js"]
I want to call them like this:
runParseTest "test1.js" "tests/libraries/test1.js" runParseTest "test2.js" "tests/libraries/test2.js" runParseTest "test3.js" "tests/libraries/test3.js"
I know that I can create a helper function that makes this pretty easy, but out of interest, is it possible to use map
on one line?
This is what I have so far, but obviously the first argument is always "test":
mapM_ (runParseTest "test") libs
I apologize if this is unclear. If necessary, I can provide additional information.
source share