import * as tsplus_module_1 from "@effect/core/io/Scope/operations/make";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/provideEnvironment";
import * as tsplus_module_3 from "@effect/core/io/Layer/memoMap";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/flatMap";
import * as tsplus_module_5 from "@effect/core/io/Scope/operations/close";
import * as tsplus_module_6 from "@effect/core/io/Effect/operations/acquireUseReleaseExit";
/**
 * Provides a layer to the effect, which translates it to another level.
 *
 * @tsplus fluent ets/Effect provideLayer
 */

export function provideLayer_(self, layer, __tsplusTrace) {
  return tsplus_module_6.acquireUseReleaseExit(() => tsplus_module_1.make, scope => tsplus_module_4.flatMap_(tsplus_module_3.buildWithScope(layer, () => scope, __tsplusTrace), r => tsplus_module_2.provideEnvironment_(self, () => r, __tsplusTrace), __tsplusTrace), (scope, exit) => tsplus_module_5.close_(scope, () => exit), __tsplusTrace);
}
/**
 * Provides a layer to the effect, which translates it to another level.
 *
 * @tsplus static ets/Effect/Aspects provideLayer
 */

export const provideLayer = (layer, __tsplusTrace) => self => provideLayer_(self, layer, __tsplusTrace);
//# sourceMappingURL=provideLayer.mjs.map