Stream: beginners

Topic: Random Number Generation


view this post on Zulip Matthew Crews (Mar 15 2023 at 16:35):

Is there an idiomatic way to generate random numbers in Roc? Is the recommendation to thread the state of the random number generator through all the function calls that require it?

view this post on Zulip Folkert de Vries (Mar 15 2023 at 16:36):

yes

view this post on Zulip Richard Feldman (Mar 15 2023 at 16:40):

that can be wrapped up in a nicer way with something like https://package.elm-lang.org/packages/elm/random but we don't have a fully working package of that type yet

view this post on Zulip Richard Feldman (Mar 15 2023 at 16:41):

there's some relevant discussion in https://roc.zulipchat.com/#narrow/stream/316715-contributing/topic/Random.20number.20generator

view this post on Zulip Matthew Crews (Mar 15 2023 at 16:45):

Thanks! I have found that high-performance Discrete Event Simulation is a degenerate case for Functional Programming. I love FP style, but it's impossible to make F# go fast using FP, which is why Roc is so enticing. I find I write C-style F# at this point for performance.

view this post on Zulip Brendan Hansknecht (Mar 15 2023 at 16:47):

Roc can definitely be made to go fast, but definitely has some sharp edges. Hopefully those will be reduced over time/tools made to identify them.


Last updated: Jul 05 2025 at 12:14 UTC