compiler-detected nontermination

David Roundy droundy at darcs.net
Fri Aug 10 12:49:02 EDT 2007


On Fri, Aug 10, 2007 at 01:32:48PM -0300, Isaac Dupree wrote:
> GHC in its RTS already throws Nontermination exception in some cases.  I 
> think it would be nice if, when the compiler detected nontermination, to 
> replace it with an exception and emit a warning message (hmm... if GHC 
> Core loses source code information, a warning message might be 
> difficult).  Is there any intentional use of certain nontermination?

One possible use for nontermination would be as a workaround for something
like Catch (which defines its own workarounds, but if it didnt...).  Catch
complains if your code calls error, so you could define your own:

myerror :: String -> a
myerror s = myerror s

The type of this function guarantees that it is either non-terminating or
generates an exception, so if powerful static checking prevented a
programmer from writing an exception-generating code, the desperate
programmer always has the fallback of generating non-terminating code (a
good reason for allowing error in the language, I suppose).
-- 
David Roundy
Department of Physics
Oregon State University


More information about the Glasgow-haskell-users mailing list