From b0ef36bb7b5e0374b8532822eb667aec752c928c Mon Sep 17 00:00:00 2001 From: sof Date: Wed, 3 Sep 1997 23:41:45 +0000 Subject: [PATCH] [project @ 1997-09-03 23:41:45 by sof] seq now operational --- ghc/lib/required/Prelude.lhs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ghc/lib/required/Prelude.lhs b/ghc/lib/required/Prelude.lhs index 054e3e3..ce24d75 100644 --- a/ghc/lib/required/Prelude.lhs +++ b/ghc/lib/required/Prelude.lhs @@ -73,13 +73,24 @@ import GHCerr strict :: Eval a => (a -> b) -> a -> b strict f x = x `seq` f x + +-- "seq" is defined a bit wierdly (see below) +-- +-- The reason for the strange "0# -> parError" case is that +-- it fools the compiler into thinking that seq is non-strict in +-- its second argument (even if it inlines seq at the call site). +-- If it thinks seq is strict in "y", then it often evaluates +-- "y" before "x", which is totally wrong. +-- +-- Just before converting from Core to STG there's a bit of magic +-- that recognises the seq# and eliminates the duff case. + {-# INLINE seq #-} seq :: Eval a => a -> b -> b -#ifdef __CONCURRENT_HASKELL__ -seq x y = case (seq# x) of { 0# -> parError; _ -> y } -#else -seq x y = y -- WRONG! -#endif +seq x y = case (seq# x) of { 0# -> seqError; _ -> y } + +seqError :: a +seqError = error "Oops! Entered seqError (a GHC bug -- please report it!)\n" -- It is expected that compilers will recognize this and insert error -- messages which are more appropriate to the context in which undefined -- 1.7.10.4