
Strictness analysis generally treats non-termination and errors (calls to 'error') the same. It decides that f is strict (that is f bot = bot), and hence it can use call-by-value. In general, GHC (like every other compiler that does strictness analysis) feels free to change non-termination into a call to 'error' and vice versa. One could change that, but a lot of programs would become less efficient as a result. Simon | -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow- | haskell-users-bounces@haskell.org] On Behalf Of Bertram Felgenhauer | Sent: 20 December 2006 09:04 | To: glasgow-haskell-users@haskell.org | Subject: Curious behaviour of irrefutable pattern. | | Hi, | | consider this program: | | > module Main (f, main) where | > | > f ~(a:as) = 1 + f as | > | > main = print $ f (error "Foobar!") | | Obviously, the program should result in an error - the irrefutable | pattern of f always succeeds, so f calls itself recursively ad | infinitum and the result is <<Loop>> or nontermination. | | Or so I thought. Running this program after compiling with ghc -O | (with 6.4.2, 6.6 and 6.7) results in: | | a.out: Foobar! | | So the 'error "Foobar!"' got evaluated. The compiler somehow replaced | one 'bottom' with another which is arguably allowed. I wasn't able to | come up with an example where it turned a bottom into a value or vice | versa. | | Anyway, this looks suspicious to me, so what's happening here? | | regards, | | Bertram | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users