[Haskell-cafe] what is f=f (not) doing ?

Neil Mitchell ndmitchell at gmail.com
Sat Sep 22 05:58:49 EDT 2007


> 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...



More information about the Haskell-Cafe mailing list