Skip to content

Remove references to PrimGen, MutGen - #83

Merged
lehins merged 13 commits into
interface-to-performancefrom
haddocks-2
Apr 15, 2020
Merged

lehins merged 13 commits into
interface-to-performancefrom
haddocks-2

Conversation

@curiousleo

@curiousleo curiousleo commented Apr 10, 2020 •

Copy link
Copy Markdown
Collaborator

Preview

Previous preview here for comparison.

... and cover AtomicGen, IOGen and STGen instead.

@curiousleo

Copy link
Copy Markdown
Collaborator Author

Ready for review.

@curiousleo curiousleo mentioned this pull request Apr 14, 2020

@idontgetoutmuch idontgetoutmuch left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread System/Random.hs Resolved
Comment thread System/Random.hs Resolved
Comment thread System/Random.hs Resolved
Comment thread System/Random.hs Resolved
Comment thread System/Random.hs Resolved
Comment thread System/Random.hs Resolved
Comment thread System/Random.hs Outdated
-- | The standard pseudo-random number generator. Uses the SplitMix
-- implementation provided by the
-- [splitmix](https://hackage.haskell.org/package/splitmix) package.
newtype StdGen = StdGen { unStdGen :: SM.SMGen }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we are hiding the access to SMGen? I understand desire to wrap it with a newtype, but making it private is too restrictive

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was that this allows for forward-compatibility. As per our reproducibility guarantee, changing the underlying PRNG would require a major version bump. But this way we can change the underlying PRNG without also breaking the API.

What would be the advantages of making StdGen's public, e.g. via type StdGen = SMGen?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think changing the algorithm would be a breaking change too regardless, because properties of numbers being generated purely would change. Also same Int seed would result in different values being generated.

If someone wants to use SMGen directly they would be able to do so:

What would be the advantages of making StdGen's public, e.g. via type StdGen = SMGen?

My point is, it is not always good to completely hide the implementation from the user. I am thinking maybe we can introduce an Internal module, where all of the internal stuff can be exported from?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can introduce an Internal module, where all of the internal stuff can be exported from?

That sounds like a good idea to me. This should happen in a separate PR though. I've reverted the change to StdGen for now.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. If wrapping with the newtype is the way to go, then we are also missing an instance RandomGen SM.SMGen

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and then instance for StdGen can be derived with GeneralizedNewtypeDeriving

Comment thread System/Random.hs Resolved
Comment thread System/Random.hs Resolved
Comment thread System/Random.hs Resolved
@curiousleo

curiousleo commented Apr 15, 2020 •

Copy link
Copy Markdown
Collaborator Author

TODO for a follow-up PR:

Edit: some of these have been addressed in #96.
Edit: #98 adds documentation for uniform and uniformR.
Edit: #99 clarifies Random, Uniform and UniformRange Haddocks
Edit: #100 clarifies the *Gen Haddocks.

@curiousleo

Copy link
Copy Markdown
Collaborator Author

All comments addressed and rebased. PTAL.

@curiousleo
curiousleo requested a review from lehins April 15, 2020 08:45
@lehins
lehins merged commit 2a9829d into interface-to-performance Apr 15, 2020
curiousleo pushed a commit that referenced this pull request May 19, 2020
Remove references to PrimGen, MutGen
lehins added a commit that referenced this pull request Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants