[Haskell-cafe] What causes <<loop>>?

Martin Hofmann martin.hofmann at uni-bamberg.de
Tue Dec 2 02:59:09 EST 2008


I am picking up a discussion with the same topic from haskell-users on
8th November.

Thunks with reference on themselves was mentioned as main reason for
<<loop>>.

> A safe recursive definition would be
>   let x = Foo (x+1)
> However, if you leave out the constructor,
>   let x = x + 1
> you get a <<loop>> (or a deadlock).
> 

Are there any other reasons? 

I am trying to debug monadic code which stores state information in a
record maintaining several Data.Maps, but in vein so far. A state is
modified/changed in several steps by a compound function i.e.

	changeA $ changeB $ changeC state

Is code using mtl, records or Maps more prone to <<loop>> or does this
not matter at all. How can I identify self-referencing thunks more
easily? Is there any rule of thumb to prevent <<loop>>? Are there any
less obvious newbie mistakes causing <<loop> then the one above?

Any comments, experience, and tips are highly appreciated.

Thanks,

Martin



More information about the Haskell-Cafe mailing list