
22 Sep
2007
22 Sep
'07
5:58 a.m.
Hi
f = f
and then try to evaluate 'f' in GHCi, as one would expect, the interpreter never returns an answer.
The funny thing is that, while it is stuck in an infinite loop, GHCi doesn't seem to use any CPU time at all.
It's called a black hole. The runtime can detect that f directly depends on f, so just gives up early. Essentially it marks f as "black hole" once it starts evaluating it, and then when it comes back to f, it knows its already doing evaluation on f, so just fails. It would be useful if there was a page on the wiki about black holes, but I can't find one... Thanks Neil