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

Depend on splitmix package or copy generator code? #86

Open
curiousleo opened this issue Apr 14, 2020 · 2 comments
Open

Depend on splitmix package or copy generator code? #86

curiousleo opened this issue Apr 14, 2020 · 2 comments

Comments

@curiousleo
Copy link
Collaborator

Context

Currently there is a dependency on the splitmix package:

splitmix -any

By default, splitmix depends on random. This dependency can be severed by setting a flag. That is currently necessary, otherwise cabal and stack fail to build random due to a dependency circle:

constraints: splitmix -random

random/stack.yaml

Lines 42 to 44 in a5c70bd

flags:
splitmix:
random: false

Alternative

The alternative to depending on the splitmix package is to inline the SplitMix implementation.

Discussion

Pull in splitmix dependency pros:

  • Whenever improvements are made to splitmix, random can easily benefit from them.

Pull in splitmix dependency cons:

  • Setting the flag called random to False is required; without it there will be a circular dependency. Flags are supported by cabal and stack, but it looks like e.g. cabal2nix does not support them.
    Q: would users need to set this flag too in order to use random?

Copy algorithm pros:

  • No dependency on splitmix and thus no need to set any flags.
  • Can reduce the dependency tree overall: some of splitmix' dependencies are not necessary for our purposes and can be removed from the dependency tree.

Copy algorithm cons:

  • Code duplication.
  • random does not automatically benefit from updates to splitmix. However, note that the algorithm is now stable - the last change to the PRNG itself occurred in May 2018: Bug in splitmix haskellari/splitmix#9.
@lehins
Copy link
Collaborator

lehins commented Apr 14, 2020

I opened an issue on splitmix about it: haskellari/splitmix#34 I don't see a good reason to inline the splitmix code into random, except only to break the cycle, so in the end it will be @phadej decision on which way the dependency arrow points.

@lehins
Copy link
Collaborator

lehins commented Apr 14, 2020

Great, Oleg is ok with dropping dependency on random, so there is no need to duplicate the full implementation. See comment haskellari/splitmix#34 (comment)

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

No branches or pull requests

2 participants