import * as tsplus_module_1 from "@effect/core/io/Effect/operations/zipRight";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/intoDeferred";
import * as tsplus_module_3 from "@effect/core/io/Effect/operations/once";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/map";
import * as tsplus_module_5 from "@effect/core/io/Deferred/operations/make";
import * as tsplus_module_6 from "@effect/core/io/Effect/operations/flatMap";
/**
 * Returns an effect that, if evaluated, will return the lazily computed
 * result of this effect.
 *
 * @tsplus fluent ets/Effect memoize
 */

export function memoize(self, __tsplusTrace) {
  return tsplus_module_6.flatMap_(tsplus_module_5.make(__tsplusTrace), deferred => tsplus_module_4.map_(tsplus_module_3.once(tsplus_module_2.intoDeferred_(self, () => deferred, __tsplusTrace), __tsplusTrace), complete => tsplus_module_1.zipRight_(complete, () => deferred.await(__tsplusTrace), __tsplusTrace), __tsplusTrace), __tsplusTrace);
}
//# sourceMappingURL=memoize.mjs.map