projects
/
ghc-base.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ccf0491
)
Use let !y = x in .. x .. instead of seq in $! and evaluate (#2273)
author
Simon Marlow
<marlowsd@gmail.com>
Wed, 16 Sep 2009 14:04:54 +0000
(14:04 +0000)
committer
Simon Marlow
<marlowsd@gmail.com>
Wed, 16 Sep 2009 14:04:54 +0000
(14:04 +0000)
GHC/IO.hs
patch
|
blob
|
history
Prelude.hs
patch
|
blob
|
history
diff --git
a/GHC/IO.hs
b/GHC/IO.hs
index
f2ccc7d
..
9615953
100644
(file)
--- a/
GHC/IO.hs
+++ b/
GHC/IO.hs
@@
-1,5
+1,5
@@
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
-{-# OPTIONS_GHC -XNoImplicitPrelude -funbox-strict-fields #-}
+{-# OPTIONS_GHC -XNoImplicitPrelude -funbox-strict-fields -XBangPatterns #-}
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
-- |
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
-- |
@@
-336,7
+336,4
@@
a `finally` sequel =
-- > evaluate x = (return $! x) >>= return
--
evaluate :: a -> IO a
-- > evaluate x = (return $! x) >>= return
--
evaluate :: a -> IO a
-evaluate a = IO $ \s -> case a `seq` () of () -> (# s, a #)
- -- NB. can't write
- -- a `seq` (# s, a #)
- -- because we can't have an unboxed tuple as a function argument
+evaluate a = IO $ \s -> let !va = a in (# s, va #) -- NB. see #2273
diff --git
a/Prelude.hs
b/Prelude.hs
index
1006bdc
..
8ede773
100644
(file)
--- a/
Prelude.hs
+++ b/
Prelude.hs
@@
-1,4
+1,4
@@
-{-# OPTIONS_GHC -XNoImplicitPrelude #-}
+{-# OPTIONS_GHC -XNoImplicitPrelude -XBangPatterns #-}
-----------------------------------------------------------------------------
-- |
-- Module : Prelude
-----------------------------------------------------------------------------
-- |
-- Module : Prelude
@@
-172,12
+172,16
@@
import Hugs.Prelude
#ifndef __HUGS__
infixr 0 $!
#ifndef __HUGS__
infixr 0 $!
+#endif
-- -----------------------------------------------------------------------------
-- Miscellaneous functions
-- | Strict (call-by-value) application, defined in terms of 'seq'.
($!) :: (a -> b) -> a -> b
-- -----------------------------------------------------------------------------
-- Miscellaneous functions
-- | Strict (call-by-value) application, defined in terms of 'seq'.
($!) :: (a -> b) -> a -> b
+#ifdef __GLASGOW_HASKELL__
+f $! x = let !vx = x in f vx -- see #2273
+#elif !defined(__HUGS__)
f $! x = x `seq` f x
#endif
f $! x = x `seq` f x
#endif