compiler-detected nontermination
Isaac Dupree
isaacdupree at charter.net
Fri Aug 10 12:32:48 EDT 2007
Firstly I'm assuming that GHC's strictness analyser notices things like
(bottom = bottom) or could easily do so - please correct me if I'm wrong.
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?
This is inspired by the problem that supplying default definitions for
class methods that refer to each other (such as Eq's (==) and (/=)),
doesn't warn you if you don't define them and only yields your program
not to terminate, when you run it! (noticed on haskell-prime list.)
Even if it can't be detected automatically, maybe a pragma for classes
to tell the compiler what documentation often tells users:
{-# MINIMAL_INSTANCE Eq (==) OR (/=) #-}
or for Data.Bits.Bits "Minimal complete definition: .&., .|., xor,
complement, (shift or (shiftL and shiftR)), (rotate or (rotateL and
rotateR)), bitSize and isSigned. "
{-# MINIMAL_INSTANCE Bits (.&.) AND (.|.) AND xor AND complement AND
(shift OR (shiftL AND shiftR)) AND (rotate OR (rotateL AND rotateR)) AND
bitSize AND isSigned #-}
Except that Bits is a stupid class in which you're *supposed to* leave
bitSize undefined for unlimited-precision types like Integer... GHC
already warns if you don't define bitSize...
Maybe "AND" --> "," , "OR" --> "|" or something
Thoughts?
Isaac
More information about the Glasgow-haskell-users
mailing list