I have a list of strings and tried this:
ls = [ "banana", "mango", "orange" ] main = do map PutStrLn list_of_strings
This did not work, and I do not understand why.
ghc print-list.hs print-list.hs:3:0: Couldn't match expected type `IO t' against inferred type `[IO ()]' In the expression: main When checking the type of the function `main'
Any clues? I believe this is due to the map display, not the value, but I have not found an easy way to fix this.
Currently, the only way I know to print a list of strings is to write a function that will iterate over the list, print each element (print if list [a], but print and recurs if it (a: b)). But it would be much easier to use a map ...
Thank!
io haskell monads
Jay May 31 '09 at 19:08 2009-05-31 19:08
source share