GHC appears to loop

2007-02-04 Thread Wouter Swierstra

When I try to compile to the following program, GHC seems to loop:

data Evil = Evil (Evil - Evil)

instance Show Evil where
  show _ = t

apply :: Evil - Evil - Evil
apply (Evil f) x = f x

delta :: Evil
delta = Evil (\x - x `apply` x)

omega :: Evil
omega = delta `apply` delta

main = print omega

The program codes up a non-terminating term omega - very similar to  
(\x - x x) (\x - x x) - without using recursion. The trick is to  
define an Evil data type which has a negative occurrence of Evil.


I realize it's a contrived example, but I wasn't sure if it's a known  
issue. In case it matters, I'm using GHC 6.6 on a PowerPC Mac.


All the best,

  Wouter
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: GHC appears to loop

2007-02-04 Thread Duncan Coutts
Would you say this the same as the one described in the user guide?

http://www.haskell.org/ghc/docs/latest/html/users_guide/bugs.html#bugs-ghc

GHC's inliner can be persuaded into non-termination using the
standard way to encode recursion via a data type:

  data U = MkU (U - Bool)
   
  russel :: U - Bool
  russel u@(MkU p) = not $ p u
  
  x :: Bool
  x = russel (MkU russel)

We have never found another class of programs, other than this
contrived one, that makes GHC diverge, and fixing the problem
would impose an extra overhead on every compilation. So the bug
remains un-fixed. There is more background in Secrets of the GHC
inliner.


Duncan


On Sun, 2007-02-04 at 13:49 +, Wouter Swierstra wrote:
 When I try to compile to the following program, GHC seems to loop:
 
 data Evil = Evil (Evil - Evil)
 
 instance Show Evil where
show _ = t
 
 apply :: Evil - Evil - Evil
 apply (Evil f) x = f x
 
 delta :: Evil
 delta = Evil (\x - x `apply` x)
 
 omega :: Evil
 omega = delta `apply` delta
 
 main = print omega
 
 The program codes up a non-terminating term omega - very similar to  
 (\x - x x) (\x - x x) - without using recursion. The trick is to  
 define an Evil data type which has a negative occurrence of Evil.
 
 I realize it's a contrived example, but I wasn't sure if it's a known  
 issue. In case it matters, I'm using GHC 6.6 on a PowerPC Mac.
 
 All the best,
 
Wouter


___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: GHC appears to loop

2007-02-04 Thread Wouter Swierstra

On 4 Feb 2007, at 14:12, Duncan Coutts wrote:


Would you say this the same as the one described in the user guide?

http://www.haskell.org/ghc/docs/latest/html/users_guide/ 
bugs.html#bugs-ghc


You're right of course. I checked Trac before hitting send, but  
didn't think to look any further.


Thanks for the link,

  Wouter
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users