Hoogle Search

Within LTS Haskell 22.20 (ghc-9.6.4)

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

  1. 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.

  2. 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.

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

    tf-random System.Random.TF.Instances

    No documentation available.

  4. 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
    

  5. 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.

  6. 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
    

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

    tf-random System.Random.TF.Instances

    No documentation available.

  8. gRandomR :: forall a g . (ADTRecord a, Constraints a Random, RandomGen g) => (a, a) -> g -> (a, g)

    one-liner-instances System.Random.OneLiner

    randomR implemented by sequencing randomR between all components Requires the type to have only a single constructor.

  9. gRandomRIO :: forall a . (ADTRecord a, Constraints a Random) => (a, a) -> IO a

    one-liner-instances System.Random.OneLiner

    randomRIO implemented by calling gRandomR on the global seed.

  10. gRandomRIOSum :: forall a . (ADT a, Constraints a Random) => (a, a) -> IO a

    one-liner-instances System.Random.OneLiner

    randomRIO implemented by calling gRandomRSum on the global seed. If given a range of items made with different constructors, will be error!

Page 1 of 2 | Next