- Fix the potential for a crash in
fromListMay
(and hence also in functions that use it, namelyfromList
,weighted
,weightedMay
,uniform
, anduniformMay
). Thanks to @Flupp for pointing out the issue and suggesting a fix. The fix may in theory cause these functions, extremely rarely, to output values different from the old values for the same seed. See https://byorgey.github.io/blog/posts/2024/10/14/MonadRandom-version-bump.html for more information and discussion.
-
Remove instances for deprecated
ErrorT
andListT
transformers -
Allow building with
transformers-0.6
andmtl-2.3.1
-
Drop support for GHC 7.6 and 7.8
-
r1 (18 Dec 2022): require
base >= 4.8
-
r2 (9 Jan 2023): require
random >= 1.0.1
-
r3 (22 Feb 2023): allow
primitive-0.8
-
r4 (12 Oct 2023): allow
primitive-0.9
, test on GHC 9.6 and 9.8
-
StatefulGen
instances forRandT
-
Addition of
RandGen
-
Addition of
withRandGen
andwithRandGen_
-
r1 (28 April 2021): require
base >= 4.6
-
r2 (9 Aug 2021): allow
transformers-compat-0.7
. -
r3 (9 Aug 2022): Test with GHC 9.0-9.4
- Support for
random-1.2
. - Drop support for GHC 7.4, test with GHC 8.10.
- Better error message when total probability sum is negative in fromListMay, weightedMay, weighted
- Only depend on
fail
package when GHC < 8.0.
Re-export System.Random
from Control.Monad.Random.{Lazy,Strict}
and hence also from Control.Monad.Random
.
- Hackage r1: allow
transformers-compat-0.6.x
.
This release has quite a few small additions as well as a big module reorganization. However, thanks to module re-exports, most existing code using the library should continue to work with no changes; the major version bump reflects the large reorganization and my inability to 100% guarantee that existing user code will not break.
The biggest changes that may be of interest to users of the library
include new lazy vs strict variants of the Rand
monad; a new
MonadInterleave
class which is a big improvement over
MonadSplit
; new PrimMonad
instances; and new random selection
functions like weighted
, weightedMay
, uniformMay
, etc.. See
the list below for full details.
Although there was some discussion of generalizing MonadRandom
to
work for a wider range of underlying generators
(see
#26,
#31, and
comments on this blog post),
I decided to punt on that for now. It seems rather complicated and
there
are
already good alternatives so
I decided to keep things simple for this release. I'm still open to
proposals for generalizing future releases.
Changes in 0.5 include:
- Refactor to reflect structure of
mtl
andtransformers
libraries. - Add lazy and strict variants of
RandT
. - Add
MonadRandom
andMonadSplit
instances forListT
. - Add (but do not export)
unRandT
field toRandT
. - Add
MonadCont
,MonadError
,MonadRWS
,PrimMonad
, andMonadFail
instances forRandT
. - Add
evalRandTIO
operation. - Move
fromList
anduniform
operations toControl.Monad.Random.Class
. fromList
now raises an error when the total weight of elements is zero.- Generalize the type of
uniform
to work over anyFoldable
. - Add new operations
weighted
,weightedMay
,fromListMay
, anduniformMay
.weighted
is likefromList
but generalized to work over anyFoldable
. TheMay
variants return aMaybe
result instead of raising an error. - New
MonadInterleave
class for random monads which can interleave random generation usingsplit
. In some ways this is similar toMonadSplit
but much more useful. - Improved documentation.
- Mark
Control.Monad.Random
asTrustworthy
.
- Allow
transformers-0.5
.
- Allow
transformers-compat-0.5
.
- Add
MonadPlus
andAlternative
instances forRandT
.
- Remove unnecessary
Monad m
constraint fromliftRandT
andrunRandT
.
This should again technically require a major version bump, but I'm not doing it this time in the interest of not being super annoying. If this breaks something for you, just yell, and I will deprecate this version and do a proper 0.5 release.
- Remove unnecessary
RandomGen g
constraints fromliftRandT
,liftRand
,evalRandT
,evalRand
,runRandT
,runRand
.
A major version bump is required by the PVP since the types of all the above methods have changed, but this release is again very unlikely to break any client code.
- Add
transformers-compat
to allow building with newermtl
- Improve documentation: ranges are exclusive at the upper bound
- Eta-reduce definition of
Rand
- Remove unnecessary
Random a
constraint from types ofliftRand
andliftRandT
.
Note that a major version bump is required by the PVP since the
types of liftRand
and liftRandT
have changed, but this release
is highly unlikely to break any client code.
- Allow building with both
transformers-0.3
and0.4
.
- change
Rand
from anewtype
to a type synonym MonadRandom
andMonadSplit
instances forExceptT
- strict variants of
StateT
andWriterT
- both lazy and strict variants of
RWST
- remove unneeded
RandomGen
constraint fromMonadState RandT
instance
- add simple
uniform
function for creating a uniform distribution over a list of values
- add
liftRandT
andliftRand
functions, for lifting explicit generator-passing functions intoRandT
andRand
, respectively.
- add
MonadRandom
andMonadSplit
instances forIdentityT
- derive
MonadReader
andMonadWriter
instances instead of declaring them explicitly (thanks again to James Koppel)
- add
MonadRandom
andMonadSplit
instances forContT
(thanks to James Koppel for the patch)
- add
MonadRandom
andMonadSplit
instances forMaybeT