How to mix Random/Clock(ZIO side effects) with ZPure(pure domain)? While generating some random rewards or properties for equipments in business logic.
Since they return ZIO, you can't use them directly. In our case we often include the current time in the environment R (so we get it before running the ZPure and then the value is consistent during the execution since the environment is read-only). For random, we use Scala Random directly wrapped inside ZPure.suspend.
I apologize, I'm still a bit confused about the Random part.
I understand it's like defining something like: def nextInt: Program[Int] = ZPure.suspend(ZPure.attempt(rng.nextInt()))?
Does using Scala's Random directly lead to a loss of purity? Could you please explain it a bit more concretely? Thank you.