39f4632
cabal-version:      >=1.10
39f4632
name:               random
39f4632
version:            1.2.0
39f4632
x-revision: 5
39f4632
license:            BSD3
39f4632
license-file:       LICENSE
39f4632
maintainer:         core-libraries-committee@haskell.org
39f4632
bug-reports:        https://github.com/haskell/random/issues
39f4632
synopsis:           Pseudo-random number generation
39f4632
description:
39f4632
    This package provides basic pseudo-random number generation, including the
39f4632
    ability to split random number generators.
39f4632
    .
39f4632
    == "System.Random": pure pseudo-random number interface
39f4632
    .
39f4632
    In pure code, use 'System.Random.uniform' and 'System.Random.uniformR' from
39f4632
    "System.Random" to generate pseudo-random numbers with a pure pseudo-random
39f4632
    number generator like 'System.Random.StdGen'.
39f4632
    .
39f4632
    As an example, here is how you can simulate rolls of a six-sided die using
39f4632
    'System.Random.uniformR':
39f4632
    .
39f4632
    >>> let roll = uniformR (1, 6)        :: RandomGen g => g -> (Word, g)
39f4632
    >>> let rolls = unfoldr (Just . roll) :: RandomGen g => g -> [Word]
39f4632
    >>> let pureGen = mkStdGen 42
39f4632
    >>> take 10 (rolls pureGen)           :: [Word]
39f4632
    [1,1,3,2,4,5,3,4,6,2]
39f4632
    .
39f4632
    See "System.Random" for more details.
39f4632
    .
39f4632
    == "System.Random.Stateful": monadic pseudo-random number interface
39f4632
    .
39f4632
    In monadic code, use 'System.Random.Stateful.uniformM' and
39f4632
    'System.Random.Stateful.uniformRM' from "System.Random.Stateful" to generate
39f4632
    pseudo-random numbers with a monadic pseudo-random number generator, or
39f4632
    using a monadic adapter.
39f4632
    .
39f4632
    As an example, here is how you can simulate rolls of a six-sided die using
39f4632
    'System.Random.Stateful.uniformRM':
39f4632
    .
39f4632
    >>> let rollM = uniformRM (1, 6)                 :: StatefulGen g m => g -> m Word
39f4632
    >>> let pureGen = mkStdGen 42
39f4632
    >>> runStateGen_ pureGen (replicateM 10 . rollM) :: [Word]
39f4632
    [1,1,3,2,4,5,3,4,6,2]
39f4632
    .
39f4632
    The monadic adapter 'System.Random.Stateful.runGenState_' is used here to lift
39f4632
    the pure pseudo-random number generator @pureGen@ into the
39f4632
    'System.Random.Stateful.StatefulGen' context.
39f4632
    .
39f4632
    The monadic interface can also be used with existing monadic pseudo-random
39f4632
    number generators. In this example, we use the one provided in the
39f4632
    <https://hackage.haskell.org/package/mwc-random mwc-random> package:
39f4632
    .
39f4632
    >>> import System.Random.MWC as MWC
39f4632
    >>> let rollM = uniformRM (1, 6)       :: StatefulGen g m => g -> m Word
39f4632
    >>> monadicGen <- MWC.create
39f4632
    >>> replicateM 10 (rollM monadicGen) :: IO [Word]
39f4632
    [2,3,6,6,4,4,3,1,5,4]
39f4632
    .
39f4632
    See "System.Random.Stateful" for more details.
39f4632

39f4632
category:           System
39f4632
build-type:         Simple
39f4632
extra-source-files:
39f4632
    README.md
39f4632
    CHANGELOG.md
39f4632
tested-with:         GHC == 7.10.2
39f4632
                   , GHC == 7.10.3
39f4632
                   , GHC == 8.0.2
39f4632
                   , GHC == 8.2.2
39f4632
                   , GHC == 8.4.3
39f4632
                   , GHC == 8.4.4
39f4632
                   , GHC == 8.6.3
39f4632
                   , GHC == 8.6.4
39f4632
                   , GHC == 8.6.5
39f4632
                   , GHC == 8.8.1
39f4632
                   , GHC == 8.8.2
39f4632
                   , GHC == 8.10.1
39f4632

39f4632
source-repository head
39f4632
    type:     git
39f4632
    location: https://github.com/haskell/random.git
39f4632

39f4632

39f4632
library
39f4632
    exposed-modules:
39f4632
        System.Random
39f4632
        System.Random.Internal
39f4632
        System.Random.Stateful
39f4632

39f4632
    hs-source-dirs:   src
39f4632
    default-language: Haskell2010
39f4632
    ghc-options:
39f4632
        -Wall
39f4632
    if impl(ghc >= 8.0)
39f4632
        ghc-options:
39f4632
            -Wincomplete-record-updates -Wincomplete-uni-patterns
39f4632

39f4632
    build-depends:
39f4632
        base >=4.8 && <5,
39f4632
        bytestring >=0.10.4 && <0.12,
39f4632
        deepseq >=1.1 && <2,
39f4632
        mtl >=2.2 && <2.3,
39f4632
        splitmix >=0.1 && <0.2
39f4632
    if impl(ghc < 8.0)
39f4632
       build-depends:
39f4632
           transformers
39f4632

39f4632
test-suite legacy-test
39f4632
    type:             exitcode-stdio-1.0
39f4632
    main-is:          Legacy.hs
39f4632
    hs-source-dirs:   test-legacy
39f4632
    other-modules:
39f4632
        T7936
39f4632
        TestRandomIOs
39f4632
        TestRandomRs
39f4632
        Random1283
39f4632
        RangeTest
39f4632

39f4632
    default-language: Haskell2010
39f4632
    ghc-options:      -with-rtsopts=-M4M
39f4632
    if impl(ghc >= 8.0)
39f4632
        ghc-options:
39f4632
            -Wno-deprecations
39f4632
    build-depends:
39f4632
        base -any,
39f4632
        containers >=0.5 && <0.7,
39f4632
        random -any
39f4632

39f4632
test-suite doctests
39f4632
    type:             exitcode-stdio-1.0
39f4632
    main-is:          doctests.hs
39f4632
    hs-source-dirs:   test
39f4632
    default-language: Haskell2010
39f4632
    build-depends:
39f4632
        base -any,
39f4632
        doctest >=0.15 && <0.19,
39f4632
        mwc-random >=0.13 && <0.16,
39f4632
        primitive >=0.6 && <0.8,
39f4632
        random -any,
39f4632
        unliftio >=0.2 && <0.3,
39f4632
        vector >= 0.10 && <0.14
39f4632

39f4632
test-suite spec
39f4632
    type:             exitcode-stdio-1.0
39f4632
    main-is:          Spec.hs
39f4632
    hs-source-dirs:   test
39f4632
    other-modules:
39f4632
        Spec.Range
39f4632
        Spec.Run
39f4632

39f4632
    default-language: Haskell2010
39f4632
    ghc-options:      -Wall
39f4632
    build-depends:
39f4632
        base -any,
39f4632
        bytestring -any,
39f4632
        random -any,
39f4632
        smallcheck >=1.2 && <1.3,
39f4632
        tasty >=1.0 && <1.5,
39f4632
        tasty-smallcheck >=0.8 && <0.9,
39f4632
        tasty-expected-failure -any,
39f4632
        tasty-hunit >=0.10 && <0.11
39f4632

39f4632
benchmark legacy-bench
39f4632
    type:             exitcode-stdio-1.0
39f4632
    main-is:          SimpleRNGBench.hs
39f4632
    hs-source-dirs:   bench-legacy
39f4632
    other-modules:    BinSearch
39f4632
    default-language: Haskell2010
39f4632
    ghc-options:
39f4632
        -Wall -O2 -threaded -rtsopts -with-rtsopts=-N
39f4632
    if impl(ghc >= 8.0)
39f4632
        ghc-options:
39f4632
            -Wno-deprecations
39f4632

39f4632
    build-depends:
39f4632
        base -any,
39f4632
        random -any,
39f4632
        rdtsc -any,
39f4632
        split >=0.2 && <0.3,
39f4632
        time >=1.4 && <1.11
39f4632

39f4632
benchmark bench
39f4632
    type:             exitcode-stdio-1.0
39f4632
    main-is:          Main.hs
39f4632
    hs-source-dirs:   bench
39f4632
    default-language: Haskell2010
39f4632
    ghc-options:      -Wall -O2
39f4632
    build-depends:
39f4632
        base -any,
39f4632
        gauge >=0.2.3 && <0.3,
39f4632
        mtl,
39f4632
        random -any,
39f4632
        splitmix >=0.1 && <0.2