Skip to content

TRandom

11 exports Added in v2.0.0 Source

Context

live

Added in v2.0.0 Source

The "live" TRandom service wrapped into a Layer.

Signature

declare const live: Layer.Layer<TRandom>;

Tag

Added in v2.0.0 Source

The service tag used to access TRandom in the environment of an effect.

Signature

declare const Tag: Context.Tag<TRandom, TRandom>;

Models

TRandom interface

Added in v2.0.0 Source

Signature

interface TRandom {
  readonly [TRandomTypeId]: typeof TRandomTypeId;
  readonly next: STM<number>;
  readonly nextBoolean: STM<boolean>;
  readonly nextInt: STM<number>;
  nextIntBetween(min: number, max: number): STM<number>;
  nextRange(min: number, max: number): STM<number>;
  shuffle<A>(elements: Iterable<A>): STM<Array<A>>;
}

Random

next

Added in v2.0.0 Source

Returns the next number from the pseudo-random number generator.

Signature

declare const next: STM.STM<number, never, TRandom>;

nextBoolean

Added in v2.0.0 Source

Returns the next boolean value from the pseudo-random number generator.

Signature

declare const nextBoolean: STM.STM<boolean, never, TRandom>;

nextInt

Added in v2.0.0 Source

Returns the next integer from the pseudo-random number generator.

Signature

declare const nextInt: STM.STM<number, never, TRandom>;

Returns the next integer in the specified range from the pseudo-random number generator.

Signature

declare const nextIntBetween: (low: number, high: number) => STM.STM<number, never, TRandom>;

nextRange

Added in v2.0.0 Source

Returns the next number in the specified range from the pseudo-random number generator.

Signature

declare const nextRange: (min: number, max: number) => STM.STM<number, never, TRandom>;

shuffle

Added in v2.0.0 Source

Uses the pseudo-random number generator to shuffle the specified iterable.

Signature

declare const shuffle: <A>(elements: Iterable<A>) => STM.STM<Array<A>, never, TRandom>;

Symbols

Signature

declare const TRandomTypeId: unique symbol;

TRandomTypeId type

Added in v2.0.0 Source

Signature

type TRandomTypeId = typeof TRandomTypeId;