On Tue, 26 Jul 2011, Manfred Lotz wrote:

main = do
s> >  con <- connectIMAP imapServer
 login con user pass
 mboxes <- list con
 mapM print mboxes

This should be mapM_ and 'ghc -Wall' spots this problem since 6.12.

The compiler (7.04) doesn't tell me anything about it.

It seems that it is no longer part of -Wall. But since this mistake is very common, I think it would be better. Problem is, that several libraries like parser libraries are designed for silently throwing away results.

You have to switch on -fwarn-unused-do-bind, according to
  
http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/options-sanity.html

Also in case this does not fix your stack space overflow, (mapM_ print) is the correct (space-efficient) way.

I'm not quite sure I understand what you mean. Stack overflow comes
from this:
       forM_ msgs (\x -> fetch con x >>= print)

If I change it to:
       mapM_  (\x -> fetch con x >>= print) msgs

there is the same stack overflow.

forM_ and mapM_ are equal in this respect, the underscore is important.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to