8000 Provide access to construct a generator from `Seed -> (a, Seed)` · Issue #26 · elm/random · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Provide access to construct a generator from Seed -> (a, Seed) #26
Open
@z5h

Description

@z5h

In Random we have:

type Generator a =
    Generator (Seed -> (a, Seed))

So if I have a way of doing Seed -> (a, Seed)), I should be able to make a Generator a.
Well not exactly.

I can do:

fromStep : (Seed -> ( a, Seed )) -> Generator a
fromStep step =
    Random.independentSeed |> Random.map (step >> Tuple.first)

The problem here is independantSeed goes through the extra work of creating a new seed, and then we throw out the seed after the generator is used.

There’s no way to use a seed and step, (generating a value) and returning the value and the next seed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0