Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
random
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
random
Commits
4aa86029
Commit
4aa86029
authored
6 years ago
by
Carter Schonwald
Browse files
Options
Downloads
Patches
Plain Diff
poking at having the semi compatible 1.2 version
parent
22a2a16b
Branches
v1.2.0
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
random.cabal
+2
-2
2 additions, 2 deletions
random.cabal
src/System/Random.hs
+17
-16
17 additions, 16 deletions
src/System/Random.hs
with
19 additions
and
18 deletions
random.cabal
+
2
−
2
View file @
4aa86029
...
...
@@ -75,9 +75,9 @@ library
-- other-extensions:
-- Other library packages from which modules are imported.
build-depends: base >=4.8 && <4.1
2
build-depends: base >=4.8 && <4.1
4
,ghc-prim
,entropy == 0.
3
.*
,entropy == 0.
4
.*
,numeric-extras == 0.1.*
,primitive >= 0.6
,transformers >= 0.2
...
...
This diff is collapsed.
Click to expand it.
src/System/Random.hs
+
17
−
16
View file @
4aa86029
...
...
@@ -66,8 +66,9 @@ module System.Random
-- * Random values of various types
,
Random
(
random
,
randomR
,
randoms
,
randomRs
,
randomIO
,
randomRIO
)
randoms
,
randomRs
--randomIO, randomRIO
)
-- * References
-- $references
...
...
@@ -83,17 +84,17 @@ import Foreign.C.Types
--
import Data.Ratio ( numerator, denominator )
import
Data.Ratio
(
numerator
,
denominator
)
--
import Data.Char ( isSpace, chr, ord )
--
import System.IO.Unsafe ( unsafePerformIO )
--
import Data.IORef ( IORef, newIORef, readIORef, writeIORef )
import
Data.Char
(
isSpace
,
chr
,
ord
)
import
System.IO.Unsafe
(
unsafePerformIO
)
import
Data.IORef
(
IORef
,
newIORef
,
readIORef
,
writeIORef
)
#
if
MIN_VERSION_base
(
4
,
6
,
0
)
--
import Data.IORef ( atomicModifyIORef' )
import
Data.IORef
(
atomicModifyIORef'
)
#
else
import
Data.IORef
(
atomicModifyIORef
)
#
endif
--
import Numeric ( readDec )
import
Numeric
(
readDec
)
#
ifdef
__GLASGOW_HASKELL__
import
GHC.Exts
(
build
)
...
...
@@ -134,7 +135,7 @@ class RandomGen g where
--
-- * If @(a,b) = 'genRange' g@, then @a < b@.
--
-- * 'genRange' always returns a pair of defined '
Int
's.
-- * 'genRange' always returns a pair of defined '
Word64
's.
--
-- The second condition ensures that 'genRange' cannot examine its
-- argument, and hence the value it returns can be determined only by the
...
...
@@ -143,7 +144,7 @@ class RandomGen g where
-- being concerned that the generator returned by (say) 'next' might have
-- a different range to the generator passed to 'next'.
--
-- The default definition spans the full range of '
Int
'.
-- The default definition spans the full range of '
Word64
'.
genRange
::
g
->
(
Word64
,
Word64
)
-- default method
...
...
@@ -294,12 +295,12 @@ class Random a where
-- | A variant of 'randomR' that uses the global random number generator
-- (see "System.Random#globalrng").
randomRIO
::
(
a
,
a
)
->
IO
a
--
randomRIO :: (a,a) -> IO a
--randomRIO range = getStdRandom (randomR range)
-- | A variant of 'random' that uses the global random number generator
-- (see "System.Random#globalrng").
randomIO
::
IO
a
--
randomIO :: IO a
--randomIO = getStdRandom random
-- | Produce an infinite list-equivalent of random values.
...
...
@@ -354,10 +355,10 @@ instance Random CIntMax where randomR = randomIvalIntegral; random = randomBo
instance
Random
CUIntMax
where
randomR
=
randomIvalIntegral
;
random
=
randomBounded
instance
Random
Char
where
--
randomR (a,b) g =
--
case (randomIvalInteger (toInteger (ord a), toInteger (ord b)) g) of
--
(x,g') -> (chr x, g')
--
random g = randomR (minBound,maxBound) g
randomR
(
a
,
b
)
g
=
case
(
randomIvalInteger
(
toInteger
(
ord
a
),
toInteger
(
ord
b
))
g
)
of
(
x
,
g'
)
->
(
chr
x
,
g'
)
random
g
=
randomR
(
minBound
,
maxBound
)
g
instance
Random
Bool
where
randomR
(
a
,
b
)
g
=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment