diff --git a/random.cabal b/random.cabal index d5bceae9..92fdc937 100644 --- a/random.cabal +++ b/random.cabal @@ -137,12 +137,14 @@ test-suite doctests default-language: Haskell2010 build-depends: base, - doctest >=0.15 && <0.19, - mwc-random >=0.13 && <0.16, - primitive >=0.6 && <0.8, - random, - unliftio >=0.2 && <0.3, - vector >= 0.10 && <0.14 + doctest >=0.15 && <0.19 + if impl(ghc >= 8.2) && impl(ghc < 8.10) + build-depends: + mwc-random >=0.13 && <0.16, + primitive >=0.6 && <0.8, + random, + unliftio >=0.2 && <0.3, + vector >= 0.10 && <0.14 test-suite spec type: exitcode-stdio-1.0 diff --git a/src/System/Random.hs b/src/System/Random.hs index 7cebb94d..6efd9fcd 100644 --- a/src/System/Random.hs +++ b/src/System/Random.hs @@ -219,12 +219,23 @@ class Random a where -- 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. In case when a lawful range is desired `uniformR` should be used + -- 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. {-# INLINE randomR #-} randomR :: RandomGen g => (a, a) -> g -> (a, g) diff --git a/test/doctests.hs b/test/doctests.hs index 1866dde3..001b3376 100644 --- a/test/doctests.hs +++ b/test/doctests.hs @@ -10,6 +10,7 @@ main = doctest ["src"] #else +-- Also disabled in cabal file. -- TODO: fix doctest support main :: IO () main = putStrLn "\nDoctests are not supported for older ghc version\n"