[Haskell-beginners] Problems with IO actions
Adam Bergmark
adam at edea.se
Wed Jul 1 12:48:24 EDT 2009
I have an issue with IO actions.
At the moment I have the following snippet of code, which works as I
expect it to.
mapM_ (writeChan ch) . lines =<< hGetContents h
That is, it gets each line in the file and writes it to the channel.
Previously I had just:
writeChan ch =<< hGetContents h
but when i readChan this I get the empty string every time.
I have two questions:
* I'm still a little unsure of why mapM_, sequence and the like are
necessary, could someone please explain this, or point me somewhere
where I can read up on it?
* Why does this problem occur when there is only one action to
perform?
Cheers
/ Adam Bergmark
More information about the Beginners
mailing list