I am trying to make a function that takes a list of strings and executes the command putStrLn
or print
(I think they are basically equivalent, please correct me if I am wrong as I'm still new to Haskell) to every element and have it printed out on my terminal screen. I was experimenting with the map
function and also with lambda/anonymous functions as I already know how to do this recursively but wanted to try a more complex non recursive version. map
returned a list of the type IO() which was not what I was going for and my attempts at lambda functions did not go according to plan. The basic code was:
test :: [String] -> something
test x = map (\a->putStrLn a) x -- output for this function would have to be [IO()]
Not entirely sure what the output of the function was supposed to be either which also gave me issues.
I was thinking of making a temp :: String
variable and have each String appended to temp and then putStrLn temp
but was not sure how to do that entirely. I though using where
would be viable but I still ran into issues. I know how to do this in languages like java and C but I am still quite new to Haskell. Any help would be appreciated.