Skip to content

Commit

Permalink
Add Uniform instance for Maybe and Either
Browse files Browse the repository at this point in the history
  • Loading branch information
lehins committed Oct 27, 2024
1 parent a20f1c2 commit 6fcb4f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 1.3.0

* Add `Uniform` instance for `Maybe` and `Either`
* Add `SplitGen` and `splitGen`
* Add `shuffleList` and `shuffleListM`: [#140](https://github.com/haskell/random/pull/140)
* Add `mkStdGen64`: [#155](https://github.com/haskell/random/pull/155)
Expand Down
6 changes: 5 additions & 1 deletion src/System/Random/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ import GHC.ST (ST(..))
import GHC.Word
import Numeric.Natural (Natural)
import System.IO.Unsafe (unsafePerformIO)
import System.Random.GFinite (Cardinality(..), GFinite(..))
import System.Random.GFinite (Cardinality(..), GFinite(..), Finite)
import qualified System.Random.SplitMix as SM
import qualified System.Random.SplitMix32 as SM32
import Data.Kind
Expand Down Expand Up @@ -1474,6 +1474,10 @@ instance UniformRange Bool where
{-# INLINE uniformRM #-}
isInRange = isInRangeOrd

instance (Finite a, Uniform a) => Uniform (Maybe a)

instance (Finite a, Uniform a, Finite b, Uniform b) => Uniform (Either a b)

-- | See [Floating point number caveats](System-Random-Stateful.html#fpcaveats).
instance UniformRange Double where
uniformRM (l, h) g
Expand Down

0 comments on commit 6fcb4f5

Please sign in to comment.