Hyperlinkv0.8.0-beta.28

Random

Random.nextconsteffect/Random.ts:83
Effect.Effect<number, never, never>

Generates a random number between 0 (inclusive) and 1 (exclusive).

When to use

Use to generate a pseudo-random floating-point number in the standard [0, 1) range.

Example (Generating a random number)

import { Effect, Random } from "effect"

const program = Effect.gen(function*() {
  const randomDouble = yield* Random.next
  console.log("Random double:", randomDouble)
})
Random Number Generators
Source effect/Random.ts:831 lines
export const next: Effect.Effect<number> = randomWith((r) => r.nextDoubleUnsafe())
Referenced by 1 symbols