From b4a3a03d015671bf43a7339e3f75633385ddaf5d Mon Sep 17 00:00:00 2001 From: Phil Freeman Date: Tue, 9 Jun 2015 21:00:41 -0700 Subject: [PATCH] Changes for RC --- README.md | 12 +- bower.json | 19 +- .../QuickCheck.md} | 31 +--- .../QuickCheck/Arbitrary.md} | 175 ++---------------- .../QuickCheck/Data/AlphaNumString.md} | 13 +- .../QuickCheck/Data/ApproxNumber.md} | 61 +----- .../QuickCheck/Gen.md} | 64 ++----- .../QuickCheck/LCG.md} | 5 - gulpfile.js | 62 ++++--- package.json | 4 +- src/Test/QuickCheck.purs | 2 +- src/Test/QuickCheck/Gen.purs | 9 +- src/Test/QuickCheck/LCG.purs | 9 +- 13 files changed, 115 insertions(+), 351 deletions(-) rename docs/{Test.QuickCheck.md => Test/QuickCheck.md} (90%) rename docs/{Test.QuickCheck.Arbitrary.md => Test/QuickCheck/Arbitrary.md} (66%) rename docs/{Test.QuickCheck.Data.AlphaNumString.md => Test/QuickCheck/Data/AlphaNumString.md} (81%) rename docs/{Test.QuickCheck.Data.ApproxNumber.md => Test/QuickCheck/Data/ApproxNumber.md} (64%) rename docs/{Test.QuickCheck.Gen.md => Test/QuickCheck/Gen.md} (85%) rename docs/{Test.QuickCheck.LCG.md => Test/QuickCheck/LCG.md} (95%) diff --git a/README.md b/README.md index dc8cc65..9737da7 100755 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ bower install purescript-quickcheck ## Module documentation -- [Test.QuickCheck](docs/Test.QuickCheck.md) -- [Test.QuickCheck.Arbitrary](docs/Test.QuickCheck.Arbitrary.md) -- [Test.QuickCheck.Gen](docs/Test.QuickCheck.Gen.md) -- [Test.QuickCheck.LCG](docs/Test.QuickCheck.LCG.md) -- [Test.QuickCheck.Data.AlphaNumString](docs/Test.QuickCheck.Data.AlphaNumString.md) -- [Test.QuickCheck.Data.ApproxNumber](docs/Test.QuickCheck.Data.ApproxNumber.md) +- [Test.QuickCheck](docs/Test/QuickCheck.md) +- [Test.QuickCheck.Arbitrary](docs/Test/QuickCheck/Arbitrary.md) +- [Test.QuickCheck.Gen](docs/Test/QuickCheck/Gen.md) +- [Test.QuickCheck.LCG](docs/Test/QuickCheck/LCG.md) +- [Test.QuickCheck.Data.AlphaNumString](docs/Test/QuickCheck/Data/AlphaNumString.md) +- [Test.QuickCheck.Data.ApproxNumber](docs/Test/QuickCheck/Data/ApproxNumber.md) diff --git a/bower.json b/bower.json index 3c0ef99..4838c25 100644 --- a/bower.json +++ b/bower.json @@ -5,6 +5,10 @@ "John A. De Goes (http://degoes.net)", "Phil Freeman " ], + "repository": { + "type": "git", + "url": "git://github.com/purescript/purescript-quickcheck.git" + }, "ignore": [ "**/.*", "bower_components", @@ -17,11 +21,14 @@ "package.json" ], "dependencies": { - "purescript-random": "~0.2.0", - "purescript-exceptions": "~0.3.0", - "purescript-strings": "~0.5.0", - "purescript-foldable-traversable": "~0.4.0", - "purescript-console": "~0.1.0", - "purescript-math": "~0.1.1" + "purescript-random": "^0.2.0", + "purescript-exceptions": "^0.3.0", + "purescript-strings": "^0.5.0", + "purescript-arrays": "^0.4.0", + "purescript-lists": "^0.7.0", + "purescript-either": "^0.2.0", + "purescript-foldable-traversable": "^0.4.0", + "purescript-console": "^0.1.0", + "purescript-math": "^0.2.0" } } diff --git a/docs/Test.QuickCheck.md b/docs/Test/QuickCheck.md similarity index 90% rename from docs/Test.QuickCheck.md rename to docs/Test/QuickCheck.md index a1f4be2..e0f6646 100644 --- a/docs/Test.QuickCheck.md +++ b/docs/Test/QuickCheck.md @@ -1,8 +1,5 @@ -# Module Documentation - ## Module Test.QuickCheck - This module is a partial port of the Haskell QuickCheck library. QuickCheck provides a way to write _property-based_ tests. @@ -24,7 +21,7 @@ main = quickCheck \n -> n + 1 > n #### `QC` ``` purescript -type QC a = forall eff. Eff (err :: EXCEPTION, random :: RANDOM, console :: CONSOLE | eff) a +type QC a = forall eff. Eff (console :: CONSOLE, random :: RANDOM, err :: EXCEPTION | eff) a ``` A type synonym which represents the effects used by the `quickCheck` function. @@ -52,7 +49,7 @@ representing the number of tests which should be run. #### `quickCheckPure` ``` purescript -quickCheckPure :: forall prop. (Testable prop) => Int -> Int -> prop -> [Result] +quickCheckPure :: forall prop. (Testable prop) => Int -> Int -> prop -> List Result ``` Test a property, returning all test results as an array. @@ -74,44 +71,29 @@ returning a `Boolean` or `Result`. Testable properties can be passed to the `quickCheck` function. -#### `testableResult` - +##### Instances ``` purescript instance testableResult :: Testable Result -``` - - -#### `testableBoolean` - -``` purescript instance testableBoolean :: Testable Boolean -``` - - -#### `testableFunction` - -``` purescript instance testableFunction :: (Arbitrary t, Testable prop) => Testable (t -> prop) ``` - #### `Result` ``` purescript data Result - = Success + = Success | Failed String ``` The result of a test: success or failure (with an error message). -#### `showResult` - +##### Instances ``` purescript +instance testableResult :: Testable Result instance showResult :: Show Result ``` - #### `()` ``` purescript @@ -143,4 +125,3 @@ Self-documenting equality assertion Self-documenting inequality assertion - diff --git a/docs/Test.QuickCheck.Arbitrary.md b/docs/Test/QuickCheck/Arbitrary.md similarity index 66% rename from docs/Test.QuickCheck.Arbitrary.md rename to docs/Test/QuickCheck/Arbitrary.md index 14f87ea..33e4972 100644 --- a/docs/Test.QuickCheck.Arbitrary.md +++ b/docs/Test/QuickCheck/Arbitrary.md @@ -1,5 +1,3 @@ -# Module Documentation - ## Module Test.QuickCheck.Arbitrary #### `Arbitrary` @@ -16,6 +14,22 @@ _randomly-generated_. the type `t`. Combinators in the `Test.QuickCheck.Gen` module can be used to construct random generators. +##### Instances +``` purescript +instance arbBoolean :: Arbitrary Boolean +instance arbNumber :: Arbitrary Number +instance arbInt :: Arbitrary Int +instance arbString :: Arbitrary String +instance arbChar :: Arbitrary Char +instance arbUnit :: Arbitrary Unit +instance arbOrdering :: Arbitrary Ordering +instance arbArray :: (Arbitrary a) => Arbitrary (Array a) +instance arbFunction :: (Coarbitrary a, Arbitrary b) => Arbitrary (a -> b) +instance arbTuple :: (Arbitrary a, Arbitrary b) => Arbitrary (Tuple a b) +instance arbMaybe :: (Arbitrary a) => Arbitrary (Maybe a) +instance arbEither :: (Arbitrary a, Arbitrary b) => Arbitrary (Either a b) +``` + #### `Coarbitrary` ``` purescript @@ -32,173 +46,20 @@ is the role of the `coarbitrary` function. `Coarbitrary` instances can be written using the `perturbGen` function. -#### `arbBoolean` - -``` purescript -instance arbBoolean :: Arbitrary Boolean -``` - - -#### `coarbBoolean` - +##### Instances ``` purescript instance coarbBoolean :: Coarbitrary Boolean -``` - - -#### `arbNumber` - -``` purescript -instance arbNumber :: Arbitrary Number -``` - - -#### `coarbNumber` - -``` purescript instance coarbNumber :: Coarbitrary Number -``` - - -#### `arbInt` - -``` purescript -instance arbInt :: Arbitrary Int -``` - - -#### `coarbInt` - -``` purescript instance coarbInt :: Coarbitrary Int -``` - - -#### `arbString` - -``` purescript -instance arbString :: Arbitrary String -``` - - -#### `coarbString` - -``` purescript instance coarbString :: Coarbitrary String -``` - - -#### `arbChar` - -``` purescript -instance arbChar :: Arbitrary Char -``` - - -#### `coarbChar` - -``` purescript instance coarbChar :: Coarbitrary Char -``` - - -#### `arbUnit` - -``` purescript -instance arbUnit :: Arbitrary Unit -``` - - -#### `coarbUnit` - -``` purescript instance coarbUnit :: Coarbitrary Unit -``` - - -#### `arbOrdering` - -``` purescript -instance arbOrdering :: Arbitrary Ordering -``` - - -#### `coarbOrdering` - -``` purescript instance coarbOrdering :: Coarbitrary Ordering -``` - - -#### `arbArray` - -``` purescript -instance arbArray :: (Arbitrary a) => Arbitrary [a] -``` - - -#### `coarbArray` - -``` purescript -instance coarbArray :: (Coarbitrary a) => Coarbitrary [a] -``` - - -#### `arbFunction` - -``` purescript -instance arbFunction :: (Coarbitrary a, Arbitrary b) => Arbitrary (a -> b) -``` - - -#### `coarbFunction` - -``` purescript +instance coarbArray :: (Coarbitrary a) => Coarbitrary (Array a) instance coarbFunction :: (Arbitrary a, Coarbitrary b) => Coarbitrary (a -> b) -``` - - -#### `arbTuple` - -``` purescript -instance arbTuple :: (Arbitrary a, Arbitrary b) => Arbitrary (Tuple a b) -``` - - -#### `coarbTuple` - -``` purescript instance coarbTuple :: (Coarbitrary a, Coarbitrary b) => Coarbitrary (Tuple a b) -``` - - -#### `arbMaybe` - -``` purescript -instance arbMaybe :: (Arbitrary a) => Arbitrary (Maybe a) -``` - - -#### `coarbMaybe` - -``` purescript instance coarbMaybe :: (Coarbitrary a) => Coarbitrary (Maybe a) -``` - - -#### `arbEither` - -``` purescript -instance arbEither :: (Arbitrary a, Arbitrary b) => Arbitrary (Either a b) -``` - - -#### `coarbEither` - -``` purescript instance coarbEither :: (Coarbitrary a, Coarbitrary b) => Coarbitrary (Either a b) ``` - - diff --git a/docs/Test.QuickCheck.Data.AlphaNumString.md b/docs/Test/QuickCheck/Data/AlphaNumString.md similarity index 81% rename from docs/Test.QuickCheck.Data.AlphaNumString.md rename to docs/Test/QuickCheck/Data/AlphaNumString.md index 1b34316..15e9388 100644 --- a/docs/Test.QuickCheck.Data.AlphaNumString.md +++ b/docs/Test/QuickCheck/Data/AlphaNumString.md @@ -1,5 +1,3 @@ -# Module Documentation - ## Module Test.QuickCheck.Data.AlphaNumString #### `AlphaNumString` @@ -12,19 +10,16 @@ newtype AlphaNumString A newtype for `String` whose `Arbitrary` instance generated random alphanumeric strings. -#### `arbAlphaNumString` - +##### Instances ``` purescript instance arbAlphaNumString :: Arbitrary AlphaNumString +instance coarbAlphaNumString :: Coarbitrary AlphaNumString ``` - -#### `coarbAlphaNumString` +#### `runAlphaNumString` ``` purescript -instance coarbAlphaNumString :: Coarbitrary AlphaNumString +runAlphaNumString :: AlphaNumString -> String ``` - - diff --git a/docs/Test.QuickCheck.Data.ApproxNumber.md b/docs/Test/QuickCheck/Data/ApproxNumber.md similarity index 64% rename from docs/Test.QuickCheck.Data.ApproxNumber.md rename to docs/Test/QuickCheck/Data/ApproxNumber.md index 5b84c5a..d4a0956 100644 --- a/docs/Test.QuickCheck.Data.ApproxNumber.md +++ b/docs/Test/QuickCheck/Data/ApproxNumber.md @@ -1,5 +1,3 @@ -# Module Documentation - ## Module Test.QuickCheck.Data.ApproxNumber #### `ApproxNumber` @@ -12,74 +10,23 @@ newtype ApproxNumber A newtype for `Number` whose `Eq` instance uses an epsilon value to allow for precision erros when comparing. -#### `(=~=)` - -``` purescript -(=~=) :: Number -> Number -> Boolean -``` - -#### `arbitraryApproxNumber` - +##### Instances ``` purescript instance arbitraryApproxNumber :: Arbitrary ApproxNumber -``` - - -#### `coarbitraryApproxNumber` - -``` purescript instance coarbitraryApproxNumber :: Coarbitrary ApproxNumber -``` - - -#### `eqApproxNumber` - -``` purescript instance eqApproxNumber :: Eq ApproxNumber -``` - - -#### `ordApproxNumber` - -``` purescript instance ordApproxNumber :: Ord ApproxNumber -``` - - -#### `semiringApproxNumber` - -``` purescript instance semiringApproxNumber :: Semiring ApproxNumber -``` - - -#### `moduloSemiringApproxNumber` - -``` purescript instance moduloSemiringApproxNumber :: ModuloSemiring ApproxNumber -``` - - -#### `ringApproxNumber` - -``` purescript instance ringApproxNumber :: Ring ApproxNumber -``` - - -#### `divisionRingApproxNumber` - -``` purescript instance divisionRingApproxNumber :: DivisionRing ApproxNumber +instance numApproxNumber :: Num ApproxNumber ``` - -#### `numApproxNumber` +#### `(=~=)` ``` purescript -instance numApproxNumber :: Num ApproxNumber +(=~=) :: Number -> Number -> Boolean ``` - - diff --git a/docs/Test.QuickCheck.Gen.md b/docs/Test/QuickCheck/Gen.md similarity index 85% rename from docs/Test.QuickCheck.Gen.md rename to docs/Test/QuickCheck/Gen.md index 21cc4c1..c459475 100644 --- a/docs/Test.QuickCheck.Gen.md +++ b/docs/Test/QuickCheck/Gen.md @@ -1,8 +1,5 @@ -# Module Documentation - ## Module Test.QuickCheck.Gen - This module defines the random generator monad used by the `Test.QuickCheck` module, as well as helper functions for constructing random generators. @@ -18,7 +15,7 @@ the meaning of which depends on the particular generator used. #### `GenState` ``` purescript -type GenState = { size :: Size, newSeed :: Seed } +type GenState = { newSeed :: Seed, size :: Size } ``` The state of the random generator monad @@ -26,7 +23,7 @@ The state of the random generator monad #### `GenOut` ``` purescript -type GenOut a = { value :: a, state :: GenState } +type GenOut a = { state :: GenState, value :: a } ``` The output of the random generator monad @@ -41,6 +38,15 @@ The random generator monad `Gen` is a state monad which encodes a linear congruential generator. +##### Instances +``` purescript +instance functorGen :: Functor Gen +instance applyGen :: Apply Gen +instance applicativeGen :: Applicative Gen +instance bindGen :: Bind Gen +instance monadGen :: Monad Gen +``` + #### `repeatable` ``` purescript @@ -101,7 +107,7 @@ Create a random generator which chooses an integer from a range. #### `oneOf` ``` purescript -oneOf :: forall a. Gen a -> [Gen a] -> Gen a +oneOf :: forall a. Gen a -> Array (Gen a) -> Gen a ``` Create a random generator which selects and executes a random generator from @@ -110,7 +116,7 @@ a non-empty collection of random generators with uniform probability. #### `frequency` ``` purescript -frequency :: forall a. Tuple Number (Gen a) -> [Tuple Number (Gen a)] -> Gen a +frequency :: forall a. Tuple Number (Gen a) -> List (Tuple Number (Gen a)) -> Gen a ``` Create a random generator which selects and executes a random generator from @@ -119,7 +125,7 @@ a non-empty, weighted collection of random generators. #### `arrayOf` ``` purescript -arrayOf :: forall a. Gen a -> Gen [a] +arrayOf :: forall a. Gen a -> Gen (Array a) ``` Create a random generator which generates an array of random values. @@ -127,7 +133,7 @@ Create a random generator which generates an array of random values. #### `arrayOf1` ``` purescript -arrayOf1 :: forall a. Gen a -> Gen (Tuple a [a]) +arrayOf1 :: forall a. Gen a -> Gen (Tuple a (Array a)) ``` Create a random generator which generates a non-empty array of random values. @@ -135,7 +141,7 @@ Create a random generator which generates a non-empty array of random values. #### `vectorOf` ``` purescript -vectorOf :: forall a. Int -> Gen a -> Gen [a] +vectorOf :: forall a. Int -> Gen a -> Gen (Array a) ``` Create a random generator which generates a vector of random values of a specified size. @@ -143,7 +149,7 @@ Create a random generator which generates a vector of random values of a specifi #### `elements` ``` purescript -elements :: forall a. a -> [a] -> Gen a +elements :: forall a. a -> Array a -> Gen a ``` Create a random generator which selects a value from a non-empty collection with @@ -197,40 +203,4 @@ perturbGen :: forall a. Number -> Gen a -> Gen a Perturb a random generator by modifying the current seed -#### `functorGen` - -``` purescript -instance functorGen :: Functor Gen -``` - - -#### `applyGen` - -``` purescript -instance applyGen :: Apply Gen -``` - - -#### `applicativeGen` - -``` purescript -instance applicativeGen :: Applicative Gen -``` - - -#### `bindGen` - -``` purescript -instance bindGen :: Bind Gen -``` - - -#### `monadGen` - -``` purescript -instance monadGen :: Monad Gen -``` - - - diff --git a/docs/Test.QuickCheck.LCG.md b/docs/Test/QuickCheck/LCG.md similarity index 95% rename from docs/Test.QuickCheck.LCG.md rename to docs/Test/QuickCheck/LCG.md index 4dd8d69..8b966a7 100644 --- a/docs/Test.QuickCheck.LCG.md +++ b/docs/Test/QuickCheck/LCG.md @@ -1,5 +1,3 @@ -# Module Documentation - ## Module Test.QuickCheck.LCG #### `Seed` @@ -8,7 +6,6 @@ type Seed = Int ``` - #### `lcgM` ``` purescript @@ -48,5 +45,3 @@ randomSeed :: forall e. Eff (random :: RANDOM | e) Seed ``` - - diff --git a/gulpfile.js b/gulpfile.js index a0f6db2..9f8940e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,50 +1,56 @@ +/* jshint node: true */ "use strict"; var gulp = require("gulp"); var plumber = require("gulp-plumber"); var purescript = require("gulp-purescript"); -var jsvalidate = require("gulp-jsvalidate"); +var rimraf = require("rimraf"); -var paths = [ +var sources = [ "src/**/*.purs", "bower_components/purescript-*/src/**/*.purs" ]; -gulp.task("make", function() { - return gulp.src(paths) - .pipe(plumber()) - .pipe(purescript.pscMake()); -}); +var foreigns = [ + "src/**/*.js", + "bower_components/purescript-*/src/**/*.js" +]; -gulp.task("jsvalidate", ["make"], function () { - return gulp.src("output/**/*.js") - .pipe(plumber()) - .pipe(jsvalidate()); +gulp.task("clean-docs", function (cb) { + rimraf("docs", cb); }); -var docTasks = []; +gulp.task("clean-output", function (cb) { + rimraf("output", cb); +}); -var docTask = function(name) { - var taskName = "docs-" + name.toLowerCase(); - gulp.task(taskName, function () { - return gulp.src("src/" + name.replace(/\./g, "/") + ".purs") - .pipe(plumber()) - .pipe(purescript.pscDocs()) - .pipe(gulp.dest("docs/" + name + ".md")); - }); - docTasks.push(taskName); -}; +gulp.task("clean", ["clean-docs", "clean-output"]); -["Test.QuickCheck", "Test.QuickCheck.Arbitrary", "Test.QuickCheck.Gen", - "Test.QuickCheck.LCG", "Test.QuickCheck.Data.AlphaNumString", - "Test.QuickCheck.Data.ApproxNumber"].forEach(docTask); +gulp.task("make", function() { + return gulp.src(sources) + .pipe(plumber()) + .pipe(purescript.pscMake({ ffi: foreigns })); +}); -gulp.task("docs", docTasks); +gulp.task("docs", ["clean-docs"], function () { + return gulp.src(sources) + .pipe(plumber()) + .pipe(purescript.pscDocs({ + docgen: { + "Test.QuickCheck": "docs/Test/QuickCheck.md", + "Test.QuickCheck.Arbitrary": "docs/Test/QuickCheck/Arbitrary.md", + "Test.QuickCheck.Gen": "docs/Test/QuickCheck/Gen.md", + "Test.QuickCheck.LCG": "docs/Test/QuickCheck/LCG.md", + "Test.QuickCheck.Data.AlphaNumString": "docs/Test/QuickCheck/Data/AlphaNumString.md", + "Test.QuickCheck.Data.ApproxNumber": "docs/Test/QuickCheck/Data/ApproxNumber.md" + } + })); +}); gulp.task("dotpsci", function () { - return gulp.src(paths) + return gulp.src(sources) .pipe(plumber()) .pipe(purescript.dotPsci()); }); -gulp.task("default", ["jsvalidate", "docs", "dotpsci"]); +gulp.task("default", ["make", "docs", "dotpsci"]); \ No newline at end of file diff --git a/package.json b/package.json index fe845c8..0c0f2c6 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "private": true, "devDependencies": { "gulp": "^3.8.11", - "gulp-jsvalidate": "^1.0.1", "gulp-plumber": "^1.0.0", - "gulp-purescript": "^0.3.1" + "gulp-purescript": "^0.5.0-rc.1", + "rimraf": "^2.3.3" } } diff --git a/src/Test/QuickCheck.purs b/src/Test/QuickCheck.purs index c687ce7..a3198e3 100644 --- a/src/Test/QuickCheck.purs +++ b/src/Test/QuickCheck.purs @@ -19,8 +19,8 @@ module Test.QuickCheck where import Prelude -import Console (CONSOLE(), log) import Control.Monad.Eff (Eff()) +import Control.Monad.Eff.Console (CONSOLE(), log) import Control.Monad.Eff.Exception (EXCEPTION(), throwException, error) import Control.Monad.Eff.Random (RANDOM(), random) import Data.Int (fromNumber, toNumber) diff --git a/src/Test/QuickCheck/Gen.purs b/src/Test/QuickCheck/Gen.purs index 36733c5..6cf6ced 100644 --- a/src/Test/QuickCheck/Gen.purs +++ b/src/Test/QuickCheck/Gen.purs @@ -28,8 +28,8 @@ module Test.QuickCheck.Gen import Prelude -import Console (CONSOLE(), print) import Control.Monad.Eff (Eff()) +import Control.Monad.Eff.Console (CONSOLE(), print) import Data.Array ((!!), length, range) import Data.Foldable (fold) import Data.Int (fromNumber, toNumber) @@ -85,7 +85,12 @@ choose a b = (*) (max - min) >>> (+) min <$> uniform where -- | Create a random generator which chooses an integer from a range. chooseInt :: Int -> Int -> Gen Int -chooseInt a b = fromNumber <$> choose (toNumber a) (toNumber b + 0.999999999) +chooseInt a b = clamp <$> lcgStep + where + clamp :: Int -> Int + clamp x = case x `mod` (b - a) of + r | r >= 0 -> a + r + | otherwise -> b + r -- | Create a random generator which selects and executes a random generator from -- | a non-empty collection of random generators with uniform probability. diff --git a/src/Test/QuickCheck/LCG.purs b/src/Test/QuickCheck/LCG.purs index 8a041d6..372092f 100644 --- a/src/Test/QuickCheck/LCG.purs +++ b/src/Test/QuickCheck/LCG.purs @@ -10,7 +10,7 @@ module Test.QuickCheck.LCG import Prelude import Control.Monad.Eff (Eff()) -import Control.Monad.Eff.Random (RANDOM(), random) +import Control.Monad.Eff.Random (RANDOM(), randomInt) import Data.Int (fromNumber, toNumber) import Data.Int.Bits (shl) @@ -18,10 +18,7 @@ type Seed = Int -- | A magic constant for the linear congruential generator lcgM :: Int -lcgM = fromNumber lcgM' - -lcgM' :: Number -lcgM' = 1103515245.0 +lcgM = 1103515245 -- | A magic constant for the linear congruential generator lcgC :: Int @@ -36,4 +33,4 @@ lcgNext :: Int -> Int lcgNext n = (lcgM * n + lcgC) `mod` lcgN randomSeed :: forall e. Eff (random :: RANDOM | e) Seed -randomSeed = fromNumber <<< (lcgM' *) <$> random +randomSeed = randomInt 0 lcgM