Conversation
| , runPrimGenST_ | ||
| , runPrimGenIO | ||
| , runPrimGenIO_ |
There was a problem hiding this comment.
Do you think that discarding generators is common enough to warrant the extra functions, or were these added mostly for benchmarking? (Same for runMutGen{ST,IO}_)
There was a problem hiding this comment.
Absolutely, in fact I believe it will be more common than runMutGen{IO,ST}.
There is a very good chance you only need a single generator for your whole application that you will just thread through in the environment either directly or with Reader pattern
Therefore I expect something like this will be a very common pattern:
main = do
... parse cli, read config from file, initialize your app environment, etc.
g <- initSystemGen -- or grab the seed from config/cli
runPrimGenIO_ g $ \ primGen ->
...
let env = AppEnv primGen ...
runApp envIf you need more than a single generator you can just use splitPrimGen. Point is, that at some point any application will be done with needing random numbers, thus there will no longer be a need for the generator and since a user already bought into the effectful RNG, it is unlikely that he'll need to recover the pure version after the computation is complete. At the same time we don't need to make it hard to get the pure generator back either, therefore I think runMutGen{IO,ST} will be useful as well.
|
Closed in favor of #33 |
This PR implements an effectful generator backed by a
MutableByteArrayas described in #15