If there is a good implementation of a lazy monad in Java?

Need a simple lazy evaluation library for java. Essentially one class. Is initialized by the functionT Lazy<t> of(Supplier<t> s)</t></t>

Minimal interface get method, the first call starts the above-mentioned Supplier and cashing his answer. The second call simply returns the value from the cache.
There is something already ready?

PS This is generally a monad?
July 9th 19 at 10:22
3 answers
July 9th 19 at 10:24
Solution
1) kotlin
2) its implementation in 5 minutes
Did, in principle, quickly wrote my - elsa_Weissnat commented on July 9th 19 at 10:27
: well, right, the task is generally trivial. a little more complicated when using in a multithreaded environment, but not too much. well, if you look in the direction of monads-monad and other functional paradigm, I advise you to look at kotlin. a good language with a huge amount of sugar - trisha.Gleason31 commented on July 9th 19 at 10:30
July 9th 19 at 10:26
This is generally a monad?

No, it is the implementation of lazy evaluations. For monads it is not.
July 9th 19 at 10:28
Can you take Rx. There is such a thing as a BehaviorSubject. All new subscribers will get the value from the "cache". When data is updated, all subscribers will receive them.
The only problem is that BehaviorSubject needs to be initialized with some initial data.
But also the Rx is the so-called "cold" Observable. There's a chain of calculations/actions will not be called until no subscribers. Ie, it's the laziness that we need. And most likely, there is a way to do lazy evaluation and the cache using Rx, I just don't know so well this libw. But Google should know.

Find more questions by tags JavaFunctional programming