Skip to content

Compiler loops indefinitely on Morris-style fixed-point operator

Consider the following programs:

-- program 1.hs
newtype F a = F {unF :: F a -> a}
fix f       = (\x -> f (unF x x)) (F (\x -> f (unF x x)))
fac         = fix (\f -> \n -> if n == 0 then 1 else n * f (n - 1))
main        = return ()
-- program 2: morris2.hs
newtype F a = F {unF :: F a -> a}
fix f       = (\x -> f (unF x x)) (F (\x -> f (unF x x)))
fac         = fix (\f -> \n -> if n == 0 then 1 else n * f (n - 1))
main        = print (fac 2)

The first one compiles just fine; the second however causes GHC to go in an infinite loop:

$ ghc -c morris1.hs
$
$ ghc -c morris2.hs
(loops)
Trac metadata
Trac field Value
Version 6.4.1
Type Bug
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system MacOS X
Architecture powerpc
Edited by guest
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information