|
Bug in GHC type system: msg#00012lang.haskell.glasgow.bugs
Hi, I have found a three-line program that will cause recent GHC type checker to diverge. The program is admittedly pathological, so here's the story: As part of my PhD thesis I am investigating a backend virtual machine for functional programs where * beta reduction is explicit, * consequently, (->) is a free type constructor that can be mixed with (*) and (+) in arbitrary mutual recursion. In such a system, is possible to define a well-typed, effective Y combinator. Of course, the reduction strategy has to be hand-coded explicitly. Since the lazy strategy is not the worst choice, I tried to abuse the Haskell type system for an experiment: y f = w w This is, naturally, rejected by the type checker because of recursive type equations of the form: t = t -> u But one can put a datatype constructor in between: newtype Auto a = { self :: Auto a -> a } Sadly, I cannot load this program into GHCi or compile it with GHC. HUGS (as of November 2003) has no such problem, and computes the factorial function: let fac f x = if x == 0 then 1 else x * f (x - 1) Technical details: x86 PC with AMD Athlon XP CPU SuSE 9.0 Linux with kernel 2.6.10 ghc-6.2.2 also observed for 6.4 on a different machine The log of `ghc -v -C Ups.hs` is attached. The compiler hangs after the *** Simplify: line, slowly consuming unbounded amounts of heap (presumably due to a divergent type unification). The last two log lines are issued only after a ^C signal. If 'newtype' is replaced by 'data', one more line of statistics Result size = 17 is issued before the compiler hangs, too. Greetings, Baltasar Trancon y Widemann
Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@xxxxxxxxxxx http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | too liberal handling of instance imports?, Claus Reinke |
|---|---|
| Next by Date: | RE: too liberal handling of instance imports?, Simon Marlow |
| Previous by Thread: | too liberal handling of instance imports?, Claus Reinke |
| Next by Thread: | Re: Bug in GHC type system, Christian Maeder |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |