From 880868b623f379c787d75956b2df95d6110fd56e Mon Sep 17 00:00:00 2001 From: Carl Hunter-Roach Date: Tue, 14 Jun 2022 19:14:19 +0100 Subject: [PATCH] Update README.md Changed a broken link to an example to the current links (it's grown to three examples). Added "side-effects" into the section about "same input, same output". --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 94834ff..e3d6735 100644 --- a/README.md +++ b/README.md @@ -25,12 +25,12 @@ usuallyTrue = In each of these defines _how_ to generate random values. The most interesting case is `usuallyTrue` which generates `True` 80% of the time and `False` 20% of the time! -Now look at this [working example](https://guide.elm-lang.org/effects/random.html) to see a `Generator` used in an application. +Now look at [Numbers](https://elm-lang.org/examples/numbers), [Card](https://elm-lang.org/examples/cards) and [Positions](https://elm-lang.org/examples/positions) to see three examples of a `Generator` used in an application. ## Mindset Shift -If you are coming from JavaScript, this package is usually quite surprising at first. Why not just call `Math.random()` and get random floats whenever you want? Well, all Elm functions have this “same input, same output” guarantee. That is part of what makes Elm so reliable and easy to test! But if we could generate random values anytime we want, we would have to throw that guarantee out. +If you are coming from JavaScript, this package is usually quite surprising at first. Why not just call `Math.random()` and get random floats whenever you want? Well, all Elm functions have this “same input, same output” guarantee. Having no "side effects" is what makes Elm so reliable and easy to test! But if we could generate random values anytime we want, we would have to throw that guarantee out. So instead, we create a `Generator` and hand it to the Elm runtime system to do the dirty work of generating values. We get to keep our guarantees _and_ we get random values. Great! And once people become familiar with generators, they often report that it is _easier_ than the traditional imperative APIs for most cases. For example, jump to the docs for [`Random.map4`](Random#map4) for an example of generating random [quadtrees](https://en.wikipedia.org/wiki/Quadtree) and think about what it would look like to do that in JavaScript!