-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functionality for generating a ByteArray #10
Conversation
System/Random.hs
Outdated
-- in order not to mess up the byte order we write generated Word64 into a temporary | ||
-- pointer and then copy only the missing bytes over to the array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A previous iteration of this code used uniformWord8
to generate those remaining bytes. Did you replace the uniformWord8
based generation for the remaining bytes by uniformWord64
based generation because of byte order?
If that is the case, I think this comment could be even more explicit: "... we write generated Word64 instead of generating Word8 one by one ..." or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was not only byte order. Generating 1xWord64 and 8x Word8 concatenated together will always give you different result, because in order generate 8x Word8 we need to generate 8x Word64 first (at least in case of splitmix)
I'll add a more descriptive comment to the function
I also added helper functions for generating ByteString, which I am sure will come in handy. |
Add functionality for generating a ByteArray
Here is an interface and default implementation for generating a sequence of bytes as a
ByteArray
I mentioned this briefly in #5 (comment)