[commit: ghc] master: Move docstring of `seq` to primops.txt.pp (abff2ff)

git at git.haskell.org git at git.haskell.org
Sat Sep 13 16:43:46 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/abff2ffd2d6e30b93daa0def282b9fc0795ad10d/ghc

>---------------------------------------------------------------

commit abff2ffd2d6e30b93daa0def282b9fc0795ad10d
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Sat Sep 13 18:14:55 2014 +0200

    Move docstring of `seq` to primops.txt.pp
    
    The documentation for `seq` was recently augmented via #9390 &
    cbfa107604f4cbfaf02bd633c1faa6ecb90c6dd7. However, it doesn't show
    up in the Haddock generated docs because `#ifdef __HADDOCK__` doesn't
    work as expected.  Also, it's easier to just fix the problem at the
    origin (which in this is case is the primops.txt.pp file).
    
    The benefit/downside of this is that now the extended documentation
    shows up everywhere `seq` is re-exported directly.


>---------------------------------------------------------------

abff2ffd2d6e30b93daa0def282b9fc0795ad10d
 compiler/prelude/primops.txt.pp | 13 +++++++++++--
 libraries/base/Prelude.hs       | 16 ----------------
 2 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/compiler/prelude/primops.txt.pp b/compiler/prelude/primops.txt.pp
index d5566fe..b1a42b3 100644
--- a/compiler/prelude/primops.txt.pp
+++ b/compiler/prelude/primops.txt.pp
@@ -2551,8 +2551,17 @@ pseudoop "proxy#"
 
 pseudoop   "seq"
    a -> b -> b
-   { Evaluates its first argument to head normal form, and then returns its second
-	argument as the result. }
+   { The value of {\tt seq a b} is bottom if {\tt a} is bottom, and
+     otherwise equal to {\tt b}. {\tt seq} is usually introduced to
+     improve performance by avoiding unneeded laziness.
+
+     A note on evaluation order: the expression {\tt seq a b} does
+     {\it not} guarantee that {\tt a} will be evaluated before {\tt b}.
+     The only guarantee given by {\tt seq} is that the both {\tt a}
+     and {\tt b} will be evaluated before {\tt seq} returns a value.
+     In particular, this means that {\tt b} may be evaluated before
+     {\tt a}. If you need to guarantee a specific order of evaluation,
+     you must use the function {\tt pseq} from the "parallel" package. }
 
 primtype Any
 	{ The type constructor {\tt Any} is type to which you can unsafely coerce any
diff --git a/libraries/base/Prelude.hs b/libraries/base/Prelude.hs
index 12a3d8f..f58cd17 100644
--- a/libraries/base/Prelude.hs
+++ b/libraries/base/Prelude.hs
@@ -150,19 +150,3 @@ import GHC.Num
 import GHC.Real
 import GHC.Float
 import GHC.Show
-
-
-#ifdef __HADDOCK__
--- | The value of @'seq' a b@ is bottom if @a@ is bottom, and otherwise
--- equal to @b at .  'seq' is usually introduced to improve performance by
--- avoiding unneeded laziness.
---
--- A note on evaluation order: the expression @seq a b@ does /not/ guarantee
--- that @a@ will be evaluated before @b at . The only guarantee given by @seq@ is
--- that the both @a@ and @b@ will be evaluated before @seq@ returns a value. In
--- particular, this means that @b@ may be evaluated before @a at . If you need to
--- guarantee a specific order of evaluation, you must use the function @pseq@
--- from the parallel package.
-seq :: a -> b -> b
-seq _ y = y
-#endif



More information about the ghc-commits mailing list