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.

  1. uniformListM :: (StatefulGen g m, Uniform a) => Int -> g -> m [a]

    random System.Random.Stateful

    Generates a list of pseudo-random values.

    Examples

    >>> import System.Random.Stateful
    
    >>> let pureGen = mkStdGen 137
    
    >>> g <- newIOGenM pureGen
    
    >>> uniformListM 10 g :: IO [Bool]
    [True,True,True,True,False,True,True,False,False,False]
    

  2. uniformM :: (Uniform a, StatefulGen g m) => g -> m a

    random System.Random.Stateful

    Generates a value uniformly distributed over all possible values of that type. There is a default implementation via Generic:

    >>> :set -XDeriveGeneric -XDeriveAnyClass
    
    >>> import GHC.Generics (Generic)
    
    >>> import System.Random.Stateful
    
    >>> data MyBool = MyTrue | MyFalse deriving (Show, Generic, Finite, Uniform)
    
    >>> data Action = Code MyBool | Eat (Maybe Bool) | Sleep deriving (Show, Generic, Finite, Uniform)
    
    >>> gen <- newIOGenM (mkStdGen 42)
    
    >>> uniformListM 10 gen :: IO [Action]
    [Code MyTrue,Code MyTrue,Eat Nothing,Code MyFalse,Eat (Just False),Eat (Just True),Eat Nothing,Eat (Just False),Sleep,Code MyFalse]
    

  3. uniformRM :: (UniformRange a, StatefulGen g m) => (a, a) -> g -> m a

    random System.Random.Stateful

    Generates a value uniformly distributed over the provided range, which is interpreted as inclusive in the lower and upper bound.

    • uniformRM (1 :: Int, 4 :: Int) generates values uniformly from the set <math>
    • uniformRM (1 :: Float, 4 :: Float) generates values uniformly from the set <math>
    The following law should hold to make the function always defined:
    uniformRM (a, b) = uniformRM (b, a)
    

  4. uniformShortByteString :: StatefulGen g m => Int -> g -> m ShortByteString

    random System.Random.Stateful

    uniformShortByteString n g generates a ShortByteString of length n filled with pseudo-random bytes.

  5. uniformViaFiniteM :: (StatefulGen g m, Generic a, GFinite (Rep a)) => g -> m a

    random System.Random.Stateful

    A definition of Uniform for Finite types. If your data has several fields of sub-Word cardinality, this instance may be more efficient than one, derived via Generic and GUniform.

    >>> :set -XDeriveGeneric -XDeriveAnyClass
    
    >>> import GHC.Generics (Generic)
    
    >>> import System.Random.Stateful
    
    >>> data Triple = Triple Word8 Word8 Word8 deriving (Show, Generic, Finite)
    
    >>> instance Uniform Triple where uniformM = uniformViaFiniteM
    
    >>> gen <- newIOGenM (mkStdGen 42)
    
    >>> uniformListM 5 gen :: IO [Triple]
    [Triple 60 226 48,Triple 234 194 151,Triple 112 96 95,Triple 51 251 15,Triple 6 0 208]
    

  6. uniformWord16 :: StatefulGen g m => g -> m Word16

    random System.Random.Stateful

    Generates a Word16 that is uniformly distributed over the entire Word16 range. The default implementation extracts a Word16 from uniformWord32.

  7. uniformWord32 :: StatefulGen g m => g -> m Word32

    random System.Random.Stateful

    Generates a Word32 that is uniformly distributed over the entire Word32 range. The default implementation extracts a Word32 from uniformWord64.

  8. uniformWord32R :: StatefulGen g m => Word32 -> g -> m Word32

    random System.Random.Stateful

    uniformWord32R upperBound g generates a Word32 that is uniformly distributed over the range [0, upperBound].

  9. uniformWord64 :: StatefulGen g m => g -> m Word64

    random System.Random.Stateful

    Generates a Word64 that is uniformly distributed over the entire Word64 range. The default implementation combines two Word32 from uniformWord32 into one Word64.

  10. uniformWord64R :: StatefulGen g m => Word64 -> g -> m Word64

    random System.Random.Stateful

    uniformWord64R upperBound g generates a Word64 that is uniformly distributed over the range [0, upperBound].

Page 413 of many | Previous | Next