The documentation for Elm\'s Random
module states:
A good way to get an unexpected seed is to use the current time. http://package.elm-
Just an update for people who got here from Google like I did: the recommended way to do this now is with flags
instead of ports
. The code in the other answers will not even compile now.
https://guide.elm-lang.org/interop/javascript.html
HTML
Elm
type alias Model = {
mySeed : String
}
type alias Flags = {
myRandomValue : String
}
init : Flags -> ( Model, Cmd Msg )
init flags =
{
mySeed = flags.myRandomValue
}
...
main : Program Flags Model Msg
main = programWithFlags
{
view = view,
init = init,
update = update
}