We'd like to be able to define a MonadRandom instance for a newtype'd ST, using the same unsafePerformIO IORef trick as the IO instance, but with MWC-random's Gen rather than the System.Random Gen.
Fundamentally, the problem is that random et al require
This is sad because the interface should be exactly the same.
One solution is to eliminate the Random a requirement and fix a return type (Word32, Int,Double, etc), since all random generators fundamentally operate on these primitive types. Another solution is to make a multiparam version of MonadRandom parameterizing the generator type and/or return type.
I'd pick the first solution, but I'd like to know if anyone has a use-case for baking different randomness mechanisms into the Random typeclass, rather than just post applying an f :: Int -> A or somesuch
We'd like to be able to define a
MonadRandominstance for anewtype'dST, using the sameunsafePerformIOIOReftrick as theIOinstance, but withMWC-random'sGenrather than theSystem.RandomGen.Fundamentally, the problem is that
randomet al requireThis is sad because the interface should be exactly the same.
One solution is to eliminate the
Random arequirement and fix a return type (Word32,Int,Double, etc), since all random generators fundamentally operate on these primitive types. Another solution is to make a multiparam version ofMonadRandomparameterizing the generator type and/or return type.I'd pick the first solution, but I'd like to know if anyone has a use-case for baking different randomness mechanisms into the
Randomtypeclass, rather than just post applying anf :: Int -> Aor somesuch