On Sun, May 3, 2009 at 6:11 PM, Ryan Ingram <ryani.s...@gmail.com> wrote: > So, I don't know what is causing your problem, but foo will not do > what you want even with lazy ST.
That depends on what he wants to do. As long as nothing subsequent to the call to foo tries to read a reference, then foo is fine. For example, this works fine: bar r = do x <- readSTRef r writeSTRef $! x + 1 return x > take 10 $ runST (newSTRef 0 >>= \r -> sequence (repeat (bar r))) [0,1,2,3,4,5,6,7,8,9] >> Does anyone know why the program just outputs <<loop>> >> when compiled under ghc 6.10.2, and runs perfectly fine >> under ghc 6.8.2? The program is compiled with --make and -O2 As I understand it, you get <<loop>> when the RTS detects a thunk which depends on itself, which can happen if you're trying to do a strict computation lazily. I can't imagine why different versions of GHC would give different results, though. -- Dave Menendez <d...@zednenem.com> <http://www.eyrie.org/~zednenem/> _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe