packages feed

real-dice (empty) → 0.1.0.0

raw patch · 35 files changed

+1406/−0 lines, 35 filesdep +QuickCheckdep +basedep +extra

Dependencies added: QuickCheck, base, extra, mtl, primes, random, real-dice

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for real-dice++## 0.1.0.0 -- 2024-05-16++* First version. Released to an eager world!
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2024 Kyle Beechly++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ README.md view
@@ -0,0 +1,49 @@+# Real\*Dice\*++Random number generation using real dice and other media that I actually touched!++## Introduction++In celebration of Haskell's determinative nature, this package provides random data from my interaction with the physical world as well as utilities to leverage this data for random number generation and other RNG-based tasks++Sometimes the digital world can feel cold and sterile compared to the messy and unpredictable nature of our physical environment. Purely functional languages like Haskell are, for better and for worse, particularly susceptible to this digital de-messification++This package can be used to bring some analog warmth and a human touch to our digital world++## Use++The API of the Coin, Die, and RNG modules more or less match the API of System.Random's `random` and `randomR` functions, but with each function handling a specific type and domain. For example, `flipCoin` returns Boolean values and `roll1d n` returns Integers in the range [1, n]++Running the executable will produce the standard randomized data as defined in the Generate modules (see `app/Generate/` and `src/RealDice/Generate/`). If valid seed data exists in the `data-seed/` directory, this will be randomized with the Real\*Dice\* data to generate custom balanced data in the `data-generated/` directory (Coming Soon!)++## FAQ++### How does Real\*Dice\* work?++Check the source or Hoogle for documentation! (Coming Soon!)++The RNG system itself is a basic randomized table lookup. If it's good enough for [the most perfect software ever written](https://www.youtube.com/watch?v=pq3x1Jy8pYM&t=32s), it's good enough for me!++### What changes are planned?++Check the [issues](https://github.com/kaBeech/real-dice/issues`) and `TODO.md`!++### I encountered a bug or have a cool feature idea!++Please [open an issue](https://github.com/kaBeech/real-dice/issues/new) or [submit a PR](https://github.com/kaBeech/real-dice/compare)!++### Why are there asterisks in "Real\*Dice\*"?++[Ce ne sont pas des dés](https://en.wikipedia.org/wiki/The_Treachery_of_Images)++Data contained in this project was generated with physical dice, but the project itself is not a physical object++Additionally, not all of the gathered data comes from rolling dice. Most of it comes from drawing poker chips, which can be much faster. Methodology for gathering the data is documented in `src/RealDice/Generate/RawData.hs`++### ...but why? On the whole thing?++Because it's cool.++The interaction between the digital world and the physical world fascinates me. Musicians love to talk about warmth and saturation in audio signals - see [Variety Of Sound](https://varietyofsound.wordpress.com/blog/) for some mind-blowing information and audio plugins. This warmth traditionally comes from signal imperfections springing from physical components. This package doesn't scratch the surface of this kind of signal theory, but it's an attempt to use the physical world to influence the digital one++Plus, we all know that observer interaction affects quantum systems, so it seems fun to have some random data touched by a human 😸
+ app/Generate.hs view
@@ -0,0 +1,143 @@+module Generate (balancedTables, pseudoRandomizedInts) where++import RealDice.Convert.BinaryString (boolsToBin)+import RealDice.Generate (rawBoolFull, rawBoolPrime)+import RealDice.Manipulate (randomizeWithCustomBools)+import StdGenRandomize (randomizeList)++-- | Verify that a list of Ints has the same length as a list of Bools before+--   running a function on them.++-- | This is used to make sure that there is an Int in the pseudo-randomized+--   seed list for each Bool in the RealDice raw data.+checkLengths :: ([Int] -> [Bool] -> [Int]) -> [Int] -> [Bool] -> [Int]+checkLengths f l1 l2 = do+  if length l1 == length l2+    then f l1 l2+    else+      error+        ( "Lengths not equal! PseudoRandomized Int List length: "+            ++ show (length l1)+            ++ " Raw Bool List length: "+            ++ show (length l2)+        )++-- | Prime-length list of integers randomized with StdGen, for use as a seed+--   when generating the RealDice balanced data+psRndIntsPrime :: [Int]+psRndIntsPrime =+  randomizeList+    [1 .. length RealDice.Generate.rawBoolPrime]++-- | Full-length list of integers randomized with StdGen, for use as a seed+--   when generating the RealDice balanced data+psRndIntsFull :: [Int]+psRndIntsFull =+  randomizeList+    [1 .. length RealDice.Generate.rawBoolFull]++-- | Prime-length list of integers randomized with the RealDice raw data+rdIntsPrime :: [Int]+rdIntsPrime =+  checkLengths+    randomizeWithCustomBools+    psRndIntsPrime+    rawBoolPrime++-- | Full-length list of integers randomized with the RealDice raw data+rdIntsFull :: [Int]+rdIntsFull =+  checkLengths+    randomizeWithCustomBools+    psRndIntsFull+    rawBoolFull++-- | Prime-length balanced list of Bools randomized with the RealDice raw data+rdBoolsPrime :: [Bool]+rdBoolsPrime = map odd rdIntsPrime++-- | Full-length balanced list of Bools randomized with the RealDice raw data+rdBoolsFull :: [Bool]+rdBoolsFull = map odd rdIntsFull++-- | Prime-length balanced binary string randomized with the RealDice raw data+rdBinPrime :: String+rdBinPrime = boolsToBin rdBoolsPrime++-- | Full-length balanced binary string randomized with the RealDice raw data+rdBinFull :: String+rdBinFull = boolsToBin rdBoolsFull++-- | The balanced tables for the RealDice library+balancedTables :: String+balancedTables =+  "-- | This module contains balanced tables randomized with the RealDice \n\+  \--   raw data\n\+  \module RealDice.Generate.BalancedTables\n\+  \  ( rdBoolsPrime,\n\+  \    rdBoolsFull,\n\+  \    rdIntsPrime,\n\+  \    rdIntsFull,\n\+  \    rdBinPrime,\n\+  \    rdBinFull,\n\+  \  )\n\+  \where\n\+  \\n\+  \-- | Prime-length list of integers randomized with the RealDice raw data\n\+  \rdIntsPrime :: [Int]\n\+  \rdIntsPrime = "+    ++ show rdIntsPrime+    ++ "\n\+       \\n\+       \-- | Full-length list of integers randomized with the RealDice raw data\n\+       \rdIntsFull :: [Int]\n\+       \rdIntsFull = "+    ++ show rdIntsFull+    ++ "\n\+       \\n\+       \-- | Prime-length balanced list of Bools randomized with the RealDice raw data\n\+       \rdBoolsPrime :: [Bool]\n\+       \rdBoolsPrime = "+    ++ show rdBoolsPrime+    ++ "\n\+       \\n\+       \-- | Full-length balanced list of Bools randomized with the RealDice raw data\n\+       \rdBoolsFull :: [Bool]\n\+       \rdBoolsFull = "+    ++ show rdBoolsFull+    ++ "\n\+       \\n\+       \-- | Prime-length balanced binary string randomized with the RealDice raw data\n\+       \rdBinPrime :: String\n\+       \rdBinPrime = "+    ++ show rdBinPrime+    ++ "\n\+       \\n\+       \-- | Full-length balanced binary string randomized with the RealDice raw data\n\+       \rdBinFull :: String\n\+       \rdBinFull = "+    ++ show rdBinFull++-- | Pseudo-randomized integers generated for the RealDice library+pseudoRandomizedInts :: String+pseudoRandomizedInts =+  "-- | This module contains pseudo-randomized integers for use as a seed\n\+  \--   when generating the RealDice balanced data\n\+  \module RealDice.Generate.PseudoRandomizedInts\n\+  \  ( psRndIntsPrime,\n\+  \    psRndIntsFull\n\+  \  )\n\+  \where\n\+  \\n\+  \-- | Prime-length list of integers randomized with StdGen, for use as a seed\n\+  \--   when generating the RealDice balanced data\n\+  \psRndIntsPrime :: [Int]\n\+  \psRndIntsPrime = "+    ++ show psRndIntsPrime+    ++ "\n\+       \\n\+       \-- | Full-length list of integers randomized with StdGen, for use as a seed\n\+       \--   when generating the RealDice balanced data\n\+       \psRndIntsFull :: [Int]\n\+       \psRndIntsFull = "+    ++ show psRndIntsFull
+ app/Main.hs view
@@ -0,0 +1,65 @@+module Main where++import Generate (balancedTables, pseudoRandomizedInts)+import RealDice.Convert.CSV (intsToCSV)+import RealDice.Generate.BalancedTables+  ( rdBinFull,+    rdBinPrime,+    rdIntsFull,+    rdIntsPrime,+  )+import RealDice.Generate.RawData (rawBinFull, rawBinPrime)++-- | Generate all the files needed for the RealDice package++-- |  Data generated for use within the RealDice library is written to the+--   `src/` directory in `.hs` files to avoid having to read the data from+--   files at runtime++-- | One such file is list of integers that are pseudo-randomized with `StdGen`+--   to use as a seed for the balanced data++-- | The other file contains the balanced data tables that are used in the+--   random generation functions++-- | These files are set up to be generated so that I can easily add newly+--   gathered data, process it, make sure that the pseudo-randomized lists are+--   the correct length, and then automatically update all the parts of the+--   library that use this data.++-- | In addition to these files, files with binary and CSV data are generated+--   in the `generate-data/` directory for use outside of the RealDice library++-- | In the future, functionality will be added to check for valid seed files+--   in the `data-seed/` directory. If such data is found it will be randomized+--   with the RealDice data to produce custom data files in the+--   `generate-data/` directory++-- | If you would like to do this yourself now, it can be accomplished by using+--   the `RealDice.Manipulate.Randomize` module to randomize the seed data and+--   then use thing `RealDice.Convert.CSV` module to convert the randomized+--   data to CSV format to write to a file+main :: IO ()+main = do+  putStrLn "Generating src files..."+  putStrLn "Generating pseudoRandomized integers:"+  writeFile+    "src/RealDice/Generate/PseudoRandomizedInts.hs"+    pseudoRandomizedInts+  putStrLn "Generating standard RNG tables:"+  writeFile "src/RealDice/Generate/BalancedTables.hs" balancedTables+  putStrLn "Generating data files..."+  putStrLn "Generating raw binary data:"+  writeFile "data-generated/real_dice_raw_prime.bin" rawBinPrime+  writeFile "data-generated/real_dice_raw_full.bin" rawBinFull+  putStrLn "Generating balanced binary data:"+  writeFile "data-generated/real_dice_balanced_prime.bin" rdBinPrime+  writeFile "data-generated/real_dice_balanced_full.bin" rdBinFull+  putStrLn "Generating balanced integer data:"+  writeFile+    "data-generated/real_dice_balanced_integers_prime.csv"+    (intsToCSV rdIntsPrime)+  writeFile+    "data-generated/real_dice_balanced_integers_full.csv"+    (intsToCSV rdIntsFull)+  putStrLn "Files generated successfully!"
+ app/StdGenRandomize.hs view
@@ -0,0 +1,33 @@+module StdGenRandomize (randomizeList) where++import Control.Monad.State+import System.Random (StdGen, mkStdGen, randomR)++data RandomState where+  RandomState :: {generator :: StdGen} -> RandomState++-- | Use StdGen to randomize the order of a list of integers++-- | This is used to generate balanced seed data to be randomized with the+--   RealDice raw data++-- | I feel comfortable use StdGen to generate the files, as long as it's not+--   used in the library itself++-- | ==== __Examples__+--   >>> randomizeList [1, 2, 3, 4, 5]+--   [3, 1, 5, 2, 4]+randomizeList :: [Int] -> [Int]+randomizeList xs =+  evalState+    (randomizeListSinglePass xs [])+    (RandomState (mkStdGen 143))++randomizeListSinglePass :: [Int] -> [Int] -> State RandomState [Int]+randomizeListSinglePass [] l' = return l'+randomizeListSinglePass l l' = do+  randomSt <- get+  let (randomIndex, gen') = randomR (0, length l - 1) (generator randomSt)+  let x = l !! randomIndex+  put RandomState {generator = gen'}+  randomizeListSinglePass (filter (/= x) l) (x : l')
+ data-generated/real_dice_balanced_full.bin view
@@ -0,0 +1,1 @@+011011001100010100101001000110101011110000001000111100101101111101000011010000101010110010010011111001010111110000101000111110011011010000001001010010001001111001001111000110010100001001011001111001111001011110010011000100111000101001010111000010001010010011010000101011000110111101111101111101000101000010111000110000110011000011101000111111110101110010011011111011111111111100110011000110011010011000100100010010000101111001010101010111101111111010011100001100101101010000110001010110110011111000001001010010100010100001100100011111000100110010111110001101101100001011100100011001011110001011100111101011101010001001010010100011000111000001111011100110010110001001010001111100111111011011011100111010011101011111100101011011111010001010010010010000100111000000011111010000011010011111001011011110010001001111110110110010100100000000111100010011011010101010000100111110111011000100110010101111011111110010001111000110001100111011000010001010010010001000010001011010011110100100011110110100100010011101110001101011100110010000110111001100000001100101010
+ data-generated/real_dice_balanced_integers_full.csv view
@@ -0,0 +1,1 @@+732,1005,501,178,479,15,464,58,683,723,454,148,100,359,564,551,544,1040,669,306,1021,594,876,611,872,30,980,385,747,868,189,140,505,540,639,73,531,101,902,940,128,632,914,342,295,174,230,446,1047,633,489,471,90,54,431,536,925,909,162,863,885,77,1015,1049,820,921,366,588,742,778,201,297,60,449,250,474,686,262,123,20,767,298,281,50,335,427,784,526,389,12,758,465,994,648,1017,91,291,913,959,642,982,493,782,753,908,605,1053,555,23,565,428,554,754,966,183,692,5,606,668,172,677,661,349,607,1029,556,576,535,755,124,749,231,118,989,1026,460,894,432,528,348,163,456,834,981,242,223,418,212,185,578,332,154,999,404,638,973,47,243,445,62,836,805,322,630,771,97,1039,255,880,400,938,371,899,86,680,475,72,713,126,182,584,888,839,600,296,645,388,507,499,52,590,307,845,893,855,866,494,211,273,895,757,180,420,195,38,393,745,597,317,780,816,443,204,970,229,137,814,458,582,485,690,726,537,937,87,910,132,164,59,984,627,36,818,949,352,377,252,589,1009,33,254,552,878,796,793,932,476,572,53,558,919,952,896,543,166,114,549,817,546,287,484,220,16,1036,487,402,595,706,81,933,562,496,1028,751,873,280,127,337,583,99,88,419,7,659,175,351,738,313,21,143,807,769,312,353,1008,524,760,955,848,343,806,946,256,514,9,614,145,775,115,288,826,856,693,277,906,74,664,184,403,347,744,790,129,841,152,842,436,882,361,247,43,624,157,944,270,598,197,871,539,883,631,993,357,835,1044,131,710,911,637,927,884,398,777,210,616,563,1043,890,173,253,285,729,625,1022,235,517,833,45,679,1011,951,239,763,467,623,859,236,976,573,907,4,444,171,917,330,996,626,69,681,188,874,725,711,628,13,6,176,381,301,66,920,316,587,376,502,1051,356,258,728,491,530,696,931,26,750,96,350,339,622,527,1023,695,27,646,32,401,714,187,822,391,550,785,42,553,830,991,953,461,663,580,1035,331,227,1033,559,233,985,746,363,336,596,533,987,521,712,486,472,248,105,581,698,490,215,1006,853,699,1018,915,272,811,146,756,892,44,651,727,8,226,406,877,762,843,900,823,827,426,813,741,612,534,869,969,261,37,441,208,860,116,838,408,979,926,794,293,214,263,364,1014,333,998,71,260,832,346,1,954,879,372,326,672,302,217,165,586,412,119,912,434,206,717,259,423,161,797,228,70,28,269,360,370,675,599,338,24,945,488,847,11,481,245,39,308,828,734,819,249,846,697,375,112,191,629,724,700,650,510,765,684,311,731,153,190,862,821,22,320,1046,963,279,442,186,103,78,829,851,971,1001,380,516,144,225,84,17,781,901,548,82,557,179,429,703,640,503,644,355,721,613,1002,673,202,271,478,566,1024,831,916,918,593,1042,399,974,770,309,988,207,482,304,666,3,315,662,394,1034,887,939,61,592,522,56,382,282,983,177,433,701,736,341,303,383,438,656,497,707,328,608,935,354,881,29,424,716,964,875,962,634,671,768,515,978,786,104,825,647,435,455,169,234,560,773,619,733,547,415,511,660,943,329,314,387,283,1032,643,319,739,68,610,585,459,147,1012,267,238,334,657,609,237,512,1031,718,579,151,709,783,473,635,852,968,111,170,569,854,483,193,840,591,975,571,803,615,936,451,158,574,798,509,958,705,704,120,759,956,508,181,772,720,275,972,106,950,1000,715,702,774,95,19,373,286,160,730,1030,142,284,448,977,665,289,653,965,670,529,688,658,764,300,246,55,801,722,367,452,102,89,1013,687,395,49,392,824,203,948,837,405,200,903,849,655,135,924,570,67,136,682,462,743,990,812,109,379,345,417,265,799,410,25,369,450,1027,409,1016,358,141,374,735,804,898,51,94,602,384,46,864,930,604,340,649,541,155,789,2,224,802,779,292,266,469,305,934,719,107,960,1037,244,905,344,447,324,257,538,654,14,240,791,504,386,1025,413,149,601,1041,480,545,221,125,362,523,31,194,922,198,957,218,858,327,251,416,422,41,130,961,676,603,439,815,621,800,219,199,57,75,117,241,411,568,708,63,904,264,232,121,325,897,967,276,134,808,321,205,222,506,138,83,857,216,992,457,453,761,752,787,617,122,766,694,792,477,156,492,844,689,850,923,40,788,1003,290,532,79,64,196,740,941,810,18,390,92,323,500,1020,430,691,108,437,929,620,213,34,1052,133,685,425,139,886,525,652,76,513,414,268,150,561,865,159,209,674,463,365,110,407,278,468,577,168,274,396,861,748,310,891,93,997,440,947,995,65,986,1010,1048,1045,889,928,495,520,85,113,867,1038,378,1007,397,470,318,421,10,518,542,98,1019,575,498,519,667,299,368,294,167,567,776,870,1050,618,192,466,80,35,737,1004,48,809,636,641,678,795,942
+ data-generated/real_dice_balanced_integers_prime.csv view
@@ -0,0 +1,1 @@+1005,942,501,178,15,464,678,683,723,636,454,809,359,737,466,1050,1040,167,294,306,594,368,876,611,30,299,575,1019,747,868,189,140,505,542,73,531,421,101,940,318,128,632,914,342,295,174,230,446,1047,633,489,397,1007,431,536,1038,909,162,113,863,885,1015,85,1049,820,366,520,588,778,201,889,1045,449,1048,474,1010,262,123,65,995,947,298,50,440,335,427,997,389,12,396,168,577,468,278,1017,91,291,913,959,407,110,493,365,908,674,209,159,865,150,268,554,754,966,513,692,5,606,668,76,886,139,425,685,133,576,535,755,124,749,231,118,989,1026,460,894,432,528,348,163,456,834,981,242,223,418,212,185,578,332,154,999,404,638,973,47,243,445,62,836,805,322,630,771,97,1039,255,880,400,938,371,899,86,680,475,72,713,126,182,584,888,839,600,296,645,388,507,499,52,590,307,845,893,855,866,494,211,273,895,757,180,420,195,38,393,745,597,317,780,816,443,204,970,229,137,814,458,582,485,690,726,537,937,87,910,132,164,59,984,627,36,818,949,352,377,252,589,1009,33,254,552,878,796,793,932,476,572,53,558,919,952,896,543,166,114,549,817,546,287,484,220,16,1036,487,402,595,706,81,933,562,496,1028,751,873,280,127,337,583,99,88,419,7,659,175,351,738,313,21,143,807,769,312,353,1008,524,760,955,848,343,806,946,256,514,9,614,145,775,115,288,826,856,693,277,906,74,664,184,403,347,744,790,129,841,152,842,436,882,361,247,43,624,157,944,270,598,197,871,539,883,631,993,357,835,1044,131,710,911,637,927,884,398,777,210,616,563,1043,890,173,253,285,729,625,1022,235,517,833,45,679,1011,951,239,763,467,623,859,236,976,573,907,4,444,171,917,330,996,626,69,681,188,874,725,711,628,13,6,176,381,301,66,920,316,587,376,502,1051,356,258,728,491,530,696,931,26,750,96,350,339,622,527,1023,695,27,646,32,401,714,187,822,391,550,785,42,553,830,991,953,461,663,580,1035,331,227,1033,559,233,985,746,363,336,596,533,987,521,712,486,472,248,105,581,698,490,215,1006,853,699,1018,915,272,811,146,756,892,44,651,727,8,226,406,877,762,843,900,823,827,426,813,741,612,534,869,969,261,37,441,208,860,116,838,408,979,926,794,293,214,263,364,1014,333,998,71,260,832,346,1,954,879,372,326,672,302,217,165,586,412,119,912,434,206,717,259,423,161,797,228,70,28,269,360,370,675,599,338,24,945,488,847,11,481,245,39,308,828,734,819,249,846,697,375,112,191,629,724,700,650,510,765,684,311,731,153,190,862,821,22,320,1046,963,279,442,186,103,78,829,851,971,1001,380,516,144,225,84,17,781,901,548,82,557,179,429,703,640,503,644,355,721,613,1002,673,202,271,478,566,1024,831,916,918,593,1042,399,974,770,309,988,207,482,304,666,3,315,662,394,1034,887,939,61,592,522,56,382,282,983,177,433,701,736,341,303,383,438,656,497,707,328,608,935,354,881,29,424,716,964,875,962,634,671,768,515,978,786,104,825,647,435,455,169,234,560,773,619,733,547,415,511,660,943,329,314,387,283,1032,643,319,739,68,610,585,459,147,1012,267,238,334,657,609,237,512,1031,718,579,151,709,783,473,635,852,968,111,170,569,854,483,193,840,591,975,571,803,615,936,451,158,574,798,509,958,705,704,120,759,956,508,181,772,720,275,972,106,950,1000,715,702,774,95,19,373,286,160,730,1030,142,284,448,977,665,289,653,965,670,529,688,658,764,300,246,55,801,722,367,452,102,89,1013,687,395,49,392,824,203,948,837,405,200,903,849,655,135,924,570,67,136,682,462,743,990,812,109,379,345,417,265,799,410,25,369,450,1027,409,1016,358,141,374,735,804,898,51,94,602,384,46,864,930,604,340,649,541,155,789,2,224,802,779,292,266,469,305,934,719,107,960,1037,244,905,344,447,324,257,538,654,14,240,791,504,386,1025,413,149,601,1041,480,545,221,125,362,523,31,194,922,198,957,218,858,327,251,416,422,41,130,961,676,603,439,815,621,800,219,199,57,75,117,241,411,568,708,63,904,264,232,121,325,897,967,276,134,808,321,205,222,506,138,83,857,216,992,457,453,761,752,787,617,122,766,694,792,477,156,492,844,689,850,923,40,788,1003,290,532,79,64,196,740,941,810,18,390,92,323,500,1020,430,691,108,437,929,620,213,34,556,1029,607,349,661,525,652,677,172,414,183,428,561,565,23,555,605,463,753,782,982,642,648,994,465,274,861,748,758,310,891,93,526,784,281,767,20,986,686,250,60,297,928,495,742,921,77,867,925,378,54,470,90,471,902,10,518,98,639,540,498,519,667,385,980,872,1021,567,669,776,870,618,544,192,80,551,35,564,1004,48,100,148,641,58,795,479,732
+ data-generated/real_dice_balanced_prime.bin view
@@ -0,0 +1,1 @@+1010100110011100010000010111101010111100000010001111110010111111000001111000011110001111000100111111011001110000010100001111011011010000001001010010001001111001001111000110010100001001011001111001111001011110010011000100111000101001010111000010001010010011010000101011000110111101111101111101000101000010111000110000110011000011101000111111110101110010011011111011111111111100110011000110011010011000100100010010000101111001010101010111101111111010011100001100101101010000110001010110110011111000001001010010100010100001100100011111000100110010111110001101101100001011100100011001011110001011100111101011101010001001010010100011000111000001111011100110010110001001010001111100111111011011011100111010011101011111100101011011111010001010010010010000100111000000011111010000011010011111001011011110010001001111110110110010100100000000111100010011011010101010000100111110111011000100110010101111011111110010001111000110001100111011000010001010010010001000010001011010011111010010111111100000101000110011000001010111100001000010011100111000000110000010110
+ data-generated/real_dice_raw_full.bin view
@@ -0,0 +1,1 @@+110001000001111111110101011101011100000011000011111111011000010111001101011011111101001101001101111001011010110110100010000010011001110100110000000101101001110100110101100101100011100101111011001100111100000000010001011100110110000000011001101100001011000010101111100000010101100111111010101110111111101010111011011011100101110100111010011110010110100010100110011111101101010000001000100100011110010010101001111010110011110011010011000011110110011011011101101111111010010110010101101111100110011110011011000011110111101101101111101110010011101000000001101101111011010111111010111100010110000001100000001001011010110111110000010011010001110010001101011010111011111010111111000101110000101111011001100111010100001110100111100001001010101100001011011001100100011111011010101110100111000000111111100001100101011101100000110100001110011010000101010101010100010111110011110100101010110100111001111111001100100001010100111101110011010110110110010101110111101111010110101100011111111111110111010100011111110000011011110111000101000100010010100111010110101111011
+ data-generated/real_dice_raw_prime.bin view
@@ -0,0 +1,1 @@+1100010000011111111101010111010111000000110000111111110110000101110011010110111111010011010011011110010110101101101000100000100110011101001100000001011010011101001101011001011000111001011110110011001111000000000100010111001101100000000110011011000010110000101011111000000101011001111110101011101111111010101110110110111001011101001110100111100101101000101001100111111011010100000010001001000111100100101010011110101100111100110100110000111101100110110111011011111110100101100101011011111001100111100110110000111101111011011011111011100100111010000000011011011110110101111110101111000101100000011000000010010110101101111100000100110100011100100011010110101110111110101111110001011100001011110110011001110101000011101001111000010010101011000010110110011001000111110110101011101001110000001111111000011001010111011000001101000011100110100001010101010101000101111100111101001010101101001110011111110011001000010101001111011100110101101101100101011101111011110101101011000111111111111101110101000111111100000110111101110001010001000100101001110101101011110
+ real-dice.cabal view
@@ -0,0 +1,175 @@+cabal-version:      3.4+-- The cabal-version field refers to the version of the .cabal specification,+-- and can be different from the cabal-install (the tool) version and the+-- Cabal (the library) version you are using. As such, the Cabal (the library)+-- version used must be equal or greater than the version stated in this field.+-- Starting from the specification version 2.2, the cabal-version field must be+-- the first thing in the cabal file.++-- Initial package description 'real-dice' generated by+-- 'cabal init'. For further documentation, see:+--   http://haskell.org/cabal/users-guide/+--+-- The name of the package.+name:               real-dice++-- The package version.+-- See the Haskell package versioning policy (PVP) for standards+-- guiding when and how versions should be incremented.+-- https://pvp.haskell.org+-- PVP summary:     +-+------- breaking API changes+--                  | | +----- non-breaking API additions+--                  | | | +--- code changes with no API change+version:            0.1.0.0++-- A short (one-line) description of the package.+synopsis:+    Random number generation based on physical media touched by humans+++-- A longer description of the package.+description:+    This package provides random data gathered via human interaction with the physical world as well as utilities to leverage this data for random number generation and other RNG-based tasks+-- URL for the project homepage or repository.+homepage:           https://github.com/kaBeech/real-dice++-- The license under which the package is released.+license:            MIT++-- The file containing the license text.+license-file:       LICENSE++-- The package author(s).+author:             Kyle Beechly++-- An email address to which users can send suggestions, bug reports, and patches.+maintainer:         contact@kaBeech.com++-- A copyright notice.+copyright:          2024 Kyle Beechly+category:           Math,+                    Data+build-type:         Simple++-- Extra doc files to be distributed with the package, such as a CHANGELOG or a README.+extra-doc-files:    README.md,+                    CHANGELOG.md++-- Extra source files to be distributed with the package, such as examples, or a tutorial module.+extra-source-files: data-generated/*.bin,+                    data-generated/*.csv++source-repository head+    type:           git+    location:       https://github.com/kaBeech/real-dice++common warnings+    ghc-options: -Wall++library+    -- Import common warning flags.+    import:           warnings++    -- Modules exported by the library.+    exposed-modules:  RealDice,+                      RealDice.RNG,+                      RealDice.Die,+                      RealDice.Coin,+                      RealDice.Generate,+                      RealDice.Generate.RawData,+                      RealDice.Generate.PseudoRandomizedInts,+                      RealDice.Generate.BalancedTables,+                      RealDice.Convert,+                      RealDice.Convert.BinaryString,+                      RealDice.Convert.CSV,+                      RealDice.Manipulate,+                      RealDice.Manipulate.GetValueFromRNGTable,+                      RealDice.Manipulate.RandomizeList,+                      RealDice.Util,+                      RealDice.Util.Prime+ ++    -- Modules included in this library but not exported.+    -- other-modules:++    -- LANGUAGE extensions used by modules in this package.+    -- other-extensions:++    -- Other library packages from which modules are imported.+    build-depends:    base ^>=4.18.2.0,+                      mtl >= 2.3.1 && < 2.4,+                      primes >= 0.2.1 && < 0.3++    -- Directories containing source files.+    hs-source-dirs:   src++    -- Base language which the package is written in.+    default-language: GHC2021++executable real-dice+    -- Import common warning flags.+    import:           warnings++    -- .hs or .lhs file containing the Main module.+    main-is:          Main.hs++    -- Modules included in this executable, other than Main.+    other-modules:    Generate,+                      StdGenRandomize++    -- LANGUAGE extensions used by modules in this package.+    -- other-extensions:++    -- Other library packages from which modules are imported.+    build-depends:+        base,+        mtl,+        random >= 1.2.1 && < 1.3,+        real-dice++    -- Directories containing source files.+    hs-source-dirs:   app++    -- Base language which the package is written in.+    default-language: GHC2021++test-suite real-dice-test+    -- Import common warning flags.+    import:           warnings++    -- Base language which the package is written in.+    default-language: GHC2021++    -- Modules included in this executable, other than Main.+    other-modules:    TestCheck,+                      RealDice.DieSpec,+                      RealDice.CoinSpec,+                      RealDice.RNGSpec,+                      -- RealDice.Generate.RawDataSpec,+                      -- RealDice.Generate.PseudoRandomizedIntsSpec,+                      -- RealDice.Generate.StandardRNGTablesSpec,+                      -- RealDice.Convert.BinaryStringSpec,+                      -- RealDice.Manipulate.GetValueFromRNGTableSpec,+                      -- RealDice.Manipulate.RandomizeListSpec,+                      RealDice.Util.PrimeSpec++    -- LANGUAGE extensions used by modules in this package.+    -- other-extensions:++    -- The interface type and version of the test suite.+    type:             exitcode-stdio-1.0++    -- Directories containing source files.+    hs-source-dirs:   test++    -- The entrypoint to the test suite.+    main-is:          Main.hs++    -- Test dependencies.+    build-depends:+        base,+        real-dice,+        primes,+        mtl,+        extra >= 1.7.15 && < 1.8,+        QuickCheck >= 2.15 && < 2.16
+ src/RealDice.hs view
@@ -0,0 +1,15 @@+-- | Core RealDice module. Excludes the Convert and Util modules+module RealDice+  ( module RealDice.Coin,+    module RealDice.Die,+    module RealDice.RNG,+    module RealDice.Generate,+    module RealDice.Manipulate,+  )+where++import RealDice.Coin+import RealDice.Die+import RealDice.Generate+import RealDice.Manipulate+import RealDice.RNG
+ src/RealDice/Coin.hs view
@@ -0,0 +1,45 @@+-- | This module exports the CoinGen data type and functions for flipping Coins+--   to generate random boolean values via balanced tables randomized by the+--   RealDice data or custom boolean tables+module RealDice.Coin (CoinGen, flipCoin, mkCoinGen, mkCoinGenCustom) where++import RealDice.Generate.BalancedTables (rdBoolsPrime)+import RealDice.Manipulate.GetValueFromRNGTable (getBoolByIndex)++-- | Stores a balanced table of random boolean values and an index pointing to+--   the next value to return+data CoinGen where+  CoinGen :: {index :: Int, boolTable :: [Bool]} -> CoinGen++-- | Creates a new CoinGen with the given index and the default bool table++-- | ==== __Examples__+--  >>> mkCoinGen 143+--  {143, rdBoolsPrime}+mkCoinGen :: Int -> CoinGen+mkCoinGen i = mkCoinGenCustom i rdBoolsPrime++-- | Creates a new CoinGen with the given index and bool table++-- | Defaults to the RealDice balanced table of random booleans if an empty+--   list is given++-- | ==== __Examples__+--   >>> mkCoinGenCustom 143 [True, False, False, True, True]+--   {143, [True, False, False, True, True]}+--   >>> mkCoinGenCustom 143 []+--   {143, rdBoolsPrime}+mkCoinGenCustom :: Int -> [Bool] -> CoinGen+mkCoinGenCustom i [] = CoinGen {index = i, boolTable = rdBoolsPrime}+mkCoinGenCustom i table = CoinGen {index = i, boolTable = table}++-- | Generates a random boolean value via a simple table lookup++-- | ==== __Examples__+--   >>> flipCoin (mkDieGen 143)+--   (False, {144, rdBoolsPrime})+flipCoin :: CoinGen -> (Bool, CoinGen)+flipCoin coin =+  ( getBoolByIndex (index coin) (boolTable coin),+    CoinGen {index = index coin + 1, boolTable = boolTable coin}+  )
+ src/RealDice/Convert.hs view
@@ -0,0 +1,11 @@+-- | This module re-exports all the conversion submodules.+--   At time of writing, this includes converting to and from binary strings+--   and strings suitable for CSV files+module RealDice.Convert+  ( module RealDice.Convert.BinaryString,+    module RealDice.Convert.CSV,+  )+where++import RealDice.Convert.BinaryString+import RealDice.Convert.CSV
+ src/RealDice/Convert/BinaryString.hs view
@@ -0,0 +1,79 @@+-- | Module for converting between boolean values and strings containing '0's+-- | and '1's+module RealDice.Convert.BinaryString+  ( boolToBin,+    boolsToBin,+    binToBool,+    binToBools,+    stringToBools,+  )+where++-- | Converts a Bool to a '1' or '0'++-- | ==== __Examples__+--  >>> boolToBin True+--  '1'+--  >>> boolToBin False+--  '0'+boolToBin :: Bool -> Char+boolToBin False = '0'+boolToBin True = '1'++-- | Converts a list of Bools to a binary string++-- | ==== __Examples__+-- >>> boolsToBin [True, False, True, True]+-- "1011"+boolsToBin :: [Bool] -> String+boolsToBin = map boolToBin++-- | Converts a binary character to a Bool++-- | ==== __Examples__+-- >>> binToBool '0'+-- False+-- >>> binToBool '1'+-- True+-- >>> binToBool '2'+-- *** Exception: Invalid binary character: '2' (valid binary characters are '0' and '1')+binToBool :: Char -> Bool+binToBool '0' = False+binToBool '1' = True+binToBool x =+  error+    ( "Invalid binary character: '"+        ++ [x]+        ++ "' (valid binary characters are '0' and '1')"+    )++-- | Converts a binary string to a list of Bools++-- | ==== __Examples__+-- >>> binToBools "1011"+-- [True, False, True, True]+-- >>> binToBools "1012"+-- *** Exception: Invalid binary character: '2' (valid binary characters are '0' and '1')+binToBools :: String -> [Bool]+binToBools = map binToBool++-- | Converts a string containing '0's and '1's to a list of Bools, ignoring+--   any characters that are not '0' or '1'++-- | ==== __Examples__+-- >>> stringToBools "1011"+-- [True, False, True, True]+-- >>> stringToBools "1012"+-- [True, False, True]+-- >>> stringToBools "Hello, Haskell!"+-- []+-- >>> stringToBools "On the 10th of March, 1901, Hacksell Kerry placed 21st\n\ \ in the 100m dash, with a time of 12.3 seconds, wearing the number 101"+-- [True, False, True, False, True, True, True, False, False, True, True, False, True]+stringToBools :: String -> [Bool]+stringToBools = acc []+  where+    acc :: [Bool] -> String -> [Bool]+    acc boolList [] = boolList+    acc boolList ('0' : xs) = acc (False : boolList) xs+    acc boolList ('1' : xs) = acc (True : boolList) xs+    acc boolList (_ : xs) = acc boolList xs
+ src/RealDice/Convert/CSV.hs view
@@ -0,0 +1,25 @@+-- | This module provides functions to convert between lists of integers and+--   strings suitable for use in CSV files+module RealDice.Convert.CSV+  ( intsToCSV,+    csvToInts,+  )+where++-- | Remove the square brackets `[]` from the string representation of a list+--   so it can be used as a CSV string++-- | ==== __Examples__+--   >>> intsToCSV [1,2,3]+--   "1,2,3"+intsToCSV :: [Int] -> String+intsToCSV xs = tail (take (length (show xs) - 1) (show xs))++-- | Add square brackets `[]` to a CSV string of integers and make it into+--   a list++-- | ==== __Examples__+--   >>> csvToInts "1,2,3"+--   [1,2,3]+csvToInts :: String -> [Int]+csvToInts xs = read ("[" ++ xs ++ "]")
+ src/RealDice/Die.hs view
@@ -0,0 +1,59 @@+-- | This module provides the DieGen data type and functions for using Dice to+--   generate random positive integers via balanced tables randomized by the+--   RealDice data or custom integer tables+module RealDice.Die (DieGen, roll1d, mkDieGen, mkDieGenCustom) where++import RealDice.Generate.BalancedTables (rdIntsPrime)+import RealDice.Manipulate.GetValueFromRNGTable (getIntByIndex)+import RealDice.Manipulate.RandomizeList (randomizeList)++-- | Stores a balanced table of random integers and an index pointing at the+--   next value to return+data DieGen where+  DieGen :: {index :: Int, intTable :: [Int]} -> DieGen++-- | Creates a new DieGen with the given index and the default Int table++-- | ==== __Examples__+--   >>> mkDieGen 143+--   {143, rdIntsPrime}+mkDieGen :: Int -> DieGen+mkDieGen i = mkDieGenCustom i rdIntsPrime++-- | Creates a new DieGen with the given index and Int table++-- | Defaults to the RealDice balanced table of random integers if an empty+--   list is given++-- | ==== __Examples__+--   >>> mkDieGenCustom 143 [1, 0, 4, 3, 2]+--   {143, [1, 0, 4, 3, 2]}+--   >>> mkDieGenCustom 143 []+--   {143, rdIntsPrime}+mkDieGenCustom :: Int -> [Int] -> DieGen+mkDieGenCustom i [] = DieGen {index = i, intTable = rdIntsPrime}+mkDieGenCustom i table = DieGen {index = i, intTable = table}++-- | Generates a random integer value between 1 and n via a simple table lookup++-- | ==== __Examples__+--   >>> roll1d 20 (mkDieGen 143)+--   (12, {144, rdIntsPrime})+roll1d ::+  -- | The number of sides on the die+  Int ->+  -- | The DieGen to use+  DieGen ->+  --  | The updated index+  ( Int,+    --  | The updated DieGen+    DieGen+  )+roll1d n die+  | n < 1 = (0, die)+  | otherwise =+      ( getIntByIndex+          (getIntByIndex (index die) (intTable die))+          (randomizeList [1 .. n]),+        DieGen {index = index die + 1, intTable = intTable die}+      )
+ src/RealDice/Generate.hs view
@@ -0,0 +1,12 @@+-- | This module re-exports all the modules that are needed to generate the+--   data used for random generation in other modules+module RealDice.Generate+  ( module RealDice.Generate.PseudoRandomizedInts,+    module RealDice.Generate.RawData,+    module RealDice.Generate.BalancedTables,+  )+where++import RealDice.Generate.BalancedTables+import RealDice.Generate.PseudoRandomizedInts+import RealDice.Generate.RawData
+ src/RealDice/Generate/BalancedTables.hs view
@@ -0,0 +1,35 @@+-- | This module contains balanced tables randomized with the RealDice +--   raw data+module RealDice.Generate.BalancedTables+  ( rdBoolsPrime,+    rdBoolsFull,+    rdIntsPrime,+    rdIntsFull,+    rdBinPrime,+    rdBinFull,+  )+where++-- | Prime-length list of integers randomized with the RealDice raw data+rdIntsPrime :: [Int]+rdIntsPrime = [1005,942,501,178,15,464,678,683,723,636,454,809,359,737,466,1050,1040,167,294,306,594,368,876,611,30,299,575,1019,747,868,189,140,505,542,73,531,421,101,940,318,128,632,914,342,295,174,230,446,1047,633,489,397,1007,431,536,1038,909,162,113,863,885,1015,85,1049,820,366,520,588,778,201,889,1045,449,1048,474,1010,262,123,65,995,947,298,50,440,335,427,997,389,12,396,168,577,468,278,1017,91,291,913,959,407,110,493,365,908,674,209,159,865,150,268,554,754,966,513,692,5,606,668,76,886,139,425,685,133,576,535,755,124,749,231,118,989,1026,460,894,432,528,348,163,456,834,981,242,223,418,212,185,578,332,154,999,404,638,973,47,243,445,62,836,805,322,630,771,97,1039,255,880,400,938,371,899,86,680,475,72,713,126,182,584,888,839,600,296,645,388,507,499,52,590,307,845,893,855,866,494,211,273,895,757,180,420,195,38,393,745,597,317,780,816,443,204,970,229,137,814,458,582,485,690,726,537,937,87,910,132,164,59,984,627,36,818,949,352,377,252,589,1009,33,254,552,878,796,793,932,476,572,53,558,919,952,896,543,166,114,549,817,546,287,484,220,16,1036,487,402,595,706,81,933,562,496,1028,751,873,280,127,337,583,99,88,419,7,659,175,351,738,313,21,143,807,769,312,353,1008,524,760,955,848,343,806,946,256,514,9,614,145,775,115,288,826,856,693,277,906,74,664,184,403,347,744,790,129,841,152,842,436,882,361,247,43,624,157,944,270,598,197,871,539,883,631,993,357,835,1044,131,710,911,637,927,884,398,777,210,616,563,1043,890,173,253,285,729,625,1022,235,517,833,45,679,1011,951,239,763,467,623,859,236,976,573,907,4,444,171,917,330,996,626,69,681,188,874,725,711,628,13,6,176,381,301,66,920,316,587,376,502,1051,356,258,728,491,530,696,931,26,750,96,350,339,622,527,1023,695,27,646,32,401,714,187,822,391,550,785,42,553,830,991,953,461,663,580,1035,331,227,1033,559,233,985,746,363,336,596,533,987,521,712,486,472,248,105,581,698,490,215,1006,853,699,1018,915,272,811,146,756,892,44,651,727,8,226,406,877,762,843,900,823,827,426,813,741,612,534,869,969,261,37,441,208,860,116,838,408,979,926,794,293,214,263,364,1014,333,998,71,260,832,346,1,954,879,372,326,672,302,217,165,586,412,119,912,434,206,717,259,423,161,797,228,70,28,269,360,370,675,599,338,24,945,488,847,11,481,245,39,308,828,734,819,249,846,697,375,112,191,629,724,700,650,510,765,684,311,731,153,190,862,821,22,320,1046,963,279,442,186,103,78,829,851,971,1001,380,516,144,225,84,17,781,901,548,82,557,179,429,703,640,503,644,355,721,613,1002,673,202,271,478,566,1024,831,916,918,593,1042,399,974,770,309,988,207,482,304,666,3,315,662,394,1034,887,939,61,592,522,56,382,282,983,177,433,701,736,341,303,383,438,656,497,707,328,608,935,354,881,29,424,716,964,875,962,634,671,768,515,978,786,104,825,647,435,455,169,234,560,773,619,733,547,415,511,660,943,329,314,387,283,1032,643,319,739,68,610,585,459,147,1012,267,238,334,657,609,237,512,1031,718,579,151,709,783,473,635,852,968,111,170,569,854,483,193,840,591,975,571,803,615,936,451,158,574,798,509,958,705,704,120,759,956,508,181,772,720,275,972,106,950,1000,715,702,774,95,19,373,286,160,730,1030,142,284,448,977,665,289,653,965,670,529,688,658,764,300,246,55,801,722,367,452,102,89,1013,687,395,49,392,824,203,948,837,405,200,903,849,655,135,924,570,67,136,682,462,743,990,812,109,379,345,417,265,799,410,25,369,450,1027,409,1016,358,141,374,735,804,898,51,94,602,384,46,864,930,604,340,649,541,155,789,2,224,802,779,292,266,469,305,934,719,107,960,1037,244,905,344,447,324,257,538,654,14,240,791,504,386,1025,413,149,601,1041,480,545,221,125,362,523,31,194,922,198,957,218,858,327,251,416,422,41,130,961,676,603,439,815,621,800,219,199,57,75,117,241,411,568,708,63,904,264,232,121,325,897,967,276,134,808,321,205,222,506,138,83,857,216,992,457,453,761,752,787,617,122,766,694,792,477,156,492,844,689,850,923,40,788,1003,290,532,79,64,196,740,941,810,18,390,92,323,500,1020,430,691,108,437,929,620,213,34,556,1029,607,349,661,525,652,677,172,414,183,428,561,565,23,555,605,463,753,782,982,642,648,994,465,274,861,748,758,310,891,93,526,784,281,767,20,986,686,250,60,297,928,495,742,921,77,867,925,378,54,470,90,471,902,10,518,98,639,540,498,519,667,385,980,872,1021,567,669,776,870,618,544,192,80,551,35,564,1004,48,100,148,641,58,795,479,732]++-- | Full-length list of integers randomized with the RealDice raw data+rdIntsFull :: [Int]+rdIntsFull = [732,1005,501,178,479,15,464,58,683,723,454,148,100,359,564,551,544,1040,669,306,1021,594,876,611,872,30,980,385,747,868,189,140,505,540,639,73,531,101,902,940,128,632,914,342,295,174,230,446,1047,633,489,471,90,54,431,536,925,909,162,863,885,77,1015,1049,820,921,366,588,742,778,201,297,60,449,250,474,686,262,123,20,767,298,281,50,335,427,784,526,389,12,758,465,994,648,1017,91,291,913,959,642,982,493,782,753,908,605,1053,555,23,565,428,554,754,966,183,692,5,606,668,172,677,661,349,607,1029,556,576,535,755,124,749,231,118,989,1026,460,894,432,528,348,163,456,834,981,242,223,418,212,185,578,332,154,999,404,638,973,47,243,445,62,836,805,322,630,771,97,1039,255,880,400,938,371,899,86,680,475,72,713,126,182,584,888,839,600,296,645,388,507,499,52,590,307,845,893,855,866,494,211,273,895,757,180,420,195,38,393,745,597,317,780,816,443,204,970,229,137,814,458,582,485,690,726,537,937,87,910,132,164,59,984,627,36,818,949,352,377,252,589,1009,33,254,552,878,796,793,932,476,572,53,558,919,952,896,543,166,114,549,817,546,287,484,220,16,1036,487,402,595,706,81,933,562,496,1028,751,873,280,127,337,583,99,88,419,7,659,175,351,738,313,21,143,807,769,312,353,1008,524,760,955,848,343,806,946,256,514,9,614,145,775,115,288,826,856,693,277,906,74,664,184,403,347,744,790,129,841,152,842,436,882,361,247,43,624,157,944,270,598,197,871,539,883,631,993,357,835,1044,131,710,911,637,927,884,398,777,210,616,563,1043,890,173,253,285,729,625,1022,235,517,833,45,679,1011,951,239,763,467,623,859,236,976,573,907,4,444,171,917,330,996,626,69,681,188,874,725,711,628,13,6,176,381,301,66,920,316,587,376,502,1051,356,258,728,491,530,696,931,26,750,96,350,339,622,527,1023,695,27,646,32,401,714,187,822,391,550,785,42,553,830,991,953,461,663,580,1035,331,227,1033,559,233,985,746,363,336,596,533,987,521,712,486,472,248,105,581,698,490,215,1006,853,699,1018,915,272,811,146,756,892,44,651,727,8,226,406,877,762,843,900,823,827,426,813,741,612,534,869,969,261,37,441,208,860,116,838,408,979,926,794,293,214,263,364,1014,333,998,71,260,832,346,1,954,879,372,326,672,302,217,165,586,412,119,912,434,206,717,259,423,161,797,228,70,28,269,360,370,675,599,338,24,945,488,847,11,481,245,39,308,828,734,819,249,846,697,375,112,191,629,724,700,650,510,765,684,311,731,153,190,862,821,22,320,1046,963,279,442,186,103,78,829,851,971,1001,380,516,144,225,84,17,781,901,548,82,557,179,429,703,640,503,644,355,721,613,1002,673,202,271,478,566,1024,831,916,918,593,1042,399,974,770,309,988,207,482,304,666,3,315,662,394,1034,887,939,61,592,522,56,382,282,983,177,433,701,736,341,303,383,438,656,497,707,328,608,935,354,881,29,424,716,964,875,962,634,671,768,515,978,786,104,825,647,435,455,169,234,560,773,619,733,547,415,511,660,943,329,314,387,283,1032,643,319,739,68,610,585,459,147,1012,267,238,334,657,609,237,512,1031,718,579,151,709,783,473,635,852,968,111,170,569,854,483,193,840,591,975,571,803,615,936,451,158,574,798,509,958,705,704,120,759,956,508,181,772,720,275,972,106,950,1000,715,702,774,95,19,373,286,160,730,1030,142,284,448,977,665,289,653,965,670,529,688,658,764,300,246,55,801,722,367,452,102,89,1013,687,395,49,392,824,203,948,837,405,200,903,849,655,135,924,570,67,136,682,462,743,990,812,109,379,345,417,265,799,410,25,369,450,1027,409,1016,358,141,374,735,804,898,51,94,602,384,46,864,930,604,340,649,541,155,789,2,224,802,779,292,266,469,305,934,719,107,960,1037,244,905,344,447,324,257,538,654,14,240,791,504,386,1025,413,149,601,1041,480,545,221,125,362,523,31,194,922,198,957,218,858,327,251,416,422,41,130,961,676,603,439,815,621,800,219,199,57,75,117,241,411,568,708,63,904,264,232,121,325,897,967,276,134,808,321,205,222,506,138,83,857,216,992,457,453,761,752,787,617,122,766,694,792,477,156,492,844,689,850,923,40,788,1003,290,532,79,64,196,740,941,810,18,390,92,323,500,1020,430,691,108,437,929,620,213,34,1052,133,685,425,139,886,525,652,76,513,414,268,150,561,865,159,209,674,463,365,110,407,278,468,577,168,274,396,861,748,310,891,93,997,440,947,995,65,986,1010,1048,1045,889,928,495,520,85,113,867,1038,378,1007,397,470,318,421,10,518,542,98,1019,575,498,519,667,299,368,294,167,567,776,870,1050,618,192,466,80,35,737,1004,48,809,636,641,678,795,942]++-- | Prime-length balanced list of Bools randomized with the RealDice raw data+rdBoolsPrime :: [Bool]+rdBoolsPrime = [True,False,True,False,True,False,False,True,True,False,False,True,True,True,False,False,False,True,False,False,False,False,False,True,False,True,True,True,True,False,True,False,True,False,True,True,True,True,False,False,False,False,False,False,True,False,False,False,True,True,True,True,True,True,False,False,True,False,True,True,True,True,True,True,False,False,False,False,False,True,True,True,True,False,False,False,False,True,True,True,True,False,False,False,True,True,True,True,False,False,False,True,False,False,True,True,True,True,True,True,False,True,True,False,False,True,True,True,False,False,False,False,False,True,False,True,False,False,False,False,True,True,True,True,False,True,True,False,True,True,False,True,False,False,False,False,False,False,True,False,False,True,False,True,False,False,True,False,False,False,True,False,False,True,True,True,True,False,False,True,False,False,True,True,True,True,False,False,False,True,True,False,False,True,False,True,False,False,False,False,True,False,False,True,False,True,True,False,False,True,True,True,True,False,False,True,True,True,True,False,False,True,False,True,True,True,True,False,False,True,False,False,True,True,False,False,False,True,False,False,True,True,True,False,False,False,True,False,True,False,False,True,False,True,False,True,True,True,False,False,False,False,True,False,False,False,True,False,True,False,False,True,False,False,True,True,False,True,False,False,False,False,True,False,True,False,True,True,False,False,False,True,True,False,True,True,True,True,False,True,True,True,True,True,False,True,True,True,True,True,False,True,False,False,False,True,False,True,False,False,False,False,True,False,True,True,True,False,False,False,True,True,False,False,False,False,True,True,False,False,True,True,False,False,False,False,True,True,True,False,True,False,False,False,True,True,True,True,True,True,True,True,False,True,False,True,True,True,False,False,True,False,False,True,True,False,True,True,True,True,True,False,True,True,True,True,True,True,True,True,True,True,True,True,False,False,True,True,False,False,True,True,False,False,False,True,True,False,False,True,True,False,True,False,False,True,True,False,False,False,True,False,False,True,False,False,False,True,False,False,True,False,False,False,False,True,False,True,True,True,True,False,False,True,False,True,False,True,False,True,False,True,False,True,True,True,True,False,True,True,True,True,True,True,True,False,True,False,False,True,True,True,False,False,False,False,True,True,False,False,True,False,True,True,False,True,False,True,False,False,False,False,True,True,False,False,False,True,False,True,False,True,True,False,True,True,False,False,True,True,True,True,True,False,False,False,False,False,True,False,False,True,False,True,False,False,True,False,True,False,False,False,True,False,True,False,False,False,False,True,True,False,False,True,False,False,False,True,True,True,True,True,False,False,False,True,False,False,True,True,False,False,True,False,True,True,True,True,True,False,False,False,True,True,False,True,True,False,True,True,False,False,False,False,True,False,True,True,True,False,False,True,False,False,False,True,True,False,False,True,False,True,True,True,True,False,False,False,True,False,True,True,True,False,False,True,True,True,True,False,True,False,True,True,True,False,True,False,True,False,False,False,True,False,False,True,False,True,False,False,True,False,True,False,False,False,True,True,False,False,False,True,True,True,False,False,False,False,False,True,True,True,True,False,True,True,True,False,False,True,True,False,False,True,False,True,True,False,False,False,True,False,False,True,False,True,False,False,False,True,True,True,True,True,False,False,True,True,True,True,True,True,False,True,True,False,True,True,False,True,True,True,False,False,True,True,True,False,True,False,False,True,True,True,False,True,False,True,True,True,True,True,True,False,False,True,False,True,False,True,True,False,True,True,True,True,True,False,True,False,False,False,True,False,True,False,False,True,False,False,True,False,False,True,False,False,False,False,True,False,False,True,True,True,False,False,False,False,False,False,False,True,True,True,True,True,False,True,False,False,False,False,False,True,True,False,True,False,False,True,True,True,True,True,False,False,True,False,True,True,False,True,True,True,True,False,False,True,False,False,False,True,False,False,True,True,True,True,True,True,False,True,True,False,True,True,False,False,True,False,True,False,False,True,False,False,False,False,False,False,False,False,True,True,True,True,False,False,False,True,False,False,True,True,False,True,True,False,True,False,True,False,True,False,True,False,False,False,False,True,False,False,True,True,True,True,True,False,True,True,True,False,True,True,False,False,False,True,False,False,True,True,False,False,True,False,True,False,True,True,True,True,False,True,True,True,True,True,True,True,False,False,True,False,False,False,True,True,True,True,False,False,False,True,True,False,False,False,True,True,False,False,True,True,True,False,True,True,False,False,False,False,True,False,False,False,True,False,True,False,False,True,False,False,True,False,False,False,True,False,False,False,False,True,False,False,False,True,False,True,True,False,True,False,False,True,True,True,True,True,False,True,False,False,True,False,True,True,True,True,True,True,True,False,False,False,False,False,True,False,True,False,False,False,True,True,False,False,True,True,False,False,False,False,False,True,False,True,False,True,True,True,True,False,False,False,False,True,False,False,False,False,True,False,False,True,True,True,False,False,True,True,True,False,False,False,False,False,False,True,True,False,False,False,False,False,True,False,True,True,False]++-- | Full-length balanced list of Bools randomized with the RealDice raw data+rdBoolsFull :: [Bool]+rdBoolsFull = [False,True,True,False,True,True,False,False,True,True,False,False,False,True,False,True,False,False,True,False,True,False,False,True,False,False,False,True,True,False,True,False,True,False,True,True,True,True,False,False,False,False,False,False,True,False,False,False,True,True,True,True,False,False,True,False,True,True,False,True,True,True,True,True,False,True,False,False,False,False,True,True,False,True,False,False,False,False,True,False,True,False,True,False,True,True,False,False,True,False,False,True,False,False,True,True,True,True,True,False,False,True,False,True,False,True,True,True,True,True,False,False,False,False,True,False,True,False,False,False,True,True,True,True,True,False,False,True,True,False,True,True,False,True,False,False,False,False,False,False,True,False,False,True,False,True,False,False,True,False,False,False,True,False,False,True,True,True,True,False,False,True,False,False,True,True,True,True,False,False,False,True,True,False,False,True,False,True,False,False,False,False,True,False,False,True,False,True,True,False,False,True,True,True,True,False,False,True,True,True,True,False,False,True,False,True,True,True,True,False,False,True,False,False,True,True,False,False,False,True,False,False,True,True,True,False,False,False,True,False,True,False,False,True,False,True,False,True,True,True,False,False,False,False,True,False,False,False,True,False,True,False,False,True,False,False,True,True,False,True,False,False,False,False,True,False,True,False,True,True,False,False,False,True,True,False,True,True,True,True,False,True,True,True,True,True,False,True,True,True,True,True,False,True,False,False,False,True,False,True,False,False,False,False,True,False,True,True,True,False,False,False,True,True,False,False,False,False,True,True,False,False,True,True,False,False,False,False,True,True,True,False,True,False,False,False,True,True,True,True,True,True,True,True,False,True,False,True,True,True,False,False,True,False,False,True,True,False,True,True,True,True,True,False,True,True,True,True,True,True,True,True,True,True,True,True,False,False,True,True,False,False,True,True,False,False,False,True,True,False,False,True,True,False,True,False,False,True,True,False,False,False,True,False,False,True,False,False,False,True,False,False,True,False,False,False,False,True,False,True,True,True,True,False,False,True,False,True,False,True,False,True,False,True,False,True,True,True,True,False,True,True,True,True,True,True,True,False,True,False,False,True,True,True,False,False,False,False,True,True,False,False,True,False,True,True,False,True,False,True,False,False,False,False,True,True,False,False,False,True,False,True,False,True,True,False,True,True,False,False,True,True,True,True,True,False,False,False,False,False,True,False,False,True,False,True,False,False,True,False,True,False,False,False,True,False,True,False,False,False,False,True,True,False,False,True,False,False,False,True,True,True,True,True,False,False,False,True,False,False,True,True,False,False,True,False,True,True,True,True,True,False,False,False,True,True,False,True,True,False,True,True,False,False,False,False,True,False,True,True,True,False,False,True,False,False,False,True,True,False,False,True,False,True,True,True,True,False,False,False,True,False,True,True,True,False,False,True,True,True,True,False,True,False,True,True,True,False,True,False,True,False,False,False,True,False,False,True,False,True,False,False,True,False,True,False,False,False,True,True,False,False,False,True,True,True,False,False,False,False,False,True,True,True,True,False,True,True,True,False,False,True,True,False,False,True,False,True,True,False,False,False,True,False,False,True,False,True,False,False,False,True,True,True,True,True,False,False,True,True,True,True,True,True,False,True,True,False,True,True,False,True,True,True,False,False,True,True,True,False,True,False,False,True,True,True,False,True,False,True,True,True,True,True,True,False,False,True,False,True,False,True,True,False,True,True,True,True,True,False,True,False,False,False,True,False,True,False,False,True,False,False,True,False,False,True,False,False,False,False,True,False,False,True,True,True,False,False,False,False,False,False,False,True,True,True,True,True,False,True,False,False,False,False,False,True,True,False,True,False,False,True,True,True,True,True,False,False,True,False,True,True,False,True,True,True,True,False,False,True,False,False,False,True,False,False,True,True,True,True,True,True,False,True,True,False,True,True,False,False,True,False,True,False,False,True,False,False,False,False,False,False,False,False,True,True,True,True,False,False,False,True,False,False,True,True,False,True,True,False,True,False,True,False,True,False,True,False,False,False,False,True,False,False,True,True,True,True,True,False,True,True,True,False,True,True,False,False,False,True,False,False,True,True,False,False,True,False,True,False,True,True,True,True,False,True,True,True,True,True,True,True,False,False,True,False,False,False,True,True,True,True,False,False,False,True,True,False,False,False,True,True,False,False,True,True,True,False,True,True,False,False,False,False,True,False,False,False,True,False,True,False,False,True,False,False,True,False,False,False,True,False,False,False,False,True,False,False,False,True,False,True,True,False,True,False,False,True,True,True,True,False,True,False,False,True,False,False,False,True,True,True,True,False,True,True,False,True,False,False,True,False,False,False,True,False,False,True,True,True,False,True,True,True,False,False,False,True,True,False,True,False,True,True,True,False,False,True,True,False,False,True,False,False,False,False,True,True,False,True,True,True,False,False,True,True,False,False,False,False,False,False,False,True,True,False,False,True,False,True,False,True,False]++-- | Prime-length balanced binary string randomized with the RealDice raw data+rdBinPrime :: String+rdBinPrime = "1010100110011100010000010111101010111100000010001111110010111111000001111000011110001111000100111111011001110000010100001111011011010000001001010010001001111001001111000110010100001001011001111001111001011110010011000100111000101001010111000010001010010011010000101011000110111101111101111101000101000010111000110000110011000011101000111111110101110010011011111011111111111100110011000110011010011000100100010010000101111001010101010111101111111010011100001100101101010000110001010110110011111000001001010010100010100001100100011111000100110010111110001101101100001011100100011001011110001011100111101011101010001001010010100011000111000001111011100110010110001001010001111100111111011011011100111010011101011111100101011011111010001010010010010000100111000000011111010000011010011111001011011110010001001111110110110010100100000000111100010011011010101010000100111110111011000100110010101111011111110010001111000110001100111011000010001010010010001000010001011010011111010010111111100000101000110011000001010111100001000010011100111000000110000010110"++-- | Full-length balanced binary string randomized with the RealDice raw data+rdBinFull :: String+rdBinFull = "011011001100010100101001000110101011110000001000111100101101111101000011010000101010110010010011111001010111110000101000111110011011010000001001010010001001111001001111000110010100001001011001111001111001011110010011000100111000101001010111000010001010010011010000101011000110111101111101111101000101000010111000110000110011000011101000111111110101110010011011111011111111111100110011000110011010011000100100010010000101111001010101010111101111111010011100001100101101010000110001010110110011111000001001010010100010100001100100011111000100110010111110001101101100001011100100011001011110001011100111101011101010001001010010100011000111000001111011100110010110001001010001111100111111011011011100111010011101011111100101011011111010001010010010010000100111000000011111010000011010011111001011011110010001001111110110110010100100000000111100010011011010101010000100111110111011000100110010101111011111110010001111000110001100111011000010001010010010001000010001011010011110100100011110110100100010011101110001101011100110010000110111001100000001100101010"
+ src/RealDice/Generate/PseudoRandomizedInts.hs view
@@ -0,0 +1,17 @@+-- | This module contains pseudo-randomized integers for use as a seed+--   when generating the RealDice balanced data+module RealDice.Generate.PseudoRandomizedInts+  ( psRndIntsPrime,+    psRndIntsFull+  )+where++-- | Prime-length list of integers randomized with StdGen, for use as a seed+--   when generating the RealDice balanced data+psRndIntsPrime :: [Int]+psRndIntsPrime = [862,190,821,22,320,153,1046,963,279,442,186,731,311,684,765,510,650,700,724,629,103,191,78,112,829,375,697,846,851,249,971,819,734,828,1001,380,516,144,225,84,308,39,17,781,901,548,245,481,11,847,488,945,24,338,82,599,675,557,179,429,703,370,640,360,269,28,503,644,70,228,355,797,721,161,423,613,259,717,206,434,912,119,1002,412,673,202,586,165,271,217,478,566,302,672,1024,326,372,879,954,831,916,1,918,346,832,593,260,1042,71,998,399,333,1014,974,364,770,309,988,263,207,482,304,666,3,214,315,662,293,794,394,1034,926,979,408,887,838,939,61,116,860,592,522,56,382,282,983,177,208,433,441,37,701,261,736,341,969,869,534,303,612,383,438,741,813,656,426,497,827,823,707,328,900,608,843,762,935,354,881,877,406,226,29,424,8,716,727,651,44,892,964,756,146,875,962,811,272,634,671,915,1018,699,853,768,515,978,786,104,825,647,435,455,1006,169,234,560,215,773,490,698,581,619,733,105,248,547,472,486,415,511,660,943,329,314,387,283,712,521,1032,643,987,533,319,596,336,739,68,610,585,363,459,746,985,147,1012,267,238,233,334,559,657,1033,227,331,1035,580,609,237,512,1031,718,579,663,151,461,709,953,991,783,473,830,553,42,785,550,391,635,822,852,187,968,714,401,32,111,646,27,695,1023,527,622,339,170,350,569,96,854,750,26,931,483,696,530,193,491,728,840,258,356,1051,591,975,502,571,376,587,316,803,920,615,936,66,301,381,451,176,158,574,6,13,628,711,798,509,725,958,874,188,705,681,704,120,759,69,956,626,508,181,996,330,772,720,917,171,444,4,907,573,275,976,236,972,859,106,623,950,1000,715,702,774,95,467,19,373,286,763,160,730,239,1030,142,284,951,1011,679,45,448,977,833,665,289,517,653,235,965,1022,670,529,625,729,285,253,688,173,658,890,1043,764,300,563,616,210,777,246,55,398,884,801,927,722,367,637,911,452,102,89,1013,710,131,1044,835,687,357,993,395,49,631,883,392,539,871,824,197,598,270,203,944,157,948,624,43,247,361,882,436,842,837,152,405,200,841,903,129,790,849,655,744,135,347,924,403,184,570,664,74,906,277,693,67,136,856,826,682,462,288,115,775,145,743,990,614,9,812,514,256,109,379,345,417,946,806,343,848,265,955,760,524,1008,799,353,312,410,769,807,25,143,21,313,738,351,369,175,659,7,450,1027,419,409,1016,88,99,583,358,337,141,374,735,804,898,51,94,602,127,280,384,873,751,46,1028,496,562,933,864,81,706,930,595,604,402,487,1036,16,220,484,340,287,649,546,817,549,114,541,155,789,166,2,543,896,224,802,779,292,266,469,952,919,305,934,719,107,960,1037,244,558,905,344,53,447,572,476,324,932,257,793,796,538,878,552,254,33,1009,654,14,240,791,504,589,386,1025,252,377,413,352,149,601,1041,949,818,36,480,545,627,221,125,362,984,59,523,164,31,132,910,194,87,922,937,537,726,198,690,485,582,458,814,957,137,218,229,970,204,443,816,780,858,327,251,317,416,597,745,393,422,41,130,961,38,676,195,420,180,757,603,895,273,439,815,211,494,621,800,866,855,893,219,845,199,307,57,75,117,241,590,52,499,411,507,568,708,388,645,296,600,63,904,264,232,839,121,325,888,897,584,967,182,276,126,713,134,808,321,205,72,222,475,680,506,86,899,138,83,371,938,857,216,400,992,457,453,880,255,1039,97,771,761,630,322,752,805,787,836,617,62,445,243,122,47,766,694,973,638,404,792,477,156,492,844,689,999,154,332,578,185,212,418,850,923,40,788,223,242,1003,290,981,532,834,79,456,163,348,64,528,432,196,740,941,810,18,894,460,390,1026,92,323,500,1020,989,118,231,430,691,749,124,108,755,437,929,620,213,535,34,576,556,133,1029,685,607,425,349,139,661,886,525,652,677,76,172,668,606,5,692,513,414,183,966,754,554,268,428,150,561,565,865,23,159,555,209,605,674,908,463,365,753,782,493,110,407,982,642,959,913,291,91,1017,278,468,648,994,577,168,465,274,396,861,748,758,310,12,891,389,93,997,526,784,427,335,440,50,281,298,947,995,767,20,65,123,986,262,686,1010,474,250,1048,449,60,1045,889,297,928,201,495,778,742,588,520,366,921,820,1049,85,1015,77,885,863,113,162,867,909,925,1038,536,378,431,54,1007,397,470,90,471,489,633,1047,446,230,174,295,342,914,632,128,318,940,902,101,421,531,10,73,518,542,98,639,540,505,140,189,868,747,1019,575,498,519,667,385,980,299,30,872,611,876,368,594,1021,306,294,167,567,669,776,1040,870,1050,618,544,192,466,80,551,35,737,564,1004,359,48,809,100,148,454,636,723,641,683,58,678,464,795,15,479,178,501,942,1005,732]++-- | Full-length list of integers randomized with StdGen, for use as a seed+--   when generating the RealDice balanced data+psRndIntsFull :: [Int]+psRndIntsFull = [862,190,821,22,320,153,1046,963,279,442,186,731,311,684,765,510,650,700,724,629,103,191,78,112,829,375,697,846,851,249,971,819,734,828,1001,380,516,144,225,84,308,39,17,781,901,548,245,481,11,847,488,945,24,338,82,599,675,557,179,429,703,370,640,360,269,28,503,644,70,228,355,797,721,161,423,613,259,717,206,434,912,119,1002,412,673,202,586,165,271,217,478,566,302,672,1024,326,372,879,954,831,916,1,918,346,832,593,260,1042,71,998,399,333,1014,974,364,770,309,988,263,207,482,304,666,3,214,315,662,293,794,394,1034,926,979,408,887,838,939,61,116,860,592,522,56,382,282,983,177,208,433,441,37,701,261,736,341,969,869,534,303,612,383,438,741,813,656,426,497,827,823,707,328,900,608,843,762,935,354,881,877,406,226,29,424,8,716,727,651,44,892,964,756,146,875,962,811,272,634,671,915,1018,699,853,768,515,978,786,104,825,647,435,455,1006,169,234,560,215,773,490,698,581,619,733,105,248,547,472,486,415,511,660,943,329,314,387,283,712,521,1032,643,987,533,319,596,336,739,68,610,585,363,459,746,985,147,1012,267,238,233,334,559,657,1033,227,331,1035,580,609,237,512,1031,718,579,663,151,461,709,953,991,783,473,830,553,42,785,550,391,635,822,852,187,968,714,401,32,111,646,27,695,1023,527,622,339,170,350,569,96,854,750,26,931,483,696,530,193,491,728,840,258,356,1051,591,975,502,571,376,587,316,803,920,615,936,66,301,381,451,176,158,574,6,13,628,711,798,509,725,958,874,188,705,681,704,120,759,69,956,626,508,181,996,330,772,720,917,171,444,4,907,573,275,976,236,972,859,106,623,950,1000,715,702,774,95,467,19,373,286,763,160,730,239,1030,142,284,951,1011,679,45,448,977,833,665,289,517,653,235,965,1022,670,529,625,729,285,253,688,173,658,890,1043,764,300,563,616,210,777,246,55,398,884,801,927,722,367,637,911,452,102,89,1013,710,131,1044,835,687,357,993,395,49,631,883,392,539,871,824,197,598,270,203,944,157,948,624,43,247,361,882,436,842,837,152,405,200,841,903,129,790,849,655,744,135,347,924,403,184,570,664,74,906,277,693,67,136,856,826,682,462,288,115,775,145,743,990,614,9,812,514,256,109,379,345,417,946,806,343,848,265,955,760,524,1008,799,353,312,410,769,807,25,143,21,313,738,351,369,175,659,7,450,1027,419,409,1016,88,99,583,358,337,141,374,735,804,898,51,94,602,127,280,384,873,751,46,1028,496,562,933,864,81,706,930,595,604,402,487,1036,16,220,484,340,287,649,546,817,549,114,541,155,789,166,2,543,896,224,802,779,292,266,469,952,919,305,934,719,107,960,1037,244,558,905,344,53,447,572,476,324,932,257,793,796,538,878,552,254,33,1009,654,14,240,791,504,589,386,1025,252,377,413,352,149,601,1041,949,818,36,480,545,627,221,125,362,984,59,523,164,31,132,910,194,87,922,937,537,726,198,690,485,582,458,814,957,137,218,229,970,204,443,816,780,858,327,251,317,416,597,745,393,422,41,130,961,38,676,195,420,180,757,603,895,273,439,815,211,494,621,800,866,855,893,219,845,199,307,57,75,117,241,590,52,499,411,507,568,708,388,645,296,600,63,904,264,232,839,121,325,888,897,584,967,182,276,126,713,134,808,321,205,72,222,475,680,506,86,899,138,83,371,938,857,216,400,992,457,453,880,255,1039,97,771,761,630,322,752,805,787,836,617,62,445,243,122,47,766,694,973,638,404,792,477,156,492,844,689,999,154,332,578,185,212,418,850,923,40,788,223,242,1003,290,981,532,834,79,456,163,348,64,528,432,196,740,941,810,18,894,460,390,1026,92,323,500,1020,989,118,231,430,691,749,124,108,755,437,929,620,213,535,34,576,1052,556,133,1029,685,607,425,349,139,661,886,525,652,677,76,172,668,606,5,692,513,414,183,966,754,554,268,428,150,561,565,865,23,159,555,209,1053,605,674,908,463,365,753,782,493,110,407,982,642,959,913,291,91,1017,278,468,648,994,577,168,465,274,396,861,748,758,310,12,891,389,93,997,526,784,427,335,440,50,281,298,947,995,767,20,65,123,986,262,686,1010,474,250,1048,449,60,1045,889,297,928,201,495,778,742,588,520,366,921,820,1049,85,1015,77,885,863,113,162,867,909,925,1038,536,378,431,54,1007,397,470,90,471,489,633,1047,446,230,174,295,342,914,632,128,318,940,902,101,421,531,10,73,518,542,98,639,540,505,140,189,868,747,1019,575,498,519,667,385,980,299,30,872,611,876,368,594,1021,306,294,167,567,669,776,1040,870,1050,618,544,192,466,80,551,35,737,564,1004,359,48,809,100,148,454,636,723,641,683,58,678,464,795,15,479,178,501,942,1005,732]
+ src/RealDice/Generate/RawData.hs view
@@ -0,0 +1,72 @@+-- | This module contains the raw RealDice random data gathered from human+--   interaction with physical media+module RealDice.Generate.RawData+  ( rawBoolPrime,+    rawBoolFull,+    rawBinPrime,+    rawBinFull,+  )+where++import RealDice.Convert.BinaryString (binToBools)+import RealDice.Util.Prime (greatestPrimeNotGreaterThan)++-- | This is raw random data gathered from human interaction with the physical world++-- | The data is gathered by rolling dice as well as drawing poker chips+--   out of a bag, stacking them up (without looking at them), and using a+--   heads/tails schema to get the values++-- | I'm using a string of "1"s and "0"s to represent the binary data because+--   it's easy to manually type in while I'm collecting data and it's easy to+--   parse into other data++-- | How did I get binary data from the dice? Does Heads equal "1" or+--   does Tails? What do Heads and Tails mean on a poker chip anyway?++-- | Who knows? I'm willfully not being too precious with that information+--   between sessions of collecting data, in order to maximize entropy =)++-- | Okay, I'll reveal some of the dice part. Mostly I've been using+--   multiple sets of 7 polyhedral dice (1d4, 1d6, 1d8, 2d10 (AKA percentage dice),+--   1d12, 1d20) and recording their results in a specific order (I think the+--   first time it was smallest (i.e. fewest sides) dice to largest, lightest+--   color to darkest, maybe?). I have used an even/odd schema to get the binary+--   values, but there's more than one way to do this and I may vary any of of+--   this methodology. I will endeavor to keep it as truly random as possible+rawBinFull :: String+rawBinFull = "110001000001111111110101011101011100000011000011111111011000010111001101011011111101001101001101111001011010110110100010000010011001110100110000000101101001110100110101100101100011100101111011001100111100000000010001011100110110000000011001101100001011000010101111100000010101100111111010101110111111101010111011011011100101110100111010011110010110100010100110011111101101010000001000100100011110010010101001111010110011110011010011000011110110011011011101101111111010010110010101101111100110011110011011000011110111101101101111101110010011101000000001101101111011010111111010111100010110000001100000001001011010110111110000010011010001110010001101011010111011111010111111000101110000101111011001100111010100001110100111100001001010101100001011011001100100011111011010101110100111000000111111100001100101011101100000110100001110011010000101010101010100010111110011110100101010110100111001111111001100100001010100111101110011010110110110010101110111101111010110101100011111111111110111010100011111110000011011110111000101000100010010100111010110101111011"++-- | This is raw random data from human interaction with the physical world,+--   truncated to have a prime number of elements++-- | We provide a subset of the full data with a prime number of elements so+--   that it's less likely that a pattern will emerge when repeatedly using a+--   predictable algorithm to loop over the data++-- | For example, suppose we have this random list of 12 elements: "011010010011"++-- | And suppose we repeatedly use a function that always references the+--   randomized list 4 times, each time using the element at the current+--   index and then incrementing the index by 1++-- | In this scenario, the elements the function uses would start repeating+--   after running the function only three times++-- | In contrast, if we use a subset of the list 11 items long ("01101001001"),+--   we can run the function 11 times before the elements start repeating+rawBinPrime :: String+rawBinPrime = do+  let primeLength = greatestPrimeNotGreaterThan (length rawBinFull)+  take primeLength rawBinFull++-- | This is raw random data from human interaction with the physical world,+--   converted to a list of Bools+rawBoolFull :: [Bool]+rawBoolFull = binToBools rawBinFull++-- | This is raw random data from human interaction with the physical world,+--   truncated to have a prime number of elements, and converted to a list of+--   Bools+rawBoolPrime :: [Bool]+rawBoolPrime = binToBools rawBinPrime
+ src/RealDice/Manipulate.hs view
@@ -0,0 +1,10 @@+-- | This module re-exports functions used to manipulate RNG tables and+--   other lists of data+module RealDice.Manipulate+  ( module RealDice.Manipulate.GetValueFromRNGTable,+    module RealDice.Manipulate.RandomizeList,+  )+where++import RealDice.Manipulate.GetValueFromRNGTable+import RealDice.Manipulate.RandomizeList
+ src/RealDice/Manipulate/GetValueFromRNGTable.hs view
@@ -0,0 +1,45 @@+-- | This module contains functions that get values from a list.+--   These functions are used to get values from randomized tables for random+--   generation purposes+module RealDice.Manipulate.GetValueFromRNGTable+  ( getBoolByIndex,+    getIntByIndex,+  )+where++-- | Gets an integer value from a list by index, looping back to the beginning+--   if the index is out of bounds++-- | This is used to get an element from a randomized table of integers++-- | ==== __Examples__+--   >>> getIntByIndex 2 [1, 0, 4, 3, 2]+--   4+--   >>> getIntByIndex 5 [1, 0, 4, 3, 2]+--   1+--   >>> getIntByIndex -1337 [1, 0, 4,  3, 2]+--   3+getIntByIndex :: Int -> [Int] -> Int+getIntByIndex index l = l !! (index `mod` length l)++-- | Gets a boolean value from a list by index, looping back to the beginning+--   if the index is out of bounds++-- | After looping over the list once, we flip the values of the elements+--     so that we can use an odd list length while still having an even+--     distribution of "True" and "False" values++-- | This is used to get an element from a randomized table of booleans++-- | ==== __Examples__+--   >>> getBoolByIndex 2 [True, False, True, False, True]+--   True+--   >>> getBoolByIndex 5 [True, False, True, False, True]+--   True+--   >>> getBoolByIndex -1337 [True, False, True, False, True]+--   False+getBoolByIndex :: Int -> [Bool] -> Bool+getBoolByIndex index l =+  if (index `mod` (length l * 2)) < length l+    then l !! (index `mod` (length l * 2))+    else not (l !! ((index `mod` (length l * 2)) - length l))
+ src/RealDice/Manipulate/RandomizeList.hs view
@@ -0,0 +1,53 @@+-- | Module for randomizing the order of elements in a list.+--   Used to generate randomized lists for table-based random generation+module RealDice.Manipulate.RandomizeList+  ( randomizeList,+    randomizeWithCustomBools,+  )+where++import Control.Monad.State+import RealDice.Generate.BalancedTables (rdBoolsPrime)+import RealDice.Manipulate.GetValueFromRNGTable (getBoolByIndex)++-- | Stores the index of the next value to return from a randomized list+data RandomState where+  RandomState :: {index :: Int} -> RandomState++-- | Randomizes the order of a list of integers using the default balanced+--   table of RealDice randomized booleans++-- | ==== __Examples__+--   >>> randomizeList [1, 2, 3, 4, 5]+--   [2, 4, 1, 5, 3]+randomizeList :: [Int] -> [Int]+randomizeList xs = randomizeWithCustomBools xs rdBoolsPrime++-- | Randomizes the order of a list of integers using a custom list of booleans++-- | ==== __Examples__+--   >>> randomizeWithCustomBools [1, 2, 3, 4, 5] [True, False, True, False, True]+--   [1, 3, 5, 2, 4]+randomizeWithCustomBools :: [Int] -> [Bool] -> [Int]+randomizeWithCustomBools xs boolList =+  evalState+    (randomizeListWithCustomBoolListSinglePass xs [] boolList)+    (RandomState 0)++randomizeListWithCustomBoolListSinglePass ::+  [Int] -> [Int] -> [Bool] -> State RandomState [Int]+randomizeListWithCustomBoolListSinglePass [] l' _ = return l'+randomizeListWithCustomBoolListSinglePass l l' boolList = do+  random <- get+  put RandomState {index = index random + 1}+  if getBoolByIndex (index random) boolList+    then+      randomizeListWithCustomBoolListSinglePass+        (tail l)+        (head l : l')+        boolList+    else+      randomizeListWithCustomBoolListSinglePass+        (tail l)+        (l' ++ [head l])+        boolList
+ src/RealDice/RNG.hs view
@@ -0,0 +1,128 @@+-- | This module provides functions to generate random numbers using balanced+--   integer tables randomized by the RealDice data or custom integer tables+module RealDice.RNG+  ( RDGen,+    randomIntR,+    randomFloat,+    randomDouble,+    mkRDGen,+    mkRDGenCustom,+  )+where++import RealDice.Generate.BalancedTables (rdIntsPrime)+import RealDice.Manipulate.GetValueFromRNGTable (getIntByIndex)+import RealDice.Manipulate.RandomizeList (randomizeList)++-- | Stores a balanced table of random integers and an index pointing to the+--   next value to return+data RDGen where+  RDGen :: {index :: Int, rngTable :: [Int]} -> RDGen++-- | Creates a new RDGen with the given index and the default Int table++-- | ==== __Examples__+-- >>> mkRDGen 143+-- {143, rdIntsPrime}+mkRDGen :: Int -> RDGen+mkRDGen i = mkRDGenCustom i rdIntsPrime++-- | Creates a new RDGen with the given index and Int table++-- | Defaults to the RealDice balanced table of random integers if an empty+--   list is given++-- | ==== __Examples__+--   >>> mkRDGenCustom 143 [1, 0, 4, 3, 2]+--   {143, [1, 0, 4, 3, 2]}+--   >>> mkRDGenCustom 143 []+--   {143, rdIntsPrime}+mkRDGenCustom :: Int -> [Int] -> RDGen+mkRDGenCustom i [] = RDGen {index = i, rngTable = rdIntsPrime}+mkRDGenCustom i table = RDGen {index = i, rngTable = table}++-- | Generates a random integer value between minResult and maxResult via a+--   simple table lookup++-- | ==== __Examples__+--   >>> randomIntR (1, 20) (mkRDGen 143)+--   (12, {144, rdIntsPrime})+--   >>> randomIntR (-1000000, 1000000) (mkRDGen 42)+--   (76465, {43, rdIntsPrime})+--   >>> randomIntR (10, 1) (mkRDGen 42)+--   (0, {43, rdIntsPrime})+randomIntR :: (Int, Int) -> RDGen -> (Int, RDGen)+randomIntR (minResult, maxResult) rng+  | minResult > maxResult = (0, rng)+  | otherwise =+      ( getIntByIndex+          (getIntByIndex (index rng) (rngTable rng))+          (randomizeList [minResult .. maxResult]),+        RDGen {index = index rng + 1, rngTable = rngTable rng}+      )++-- Generate a random float value between 0 and 1++-- | ==== __Examples__+--   >>> randomFloat 3 (mkRDGen 143)+--   (0.503, {144, rdIntsPrime})+--   >>> randomFloat 0 (mkRDGen 143)+--   (0, {143, rdIntsPrime})+--   >>> randomFloat (-1) (mkRDGen 143)+--   (0, {143, rdIntsPrime})+randomFloat :: Int -> RDGen -> (Float, RDGen)+randomFloat decimalPrecision rng+  | decimalPrecision < 0 = (0, rng)+  | otherwise = randomFloatSinglePass (decimalPrecision, 0) rng++-- Generates a single digit to be used to compose a random float++-- | ==== __Examples__+--  >>> randomFloatSinglePass (1, 0.003) (mkRDGen 145)+--  (0.503, {146, rdIntsPrime})+--  >>> randomFloatSinglePass (0, 0) (mkRDGen 143)+--  (0, {143, rdIntsPrime})+--  >>> randomFloatSinglePass (-1, 0) (mkRDGen 143)+--  (0, {143, rdIntsPrime})+randomFloatSinglePass :: (Int, Float) -> RDGen -> (Float, RDGen)+randomFloatSinglePass (0, currentFloat) rng = (currentFloat, rng)+randomFloatSinglePass (decimalPlace, currentFloat) rng = do+  let randomDigit = getIntByIndex (getIntByIndex (index rng) (rngTable rng)) (randomizeList [0 .. 9])+  randomFloatSinglePass+    ( decimalPlace - 1,+      currentFloat + (fromIntegral randomDigit / (10 ^ decimalPlace))+    )+    (RDGen {index = index rng + 1, rngTable = rngTable rng})++-- Generates a random float value between 0 and 1++-- | ==== __Examples__+--   >>> randomDouble 3 (mkRDGen 143)+--   (0.503, {144, rdIntsPrime})+--   >>> randomDouble 0 (mkRDGen 143)+--   (0, {143, rdIntsPrime})+--   >>> randomDouble (-1) (mkRDGen 143)+--   (0, {143, rdIntsPrime})+randomDouble :: Int -> RDGen -> (Double, RDGen)+randomDouble decimalPrecision rng+  | decimalPrecision < 0 = (0, rng)+  | otherwise = randomDoubleSinglePass (decimalPrecision, 0) rng++-- Generates a single digit to be used to compose a random float++-- | ==== __Examples__+--   >>> randomDoubleSinglePass (1, 0.003) (mkRDGen 145)+--   (0.503, {146, rdIntsPrime})+--   >>> randomDoubleSinglePass (0, 0) (mkRDGen 143)+--   (0, {143, rdIntsPrime})+--   >>> randomDoubleSinglePass (-1, 0) (mkRDGen 143)+--   (0, {143, rdIntsPrime})+randomDoubleSinglePass :: (Int, Double) -> RDGen -> (Double, RDGen)+randomDoubleSinglePass (0, currentDouble) rng = (currentDouble, rng)+randomDoubleSinglePass (decimalPlace, currentDouble) rng = do+  let randomDigit = getIntByIndex (getIntByIndex (index rng) (rngTable rng)) (randomizeList [0 .. 9])+  randomDoubleSinglePass+    ( decimalPlace - 1,+      currentDouble + (fromIntegral randomDigit / (10 ^ decimalPlace))+    )+    (RDGen {index = index rng + 1, rngTable = rngTable rng})
+ src/RealDice/Util.hs view
@@ -0,0 +1,9 @@+-- | This module re-exports utility modules.+--   At the time of writing, this just includes modules to deal with prime+--   numbers+module RealDice.Util+  ( module RealDice.Util.Prime,+  )+where++import RealDice.Util.Prime
+ src/RealDice/Util/Prime.hs view
@@ -0,0 +1,31 @@+-- | Module for finding the greatest prime number that is less than or equal to+--   a given number+module RealDice.Util.Prime (greatestPrimeNotGreaterThan) where++import Data.Numbers.Primes (isPrime)++-- | Returns the greatest prime number that is not greater than the given number++-- | Returns 1 if called with the number 1++-- | Returns 0 if called with a number lower than 1++-- | See RealDice.Generate.RawData for reasons for use in this package++-- | ==== __Examples__+--   >>> greatestPrimeNotGreaterThan 10+--   7+--   >>> greatestPrimeNotGreaterThan 1024+--   1019+--   >>> greatestPrimeNotGreaterThan 1+--   1+--   >>> greatestPrimeNotGreaterThan 0+--   0+--   >>> greatestPrimeNotGreaterThan -1024+--   0+greatestPrimeNotGreaterThan :: Int -> Int+greatestPrimeNotGreaterThan n+  | n < 1 = 0+  | n == 1 = 1+  | isPrime n = n+  | otherwise = greatestPrimeNotGreaterThan (n - 1)
+ test/Main.hs view
@@ -0,0 +1,45 @@+module Main (main) where++import RealDice.CoinSpec (doesnt_give_same_result_10_times)+import RealDice.DieSpec (returns_many_unique_rolls)+import RealDice.RNGSpec (returns_many_unique_integers)+import RealDice.Util.PrimeSpec (next_largest_prime_is_larger_than_input, result_is_less_than_or_equal_to_input, result_is_prime)+import TestCheck (check)++-- | Run the test suite++-- | Currently this consists of QuickCheck tests, along with a guard that will+--   cause the test suite to fail if any of the individual tests fail+main :: IO ()+main = do+  putStrLn "Running test suite!"++  putStrLn "Testing RealDice.Util.Prime..."++  putStrLn "...greatestPrimeNotGreaterThan..."+  putStrLn "...returns a prime result:"+  check result_is_prime+  putStrLn "...returns a result less than or equal to the input:"+  check result_is_less_than_or_equal_to_input+  putStrLn "...returns the largest possible result:"+  check next_largest_prime_is_larger_than_input++  putStrLn "Testing RealDice.CoinSpec..."++  putStrLn "..flipCoin..."+  putStrLn "...doesn't give the same result 10 times in a row:"+  check doesnt_give_same_result_10_times++  putStrLn "Testing RealDice.RNGSpec..."++  putStrLn "..randomIntR..."+  putStrLn "...returns many unique integers:"+  check returns_many_unique_integers++  putStrLn "Testing RealDice.DieSpec..."++  putStrLn "..roll1d..."+  putStrLn "...returns many unique rolls:"+  check returns_many_unique_rolls++  putStrLn "All tests pass!"
+ test/RealDice/CoinSpec.hs view
@@ -0,0 +1,29 @@+{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}++{-# HLINT ignore "Use camelCase" #-}+module RealDice.CoinSpec (doesnt_give_same_result_10_times) where++import Control.Monad.State+import Data.List.Extra+import RealDice.Coin (CoinGen, flipCoin, mkCoinGen)+import Test.QuickCheck++data CoinState where+  CoinState :: {generator :: CoinGen} -> CoinState++generateFlips :: Int -> [Bool]+generateFlips n =+  evalState+    (generateFlipsSinglePass 10 [])+    (CoinState (mkCoinGen n))++generateFlipsSinglePass :: Int -> [Bool] -> State CoinState [Bool]+generateFlipsSinglePass 0 flips = return flips+generateFlipsSinglePass i flips = do+  coinSt <- get+  let (randomInteger, gen') = flipCoin (generator coinSt)+  put CoinState {generator = gen'}+  generateFlipsSinglePass (i - 1) (randomInteger : flips)++doesnt_give_same_result_10_times :: Int -> Property+doesnt_give_same_result_10_times n = n > 0 ==> not (allSame (generateFlips n))
+ test/RealDice/DieSpec.hs view
@@ -0,0 +1,37 @@+{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}++{-# HLINT ignore "Use camelCase" #-}+module RealDice.DieSpec+  ( returns_many_unique_rolls,+    returns_0_for_inputs_under_1,+  )+where++import Control.Monad.State+import RealDice.Die (DieGen, mkDieGen, roll1d)+import Test.QuickCheck++data DieSt where+  DieSt :: {generator :: DieGen} -> DieSt++generateRolls :: Int -> [Int]+generateRolls n =+  evalState (generateRollsSinglePass 10 []) (DieSt (mkDieGen n))++generateRollsSinglePass :: Int -> [Int] -> State DieSt [Int]+generateRollsSinglePass 0 generatedRolls = return generatedRolls+generateRollsSinglePass i generatedRolls = do+  randomSt <- get+  let (randomInteger, gen') = roll1d 1000 (generator randomSt)+  put DieSt {generator = gen'}+  generateRollsSinglePass (i - 1) (randomInteger : generatedRolls)++returns_many_unique_rolls :: Int -> Property+returns_many_unique_rolls n =+  n+    > 0+    ==> head (generateRolls n)+      `notElem` tail (generateRolls n)++returns_0_for_inputs_under_1 :: Int -> Property+returns_0_for_inputs_under_1 n = n < 1 ==> head (generateRolls n) == 0
+ test/RealDice/RNGSpec.hs view
@@ -0,0 +1,82 @@+{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}++{-# HLINT ignore "Use camelCase" #-}+module RealDice.RNGSpec+  ( returns_many_unique_integers,+    returns_many_unique_rolls,+    returns_0_for_inputs_under_1,+    returns_many_unique_floats,+    returns_floats_between_0_and_1,+    returns_many_unique_doubles,+    returns_doubles_between_0_and_1,+  )+where++import Control.Monad.State+import RealDice.DieSpec (returns_0_for_inputs_under_1, returns_many_unique_rolls)+import RealDice.RNG (RDGen, mkRDGen, randomDouble, randomFloat, randomIntR)+import Test.QuickCheck++data RandomState where+  RandomState :: {generator :: RDGen} -> RandomState++generateRandomNumbers :: Int -> [Int]+generateRandomNumbers n =+  evalState (generateRandomNumbersSinglePass 10 []) (RandomState (mkRDGen n))++generateRandomNumbersSinglePass :: Int -> [Int] -> State RandomState [Int]+generateRandomNumbersSinglePass 0 generatedNumbers = return generatedNumbers+generateRandomNumbersSinglePass i generatedNumbers = do+  randomSt <- get+  let (randomInteger, gen') = randomIntR (0, 1000) (generator randomSt)+  put RandomState {generator = gen'}+  generateRandomNumbersSinglePass (i - 1) (randomInteger : generatedNumbers)++returns_many_unique_integers :: Int -> Property+returns_many_unique_integers n =+  n > 0 ==>+    head (generateRandomNumbers n) `notElem` tail (generateRandomNumbers n)++generateRandomFloats :: Int -> [Float]+generateRandomFloats n =+  evalState (generateRandomFloatsSinglePass 10 []) (RandomState (mkRDGen n))++generateRandomFloatsSinglePass :: Int -> [Float] -> State RandomState [Float]+generateRandomFloatsSinglePass 0 generatedNumbers = return generatedNumbers+generateRandomFloatsSinglePass i generatedNumbers = do+  randomSt <- get+  let (randomFloat', gen') = randomFloat 4 (generator randomSt)+  put RandomState {generator = gen'}+  generateRandomFloatsSinglePass (i - 1) (randomFloat' : generatedNumbers)++returns_many_unique_floats :: Int -> Property+returns_many_unique_floats n =+  n > 0 ==>+    head (generateRandomFloats n) `notElem` tail (generateRandomFloats n)++returns_floats_between_0_and_1 :: Int -> Property+returns_floats_between_0_and_1 n =+  n > 0 ==>+    all (\x -> x >= 0 && x <= 1) (generateRandomFloats n)++generateRandomDoubles :: Int -> [Double]+generateRandomDoubles n =+  evalState (generateRandomDoublesSinglePass 10 []) (RandomState (mkRDGen n))++generateRandomDoublesSinglePass :: Int -> [Double] -> State RandomState [Double]+generateRandomDoublesSinglePass 0 generatedDoubles = return generatedDoubles+generateRandomDoublesSinglePass i generatedDoubles = do+  randomSt <- get+  let (randomDouble', gen') = randomDouble 4 (generator randomSt)+  put RandomState {generator = gen'}+  generateRandomDoublesSinglePass (i - 1) (randomDouble' : generatedDoubles)++returns_many_unique_doubles :: Int -> Property+returns_many_unique_doubles n =+  n > 0 ==>+    head (generateRandomDoubles n) `notElem` tail (generateRandomDoubles n)++returns_doubles_between_0_and_1 :: Int -> Property+returns_doubles_between_0_and_1 n =+  n > 0 ==>+    all (\x -> x >= 0 && x <= 1) (generateRandomDoubles n)
+ test/RealDice/Util/PrimeSpec.hs view
@@ -0,0 +1,35 @@+{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}++{-# HLINT ignore "Use camelCase" #-}+module RealDice.Util.PrimeSpec+  ( result_is_less_than_or_equal_to_input,+    result_is_prime,+    next_largest_prime_is_larger_than_input,+    inputs_lower_than_1_return_0,+    result_equals_result_from_equivalent_function,+  )+where++import Data.Numbers.Primes (isPrime)+import RealDice.Util.Prime (greatestPrimeNotGreaterThan)+import Test.QuickCheck++result_is_prime :: Int -> Property+result_is_prime n = n > 1 ==> isPrime (greatestPrimeNotGreaterThan n)++result_is_less_than_or_equal_to_input :: Int -> Property+result_is_less_than_or_equal_to_input n =+  n > 1 ==> greatestPrimeNotGreaterThan n <= n++next_largest_prime_is_larger_than_input :: Int -> Property+next_largest_prime_is_larger_than_input n = do+  let result = greatestPrimeNotGreaterThan n+  n > 1 ==> n < head (filter isPrime [result + 1, result + 2 ..])++inputs_lower_than_1_return_0 :: Int -> Property+inputs_lower_than_1_return_0 n = n < 1 ==> greatestPrimeNotGreaterThan n == 0++result_equals_result_from_equivalent_function :: Int -> Property+result_equals_result_from_equivalent_function n =+  n > 1 ==>+    greatestPrimeNotGreaterThan n == head (filter isPrime [n, n - 1 ..])
+ test/TestCheck.hs view
@@ -0,0 +1,36 @@+module TestCheck (isPass, check) where++import Control.Monad qualified+import System.Exit+import Test.QuickCheck++-- | Run a QuickCheck test and exit with a failure if it fails++-- | This is used so that the testing suite will fail if any QuickCheck tests+--   fail++-- | ==== __Examples__+--   >>> check (1 == 1)+--   ...+--   >>> check (1 == 2)+--   ...+--   ...exit with failure+check :: (Testable prop) => prop -> IO ()+check prop = do+  result <- quickCheckResult prop+  Control.Monad.unless (isPass result) exitFailure++-- | Returns True if a test passes, and False otherwise++-- | ==== __Examples__+--   >>> isPass (Success {})+--   True+--   >>> isPass (GaveUp {})+--   False+--   >>> isPass (Failure {})+--   False+--   >>> isPass (_ {})+--   False+isPass :: Result -> Bool+isPass (Success {}) = True+isPass _ = False