Hoogle Search

Within LTS Haskell 22.18 (ghc-9.6.4)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. class RandomGen g

    tf-random System.Random.TF.Gen

    Alternative RandomGen class with a modified next operation, and added splitn and level operations. Using the generator requires that no more than one operation is called on the same generator state, as the implementation does not guarantee pseudorandomness otherwise. As an exception, calling splitn many times on the same generator state is allowed as long as the 'bits' argument is the same for all the calls.

  2. randomIO :: (Random a, MonadIO m) => m a

    random System.Random

    A variant of randomM that uses the global pseudo-random number generator globalStdGen.

    >>> import Data.Int
    
    >>> randomIO :: IO Int32
    -1580093805
    
    This function is equivalent to getStdRandom random and is included in this interface for historical reasons and backwards compatibility. It is recommended to use uniformM instead, possibly with the globalStdGen if relying on the global state is acceptable.
    >>> import System.Random.Stateful
    
    >>> uniformM globalStdGen :: IO Int32
    -1649127057
    

  3. randomR :: (Random a, RandomGen g) => (a, a) -> g -> (a, g)

    random System.Random

    Takes a range (lo,hi) and a pseudo-random number generator g, and returns a pseudo-random value uniformly distributed over the closed interval [lo,hi], together with a new generator. It is unspecified what happens if lo>hi, but usually the values will simply get swapped.

    >>> let gen = mkStdGen 2021
    
    >>> fst $ randomR ('a', 'z') gen
    't'
    
    >>> fst $ randomR ('z', 'a') gen
    't'
    
    For continuous types there is no requirement that the values lo and hi are ever produced, but they may be, depending on the implementation and the interval. There is no requirement to follow the Ord instance and the concept of range can be defined on per type basis. For example product types will treat their values independently:
    >>> fst $ randomR (('a', 5.0), ('z', 10.0)) $ mkStdGen 2021
    ('t',6.240232662366563)
    
    In case when a lawful range is desired uniformR should be used instead.

  4. randomR :: (Random a, RandomGen g, UniformRange a) => (a, a) -> g -> (a, g)

    random System.Random

    Takes a range (lo,hi) and a pseudo-random number generator g, and returns a pseudo-random value uniformly distributed over the closed interval [lo,hi], together with a new generator. It is unspecified what happens if lo>hi, but usually the values will simply get swapped.

    >>> let gen = mkStdGen 2021
    
    >>> fst $ randomR ('a', 'z') gen
    't'
    
    >>> fst $ randomR ('z', 'a') gen
    't'
    
    For continuous types there is no requirement that the values lo and hi are ever produced, but they may be, depending on the implementation and the interval. There is no requirement to follow the Ord instance and the concept of range can be defined on per type basis. For example product types will treat their values independently:
    >>> fst $ randomR (('a', 5.0), ('z', 10.0)) $ mkStdGen 2021
    ('t',6.240232662366563)
    
    In case when a lawful range is desired uniformR should be used instead.

  5. randomRIO :: (Random a, MonadIO m) => (a, a) -> m a

    random System.Random

    A variant of randomRM that uses the global pseudo-random number generator globalStdGen

    >>> randomRIO (2020, 2100) :: IO Int
    2040
    
    Similar to randomIO, this function is equivalent to getStdRandom randomR and is included in this interface for historical reasons and backwards compatibility. It is recommended to use uniformRM instead, possibly with the globalStdGen if relying on the global state is acceptable.
    >>> import System.Random.Stateful
    
    >>> uniformRM (2020, 2100) globalStdGen :: IO Int
    2079
    

  6. randomRs :: (Random a, RandomGen g) => (a, a) -> g -> [a]

    random System.Random

    Plural variant of randomR, producing an infinite list of pseudo-random values instead of returning a new generator.

  7. randoms :: (Random a, RandomGen g) => g -> [a]

    random System.Random

    Plural variant of random, producing an infinite list of pseudo-random values instead of returning a new generator.

  8. randomM :: (RandomGenM g r m, Random a) => g -> m a

    random System.Random.Stateful

    Generates a pseudo-random value using monadic interface and Random instance.

    Examples

    >>> import System.Random.Stateful
    
    >>> let pureGen = mkStdGen 137
    
    >>> g <- newIOGenM pureGen
    
    >>> randomM g :: IO Double
    0.5728354935654512
    

  9. randomRM :: (RandomGenM g r m, Random a) => (a, a) -> g -> m a

    random System.Random.Stateful

    Generates a pseudo-random value using monadic interface and Random instance.

    Examples

    >>> import System.Random.Stateful
    
    >>> let pureGen = mkStdGen 137
    
    >>> g <- newIOGenM pureGen
    
    >>> randomRM (1, 100) g :: IO Int
    52
    

  10. randomSourceName :: String

    mwc-random System.Random.MWC.SeedSource

    Name of source of randomness. It should be used in error messages

Page 2 of many | Previous | Next