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?
yes
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
there's some relevant discussion in https://roc.zulipchat.com/#narrow/stream/316715-contributing/topic/Random.20number.20generator
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.
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