[commit: packages/random] master: Use strict fields for StdGen (GHC #7936) (9721b7c)
git at git.haskell.org
git at git.haskell.org
Thu Mar 19 15:44:58 UTC 2015
Repository : ssh://git@git.haskell.org/random
On branch : master
Link : http://git.haskell.org/packages/random.git/commitdiff/9721b7c09278479a763a9a187fbd91fa4faacc98
>---------------------------------------------------------------
commit 9721b7c09278479a763a9a187fbd91fa4faacc98
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date: Thu Jul 10 20:56:17 2014 +0200
Use strict fields for StdGen (GHC #7936)
>---------------------------------------------------------------
9721b7c09278479a763a9a187fbd91fa4faacc98
System/Random.hs | 2 +-
random.cabal | 7 +++++++
tests/T7936.hs | 14 ++++++++++++++
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/System/Random.hs b/System/Random.hs
index 7522499..1d0ec42 100644
--- a/System/Random.hs
+++ b/System/Random.hs
@@ -198,7 +198,7 @@ instance of 'StdGen' has the following properties:
-}
data StdGen
- = StdGen Int32 Int32
+ = StdGen !Int32 !Int32
instance RandomGen StdGen where
next = stdNext
diff --git a/random.cabal b/random.cabal
index 1039057..8353685 100644
--- a/random.cabal
+++ b/random.cabal
@@ -37,6 +37,13 @@ source-repository head
-- $ cabal configure --enable-tests
-- $ cabal test --show-details=always --test-options="+RTS -M1M -RTS"
+Test-Suite T7936
+ type: exitcode-stdio-1.0
+ main-is: T7936.hs
+ hs-source-dirs: tests
+ build-depends: base >= 3 && < 5, random
+ ghc-options: -rtsopts -O2
+
Test-Suite TestRandomRs
type: exitcode-stdio-1.0
main-is: TestRandomRs.hs
diff --git a/tests/T7936.hs b/tests/T7936.hs
new file mode 100644
index 0000000..cfea911
--- /dev/null
+++ b/tests/T7936.hs
@@ -0,0 +1,14 @@
+-- Test for ticket #7936:
+-- https://ghc.haskell.org/trac/ghc/ticket/7936
+--
+-- Used to fail with:
+--
+-- $ cabal test T7936 --test-options="+RTS -M1M -RTS"
+-- T7936: Heap exhausted;
+
+module Main where
+
+import System.Random (newStdGen)
+import Control.Monad (replicateM_)
+
+main = replicateM_ 100000 newStdGen
More information about the ghc-commits
mailing list