Haskell: can't use “map putStrLn”?

后端 未结 2 1055
慢半拍i
慢半拍i 2020-12-23 16:05

I have a list of strings, and tried this:

ls = [ \"banana\", \"mango\", \"orange\" ]

main = do
       map PutStrLn list_of_strings

That di

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-23 16:49

    Ayman's answer makes most sense for this situation. In general, if you have [m ()] and you want m (), then use sequence_, where m can be any monad including IO.

提交回复
热议问题