diff --git a/Random.roc b/Random.roc index fc8d779..ef24866 100644 --- a/Random.roc +++ b/Random.roc @@ -3,8 +3,8 @@ interface Random Generation, Generator, Seed, - andThen, int, + next, step, ] imports [] @@ -16,6 +16,9 @@ Generator a : Seed -> Generation a Generation a : { value : a, seed : Seed } +next : Generation *, Generator a -> Generation a +next = \x, g -> g x.seed + step : Seed, Generator a -> Generation a step = \seed, g -> g seed @@ -28,7 +31,3 @@ int = \a, b -> { value: a, seed: seed + 1 } else { value: b, seed: seed + 1 } - - -andThen : Generation *, Generator a -> Generation a -andThen = \x, g -> g x.seed diff --git a/example.roc b/example.roc index a4a902b..0a5c5bb 100644 --- a/example.roc +++ b/example.roc @@ -14,7 +14,7 @@ main = a = point 2 # Even seed ~ x==6 b = point 4 # Even seed ~ x==6 c = point 6 # Even seed, but... - |> Random.andThen point # ... odd seed ~ x==5 (seed increments on each use) + |> Random.next point # ... odd seed ~ x==5 (seed increments on each use) d = point 7 # Odd seed ~ x==5 _ <- await (line (Num.toStr a.value.x)) # 6 _ <- await (line (Num.toStr b.value.x)) # 6