MapM putStrLn ["a", "b"] why does it show three lines?
If you put the version of mapM in a standalone program, compile it with ghc and run it, you wonโt get the third line from it:
$ cat demo.hs main = mapM putStrLn [ "a", "b" ] $ ghc demo.hs $ ./demo a b $ That [(),()] that you see in ghci is just the return value of the mapM call; ghci automatically displays the value of each expression entered. (This is why ghci is called the Read-Evaluate-Print Loop or REPL loop, the Print part is what you see here.)
While mapM creates a list containing the return value of each call to putStrLn (so you get one () for each item in the list), mapM_ discards the return values โโand returns IO () that ghci does not bother displaying itself. So you do not see the extra line from ghci in this case.