-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate RandomGenM
in favor of a more powerful FrozenGen
#149
Conversation
618b5e4
to
2fba77c
Compare
That's great! It provides direct correspondence between
|
Yes, that seems like a good feature to me. |
2fba77c
to
66f0f10
Compare
14ce716
to
c7eb9bd
Compare
* Addition of `modifyGen` totally removes the need for `RandomGenM`, because every frozen generator that is a wrapper around `RandomGen` also derives an instance for `RandomGen` * Add `splitMutableM` and `splitFrozenM` * Avoid redundant freeze in `withMutableGen_`
* Also add some laws for `FrozenGen` and `ThawedGen` This split of `FrozenGen` type class into two is needed because some mutable generators can't be cloned, becase the mutable state is stored in the monad they are running in, rather than in the mutable generator itself.
c7eb9bd
to
bc58313
Compare
@Shimuuar I've added |
Also fixup example with `FrozenGen` instance in haddock
# 1.3.0 * Improve floating point value generation and avoid degenerate cases: [#172](haskell/random#172) * Add `Uniform` instance for `Maybe` and `Either`: [#167](haskell/random#167) * Add `Seed`, `SeedGen`, `seedSize`, `seedSizeProxy`, `mkSeed` and `unSeed`: [#162](haskell/random#162) * Add `mkSeedFromByteString`, `unSeedToByteString`, `withSeed`, `withSeedM`, `withSeedFile`, `seedGenTypeName`, `nonEmptyToSeed`, `nonEmptyFromSeed`, `withSeedM`, `withSeedMutableGen` and `withSeedMutableGen_` * Add `SplitGen` and `splitGen`: [#160](haskell/random#160) * Add `unifromShuffleList` and `unifromShuffleListM`: [#140](haskell/random#140) * Add `uniformWordR`: [#140](haskell/random#140) * Add `mkStdGen64`: [#155](haskell/random#155) * Add `uniformListRM`, `uniformList`, `uniformListR`, `uniforms` and `uniformRs`: [#154](haskell/random#154) * Add compatibility with recently added `ByteArray` to `base`: [#153](haskell/random#153) * Switch to using `ByteArray` for type class implementation instead of `ShortByteString` * Add `unsafeUniformFillMutableByteArray` to `RandomGen` and a helper function `defaultUnsafeUniformFillMutableByteArray` that makes implementation for most instances easier. * Add `uniformByteArray`, `uniformByteString` and `uniformFillMutableByteArray` * Deprecate `genByteString` in favor of `uniformByteString` * Add `uniformByteArrayM` to `StatefulGen` * Add `uniformByteStringM` and `uniformShortByteStringM` * Deprecate `System.Random.Stateful.uniformShortByteString` in favor of `uniformShortByteStringM` for consistent naming and a future plan of removing it from `StatefulGen` type class * Add a pure `System.Random.uniformShortByteString` generating function. * Deprecate `genShortByteString` in favor of `System.Random.uniformShortByteString` * Expose a helper function `fillByteArrayST`, that can be used for defining implementation for `uniformByteArrayM` * Deprecate `genShortByteStringST` and `genShortByteStringIO` in favor of `fillByteArrayST` * Improve `FrozenGen` interface: [#149](haskell/random#149) * Move `thawGen` from `FreezeGen` into the new `ThawGen` type class. Fixes an issue with an unlawful instance of `StateGen` for `FreezeGen`. * Add `modifyGen` and `overwriteGen` to the `FrozenGen` type class * Switch `splitGenM` to use `SplitGen` and `FrozenGen` instead of deprecated `RandomGenM` * Add `splitMutableGenM` * Switch `randomM` and `randomRM` to use `FrozenGen` instead of `RandomGenM` * Deprecate `RandomGenM` in favor of a more powerful `FrozenGen` * Add `isInRangeOrd` and `isInRangeEnum` that can be used for implementing `isInRange`: [#148](haskell/random#148) * Add `isInRange` to `UniformRange`: [#78](haskell/random#78) * Add default implementation for `uniformRM` using `Generics`: [#92](haskell/random#92)
modifyGen
totally removes the need forRandomGenM
, because every frozen generator that is anetwtype
wrapper aroundRandomGen
also derives an instance forRandomGen
splitMutableGen
andsplitGen
ThawedGen
and movethawGen
into that type class to combat current unlawfulFrozenGen
instance forStateGen