Skip to main content
Version: 2.0.x


TRandom is a random service like Random that provides utilities to generate random numbers, but they can participate in STM transactions.

The TRandom service is the same as the Random service. There are no differences in operations, but all return types are in the STM world rather than the ZIO world:

FunctionInput TypeOutput Type
nextBooleanURSTM[TRandom, Boolean]
nextByteslength: IntURSTM[TRandom, Chunk[Byte]]
nextDoubleURSTM[TRandom, Double]
nextIntURSTM[TRandom, Int]

When we use operations of the TRandom service, they add TRandom dependency on our STM data type. After committing all the transactions, we can inject/provide a TRandom implementation into our effect: