Skip to content
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

Introduce new SplitGen type class #160

Merged
merged 1 commit into from
Jan 27, 2024
Merged

Introduce new SplitGen type class #160

merged 1 commit into from
Jan 27, 2024

Conversation

lehins
Copy link
Contributor

@lehins lehins commented Jan 27, 2024

Fixes #97

I've been thinking for a while about this and I think the correct path forward is to introduce a separate class for splittable generators, which I called SplitGen and deprecate the old split function.

The benefit of this approach is that current user code does not break and gives a graceful path to upgrade to the new type class.

Other approaches were considered in #94 and discussed at length in idontgetoutmuch#7

I highly doubt that we will provide a generic approach of using some hash function for implementing PRNG splitting. I would rather prefer such functionality be in a separate library that other packages that want to implement SplitGen can opt-in into using.

@lehins lehins force-pushed the lehins/SplitGen branch 2 times, most recently from 3411863 to 2cc5a88 Compare January 27, 2024 13:37
@Shimuuar
Copy link
Contributor

+1

Following will cause compile failure for instances which don't define split and SplitGen instance. But I think it's fine

  default split :: SplitGen g => g -> (g, g)
  split = splitGen

@lehins lehins merged commit 623cf51 into master Jan 27, 2024
49 checks passed
lehins added a commit that referenced this pull request Jan 28, 2024
lehins added a commit that referenced this pull request Jan 28, 2024
lehins added a commit that referenced this pull request Oct 26, 2024
lehins added a commit that referenced this pull request Oct 27, 2024
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.

Make a better story for split
2 participants