paurkedal / ppx_deriving_random

Syntax extension to generate random instances of types
GNU Lesser General Public License v3.0
6 stars 2 forks source link

inclusion in `ppx_deriving` #1

Open c-cube opened 9 years ago

c-cube commented 9 years ago

Did you consider merging your work into ppx_deriving? You don't seem to need additional dependencies, and the plugin seems general purpose. It might require using Random.State.t by default for the random_state, but I think 99% of the use cases will use Random anyway.

paurkedal commented 9 years ago

I don't think Random will do for even the common case, since types will typically embed elementary types, at least int. Both Random.State.int and Random.State.float have the wrong signatures. So, for out-of-the-box usage, it would be necessary to ship a library with it.

That raises the question of which distributions to use. Bool is obvious, but int and float I think should have distributions centred around 0 with exponential tails. The main use cases I've had in mind are unit testing, generic algorithms, and maybe games. For unit testing, such default distributions might be okay, but for the latter two, I think one want's customized and parametrised distributions. I've though about adding a distribution library, but have been busy with another project since I wrote ppx_deriving_random. Should have some more time later this autumn, though.

I generally prefer separate packaging when there is not compelling reason to bundle. Not sure deriving random is as generally useful as the shipped deriving modules. Well, except if people start using it for unit testing.