Hoogle Search
Within LTS Haskell 24.40 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
uniformR :: (RandomGen g, UniformRange a) => (a, a) -> g -> (a, g)random System.Random Generates a value uniformly distributed over the provided range, which is interpreted as inclusive in the lower and upper bound.
- uniformR (1 :: Int, 4 :: Int) generates values uniformly from the set <math>
- uniformR (1 :: Float, 4 :: Float) generates values uniformly from the set <math>
uniformR (a, b) = uniformR (b, a)
This is a pure version of uniformRM.Examples
>>> import System.Random >>> let pureGen = mkStdGen 137 >>> uniformR (1 :: Int, 4 :: Int) pureGen (4,StdGen {unStdGen = SMGen 11285859549637045894 7641485672361121627})-
random System.Random.Stateful The class of types for which a uniformly distributed value can be drawn from all possible values of the type.
-
random System.Random.Stateful The class of types for which a uniformly distributed value can be drawn from a range.
uniformByteStringM :: StatefulGen g m => Int -> g -> m ByteStringrandom System.Random.Stateful Generates a pseudo-random ByteString of the specified size.
uniformDouble01M :: StatefulGen g m => g -> m Doublerandom System.Random.Stateful Generates uniformly distributed Double in the range <math>. Numbers are generated by generating uniform Word64 and dividing it by <math>. It's used to implement UniformRange instance for Double.
uniformDoublePositive01M :: StatefulGen g m => g -> m Doublerandom System.Random.Stateful Generates uniformly distributed Double in the range <math>. Number is generated as <math>. Constant is 1/2 of smallest nonzero value which could be generated by uniformDouble01M.
uniformEnumM :: (Enum a, Bounded a, StatefulGen g m) => g -> m arandom System.Random.Stateful Generates uniformly distributed Enum. One can use it to define a Uniform instance:
data Colors = Red | Green | Blue deriving (Enum, Bounded) instance Uniform Colors where uniformM = uniformEnumM
uniformEnumRM :: (Enum a, StatefulGen g m) => (a, a) -> g -> m arandom System.Random.Stateful Generates uniformly distributed Enum in the given range. One can use it to define a UniformRange instance:
data Colors = Red | Green | Blue deriving (Enum) instance UniformRange Colors where uniformRM = uniformEnumRM inInRange (lo, hi) x = isInRange (fromEnum lo, fromEnum hi) (fromEnum x)
uniformFloat01M :: StatefulGen g m => g -> m Floatrandom System.Random.Stateful Generates uniformly distributed Float in the range <math>. Numbers are generated by generating uniform Word32 and dividing it by <math>. It's used to implement UniformRange instance for Float.
uniformFloatPositive01M :: StatefulGen g m => g -> m Floatrandom System.Random.Stateful Generates uniformly distributed Float in the range <math>. Number is generated as <math>. Constant is 1/2 of smallest nonzero value which could be generated by uniformFloat01M.