News for hackers. Stuff that matters.
Re:Why the world needs Haskell by mercurial on Wednesday July 10, 2013 @08:57AM (#6019146)
map print doesn't have side effects. mapM_ print, certainly.
Re:Why the world needs Haskell by tmoertel on Wednesday July 10, 2013 @09:25AM (#6019284)
(mapM_ print) produces a pure function that produces a single IO action, and (map print) produces a pure function that produces a list of IO actions. Neither has any effect unless called in a context that sequences the resultant actions into the main IO action that the runtime interprets (or a thread's action).
Re:Why the world needs Haskell by mercurial on Wednesday July 10, 2013 @09:36AM (#6019353)
I meant mapM_ in an IO action actually executed. On the other hand, getting a list of IO actions, even in the IO monad, doesn't amount to much.
Re:Why the world needs Haskell by tmoertel on Wednesday July 10, 2013 @10:04AM (#6019592)
And my point is that the action that mapM_ ultimately produces is not actually executed unless you sequence it into the main action (or a thread's action). Since mapM_'s eventual action is a singleton, you can do this sequencing with any combinator taking a singleton action, for example (>>) or (>>=), but it must be sequenced nonetheless, the same as for the list of actions that (map print) produces, if you want those actions to be executed.
Re:Why the world needs Haskell by mercurial on Wednesday July 10, 2013 @11:13AM (#6020251)
Fair enough.