What if the siganture of memoize would be def memoize: ZIO[R, E, A] instead of UIO[ZIO[R, E,A]]. Let's keep the intial definition.
**we asume that the first part of an for-comprehension can be a x = xyz, which it can't, but it doesn't change the point of this example. The first part of an for-comprehension has to be an x <- xyz **
Let's look at an example:
for {
m1 <- putStrLn("hello").memoize
m2 <- putStrLn("hello").memoize