[Haskell-cafe] Having a very annoying problem related with (I think) lazy IO

Yuras Shumovich shumovichy at gmail.com
Fri Dec 12 16:20:18 UTC 2014


What if you replace the `putStrLn` with `yield` or `threadDelay 1`?
Probably the loop is too fast, and it doesn't give other parts of your
program to take a lock.

On Fri, 2014-12-12 at 17:58 +0200, Ömer Sinan Ağacan wrote:
> Hi all,
> 
> I'm having a horrible bug in my program: a print statement that
> doesn't force any values(e.g. it just prints a static string)
> effecting the behavior of the program.
> 
> I tried hard to produce a minimal example, but couldn't manage it. So
> instead I'm just going to point to the source code of my program:
> https://github.com/osa1/rho-torrent/blob/master/src/Rho/Listener.hs#L125
> 
> If I remove this print statement everything goes weird. I think when I
> remove this statement some effects are not happening, or happening in
> wrong times.
> 
> Here's how I'm testing the different behavior: This is a network
> application and I'm creating an environment in my system and making
> this program talk to another program.
> 
> I run my program 10 times without the print statement, and run 10 times with it.
> 
> Both groups produce same output in every time, but outputs of first
> group and second group are different from each other. (apart from
> extra prints, of course)
> 
> So this print statement effects some other things, and expected
> behavior is the one happening with print statement.
> 
> I know the program is big for anyone to figure things in short amount
> of time, I'm just looking for tips and pitfalls that I may be falling.
> Does anyone have any ideas what I may be doing wrong? Note that the
> program doesn't use any unsafe stuff.
> 
> Thanks in advance.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe




More information about the Haskell-Cafe mailing list