NoRedInk/elm-random-extra/2.1.0

NOTE: this package is not compatible with Elm 0.19.1

Random.Signal

List of Signal Generators

Generators

constant : Generator a -> Generator (Signal a)

Generates constant signals.

Random Seeds

randomSeed : Signal Seed

Generate a random seed that updates 60 times per second. Note: The seed uses the current Unix time.

randomSeedEvery : Time -> Signal Seed

Generate a random seed that updates every given timestep.

Generate Signals

generate : Generator a -> Signal a

Generate a signal from a random generator that updates 60 times per second.

generateEvery : Time -> Generator a -> Signal a

Generate a signal from a random generator that updates every given number of milliseconds.

Generate a run of an application

model
-> Generator action
-> (action -> model -> model)
-> (model -> view)
-> Generator view

Generate a random run of an application that follows the Elm Architecture. Here, the Elm Architecture is interpreted as follows:

initialModel : model
actions : Signal action
update : action -> model -> model
view : model -> view -- where view is usually Element or Html


main =
  Signal.map view
    (Signal.foldp update initialModel actions)

How to use:

applicationGenerator =
  application initialModel actionGenerator update view


main =
  generate applicationGenerator
run :
model
-> Generator action
-> (action -> model -> model)
-> (model -> view)
-> Signal view

Create a running signal from an application that follows the Elm Architecture. This is analogous to application and works better as it avoids issues with Random.Extra.reduce.

How to use:

main =
  run initialModel actionGenerator update view