elm / random

Generate random values in Elm
https://package.elm-lang.org/packages/elm/random/latest/
BSD 3-Clause "New" or "Revised" License
46 stars 23 forks source link

Rename Generator to Random #12

Closed mgold closed 5 years ago

mgold commented 5 years ago

Over on discourse, someone was asking about the best practices for using this library and had apparently missed what we tried to convey about generators and deemphasizing seeds. Now maybe that's just part of the learning process but the idea occurred to me to rename Generator a to Random a. The comment got six hearts so some people think it's a good idea.

The benefit is that by following the "module built around a data structure of the same name" paradigm, we would really enforce that Random a is where it's at. And Random Int or Random User read quite nicely.

The large downside of course is that it's a major change, and would require a lot of tedious updates (including in elm-test and then other people's tests). Also, I can refer to generators as nouns pretty easily ("a way to combine two generators"), but "random" is an adjective so we'd need to say "a way to combine two Random values" or similar.

evancz commented 5 years ago

This is interesting.

I think it is valuable to keep it as a noun that matches the naming convention in other similar libraries. Data structures use their own names (e.g. List a, Set a, Array a) whereas APIs that are encoding some sort of logic have -er names (e.g. Parser a, Decoder a, Generator a)

I remember struggling a lot with generating random numbers in Haskell with their Random interface. I can imagine than calling it Random seems helpful for some folks who have seen it called Generator before, but my experience suggests that it would be harder when seeing it fresh. "What is a Random? This isn't like a list!" Then we're back where we started.

mgold commented 5 years ago

Makes sense, I’m glad to have resolution on this instead of leaving the issue open forever.