Refactor mutable generators#122
Merged
idontgetoutmuch merged 1 commit intointerface-to-performancefrom May 8, 2020
Merged
Conversation
…encies` for `Frozen`
cd272a0 to
cd5421f
Compare
curiousleo
approved these changes
May 8, 2020
Collaborator
curiousleo
left a comment
There was a problem hiding this comment.
This is really neat. The names are all better now, the MonadRandom instances are more straightforward to write, and thanks for removing the obsolete primitive extra-dep!
Yes, I do. Excellent idea |
curiousleo
pushed a commit
that referenced
this pull request
May 19, 2020
Refactor mutable generators
Shimuuar
pushed a commit
to Shimuuar/random
that referenced
this pull request
Jan 6, 2025
…bility Fix compilation on 32bit systems
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Main semantic change in this PR is the switch to
TypeFamilyDependenciesforFrozen, which until couple days ago I mistakenly thought can only be used with closed type families:This approach gives very nice usability improvements:
mwc-randomdo not have to define any newtypes (see the updated haddock), thus simplifying corresponding instances and overall making usage ofMonadRandommore pleasant. I am sure @Shimuuar will approve of this approachSTGen,IOGen... now get a standalone pure counterpart, which now have a constructor that is easily discoverable in haddock. Withdata family Frozen, instead oftype family Frozenconstructor is hidden from the user and can't really be documented directlyBesides semantic changes it contains some improvement to consistent naming. Each Monadic generator has now a suffix
M, ie.IOGenM. Each monadic has a pure counterpart withoutM, ie.IOGenPureGenis now renamedStateGen, which I think better describes its nature and how it works underneathThe important part of this PR is that everything else works just the same as before with respect to performance and type inference (without
TypeFamilyDependenciesFrozenwould make types of some functions ambiguous and would drastically impact the usability, which was my main concern before and the reason for rejection of #67 )