Up until random-1.1 a barebone (and potentially brittle) way to serialise and deserialise a StdGen would have been to use show and read, however random-1.2.0 removed Read (for good reasons) which means this is not possible anymore. As a consequence, writing things like a Serialize instance for StdGen is not possible at the moment.
Technically speaking one can work around this by using the .Internal module and simply use seedSMGen' and unseedSMGen on the underlying SMGen, but it feels wrong to use the Internal module and to rely on the concrete implementation of StdGen.
In a nutshell, it would be nice to have two functions as part of the API similar to the following:
toSeedGamma :: StdGen -> (Word64, Word64)
fromSeedGamma :: (Word64, Word64) -> StdGen
Thanks!
Up until
random-1.1a barebone (and potentially brittle) way to serialise and deserialise aStdGenwould have been to useshowandread, howeverrandom-1.2.0removedRead(for good reasons) which means this is not possible anymore. As a consequence, writing things like aSerializeinstance forStdGenis not possible at the moment.Technically speaking one can work around this by using the
.Internalmodule and simply useseedSMGen'andunseedSMGenon the underlyingSMGen, but it feels wrong to use theInternalmodule and to rely on the concrete implementation ofStdGen.In a nutshell, it would be nice to have two functions as part of the API similar to the following:
Thanks!