idontgetoutmuch / random

Random number library
Other
3 stars 2 forks source link

Depend on splitmix package or copy generator code? #86

Open curiousleo opened 4 years ago

curiousleo commented 4 years ago

Context

Currently there is a dependency on the splitmix package: https://github.com/idontgetoutmuch/random/blob/a5c70bdbc2ffd1616fef07c43170a9a172f2afac/random.cabal#L38

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: https://github.com/idontgetoutmuch/random/blob/a5c70bdbc2ffd1616fef07c43170a9a172f2afac/cabal.project#L2 https://github.com/idontgetoutmuch/random/blob/a5c70bdbc2ffd1616fef07c43170a9a172f2afac/stack.yaml#L42-L44

Alternative

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

Discussion

Pull in splitmix dependency pros:

Pull in splitmix dependency cons:

Copy algorithm pros:

Copy algorithm cons:

lehins commented 4 years ago

I opened an issue on splitmix about it: https://github.com/phadej/splitmix/issues/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 commented 4 years ago

Great, Oleg is ok with dropping dependency on random, so there is no need to duplicate the full implementation. See comment https://github.com/phadej/splitmix/issues/34#issuecomment-613462577