Closed sdroege closed 8 years ago
I don't think it's good idea. State is rather large: 258 Word32 so it's not efficient to carry it around.And implementation uses in-place state mutation to achieve high performance
That's actually a good point, didn't think of that. Might maybe make more sense for my use case to build a new MonadRandom-like thing that runs in PrimMonad
Writing generic API for random number generation is challenging task. All PRNG I know about (I'm no expert though) generate uniformly distributed bit vector (usually 32 or 64 bits wide). Everything else is built upon it
Haskell PRNGs could be split into two main categories: ones with pure state (System.Random), and ones with mutable state. Latter tend to have large state (mwc8222, Mersenne twister). Explicit state passing or passing of reference to mutable state could be abstracted using state or reader monad correspondingly. Unifying API this disparate is not easy task
FWIW, I went with this solution for my own uses now: https://gist.github.com/sdroege/6209e97b4dfc9791033d Might be useful to have something like this in mwc-random
You might be interested in mwc-random-monad package. It provides monadic API for mwc-random but doesn't generalize different generators
Ah, for some reason I didn't find that package and reinvented parts of it :)
I'm closing this issue.
It would be great if mwc-random had a pure API that explictly passes random state around, especially for integration with something like MonadRandom ( https://hackage.haskell.org/package/MonadRandom ).