Proposal: Add getStdGenState and stdGenFromState

wren ng thornton wren at
Tue Feb 7 23:04:51 CET 2012

On 2/6/12 1:36 PM, Tyson Whitehead wrote:
> Jumping in without having paid much attention to the thread or API, but I
> expect [Word8] (ByteString?) would fit the general case better than [Int32]

I'd second the vote for ByteString. If the goal is to dump a bunch of 
bits without declaring how many there are beforehand, then ByteString is 
exactly the right interface for that. If the goal is to serialize things 
efficiently, then ByteString is one of the better target representations 
for that[1]. I don't know what exactly StdGen is storing under the hood, 
but I don't imagine that it really has the semantic structure of a list 
of Int32.

[1] Depending on the details of what all you need exactly, it may not be 
the best. For example, if the semantic interpretation of the bits is 
non-uniform, then you'll probably want an intermediate structure which 
expresses the non-uniform chunks; and from there you'll almost surely 
need to start worrying about things like versioning of the format etc.

Live well,

More information about the Libraries mailing list