diff --git a/.changeset/cyan-vans-camp.md b/.changeset/cyan-vans-camp.md new file mode 100644 index 00000000..617f7aa1 --- /dev/null +++ b/.changeset/cyan-vans-camp.md @@ -0,0 +1,5 @@ +--- +"@effect/io": minor +--- + +consolidate provide\* apis for Layer/Context/Runtime diff --git a/docs/modules/Effect.ts.md b/docs/modules/Effect.ts.md index 5bc4274f..df56287f 100644 --- a/docs/modules/Effect.ts.md +++ b/docs/modules/Effect.ts.md @@ -89,13 +89,9 @@ Added in v1.0.0 - [contextWith](#contextwith) - [contextWithEffect](#contextwitheffect) - [mapInputContext](#mapinputcontext) - - [provideContext](#providecontext) - - [provideLayer](#providelayer) + - [provide](#provide) - [provideService](#provideservice) - [provideServiceEffect](#provideserviceeffect) - - [provideSomeContext](#providesomecontext) - - [provideSomeLayer](#providesomelayer) - - [provideSomeRuntime](#providesomeruntime) - [serviceConstants](#serviceconstants) - [serviceFunction](#servicefunction) - [serviceFunctionEffect](#servicefunctioneffect) @@ -1571,32 +1567,23 @@ export declare const mapInputContext: { Added in v1.0.0 -## provideContext +## provide -Provides the effect with its required context, which eliminates its -dependency on `R`. - -**Signature** - -```ts -export declare const provideContext: { - (context: Context.Context): (self: Effect) => Effect - (self: Effect, context: Context.Context): Effect -} -``` - -Added in v1.0.0 - -## provideLayer - -Provides a layer to the effect, which translates it to another level. +Splits the context into two parts, providing one part using the +specified layer/context/runtime and leaving the remainder `R0`. **Signature** ```ts -export declare const provideLayer: { - (layer: Layer.Layer): (self: Effect) => Effect - (self: Effect, layer: Layer.Layer): Effect +export declare const provide: { + (layer: Layer.Layer): ( + self: Effect + ) => Effect, E2 | E, A> + (context: Context.Context): (self: Effect) => Effect, E, A> + (runtime: Runtime.Runtime): (self: Effect) => Effect, E, A> + (self: Effect, layer: Layer.Layer): Effect, E | E2, A> + (self: Effect, context: Context.Context): Effect, E, A> + (self: Effect, runtime: Runtime.Runtime): Effect, E, A> } ``` @@ -1646,56 +1633,6 @@ export declare const provideServiceEffect: { Added in v1.0.0 -## provideSomeContext - -Splits the context into two parts, providing one part using the -specified layer and leaving the remainder `R0`. - -**Signature** - -```ts -export declare const provideSomeContext: { - (context: Context.Context): (self: Effect) => Effect, E, A> - (self: Effect, context: Context.Context): Effect, E, A> -} -``` - -Added in v1.0.0 - -## provideSomeLayer - -Splits the context into two parts, providing one part using the -specified layer and leaving the remainder `R0`. - -**Signature** - -```ts -export declare const provideSomeLayer: { - (layer: Layer.Layer): ( - self: Effect - ) => Effect, E2 | E, A> - (self: Effect, layer: Layer.Layer): Effect, E | E2, A> -} -``` - -Added in v1.0.0 - -## provideSomeRuntime - -Splits the context into two parts, providing one part using the -specified runtime and leaving the remainder `R0`. - -**Signature** - -```ts -export declare const provideSomeRuntime: { - (context: Runtime.Runtime): (self: Effect) => Effect, E, A> - (self: Effect, context: Runtime.Runtime): Effect, E, A> -} -``` - -Added in v1.0.0 - ## serviceConstants **Signature** diff --git a/examples/config.ts b/examples/config.ts index 8e1c1a7a..bea11138 100644 --- a/examples/config.ts +++ b/examples/config.ts @@ -32,7 +32,7 @@ export const program = Effect.gen(function*($) { pipe( program, - Effect.provideSomeLayer(HttpServerLive), + Effect.provide(HttpServerLive), Effect.catchAllCause(Effect.logError), Effect.runFork ) diff --git a/examples/deep.ts b/examples/deep.ts index bbd915c1..f01729ae 100644 --- a/examples/deep.ts +++ b/examples/deep.ts @@ -11,7 +11,7 @@ const program = pipe( }), Effect.flatMap((chunk) => Effect.sync(() => console.log(Array.from(chunk)))), Effect.tapErrorCause(Effect.logError), - Effect.provideLayer(Logger.minimumLogLevel(Level.Debug)) + Effect.provide(Logger.minimumLogLevel(Level.Debug)) ) Effect.runFork(program) diff --git a/examples/example.ts b/examples/example.ts index e742cd5b..250bdd11 100644 --- a/examples/example.ts +++ b/examples/example.ts @@ -15,7 +15,7 @@ const L = Layer.effect( }) ) -const main = Effect.provideSomeLayer(L)(Effect.flatMap(N, (n) => Effect.logDebug(`n: ${n}`))) +const main = Effect.provide(L)(Effect.flatMap(N, (n) => Effect.logDebug(`n: ${n}`))) Effect.runSync( Logger.withMinimumLogLevel(LogLevel.Debug)(main) diff --git a/examples/log.ts b/examples/log.ts index 47949199..88dd071b 100644 --- a/examples/log.ts +++ b/examples/log.ts @@ -21,7 +21,7 @@ const program2 = Logger.withMinimumLogLevel(LogLevel.Info)( const main = pipe( Effect.all([program1, program2], { discard: true }), - Effect.provideSomeLayer(Logger.minimumLogLevel(LogLevel.Info)) + Effect.provide(Logger.minimumLogLevel(LogLevel.Info)) ) Effect.runFork(main) diff --git a/examples/logMeta.ts b/examples/logMeta.ts index ba6bd546..1c48eb91 100644 --- a/examples/logMeta.ts +++ b/examples/logMeta.ts @@ -22,7 +22,7 @@ const program = Effect.gen(function*($) { const main = pipe( program, - Effect.provideSomeLayer(Logger.replace(Logger.defaultLogger, customLogger)) + Effect.provide(Logger.replace(Logger.defaultLogger, customLogger)) ) Effect.runFork(main) diff --git a/src/Effect.ts b/src/Effect.ts index fa01f907..a367a532 100644 --- a/src/Effect.ts +++ b/src/Effect.ts @@ -8,7 +8,7 @@ import type * as Either from "@effect/data/Either" import type * as Equal from "@effect/data/Equal" import type { Equivalence } from "@effect/data/Equivalence" import type { LazyArg } from "@effect/data/Function" -import { dual, identity } from "@effect/data/Function" +import { identity } from "@effect/data/Function" import type * as HashMap from "@effect/data/HashMap" import type * as HashSet from "@effect/data/HashSet" import type { TypeLambda } from "@effect/data/HKT" @@ -30,7 +30,7 @@ import type * as Fiber from "@effect/io/Fiber" import type * as FiberId from "@effect/io/FiberId" import type * as FiberRef from "@effect/io/FiberRef" import type * as FiberRefs from "@effect/io/FiberRefs" -import * as FiberRefsPatch from "@effect/io/FiberRefsPatch" +import type * as FiberRefsPatch from "@effect/io/FiberRefsPatch" import { clockTag } from "@effect/io/internal/clock" import * as core from "@effect/io/internal/core" import * as defaultServices from "@effect/io/internal/defaultServices" @@ -53,7 +53,7 @@ import type * as Request from "@effect/io/Request" import type { RequestBlock } from "@effect/io/RequestBlock" import type { RequestResolver } from "@effect/io/RequestResolver" import type * as Runtime from "@effect/io/Runtime" -import * as RuntimeFlags from "@effect/io/RuntimeFlags" +import type * as RuntimeFlags from "@effect/io/RuntimeFlags" import type * as RuntimeFlagsPatch from "@effect/io/RuntimeFlagsPatch" import type * as Schedule from "@effect/io/Schedule" import * as Scheduler from "@effect/io/Scheduler" @@ -3044,72 +3044,23 @@ export const mapInputContext: { (self: Effect, f: (context: Context.Context) => Context.Context): Effect } = core.mapInputContext -/** - * Provides the effect with its required context, which eliminates its - * dependency on `R`. - * - * @since 1.0.0 - * @category context - */ -export const provideContext: { - (context: Context.Context): (self: Effect) => Effect - (self: Effect, context: Context.Context): Effect -} = core.provideContext - -/** - * Splits the context into two parts, providing one part using the - * specified layer and leaving the remainder `R0`. - * - * @since 1.0.0 - * @category context - */ -export const provideSomeContext: { - (context: Context.Context): (self: Effect) => Effect, E, A> - (self: Effect, context: Context.Context): Effect, E, A> -} = core.provideSomeContext - /** * Splits the context into two parts, providing one part using the - * specified runtime and leaving the remainder `R0`. - * - * @since 1.0.0 - * @category context - */ -export const provideSomeRuntime: { - (context: Runtime.Runtime): (self: Effect) => Effect, E, A> - (self: Effect, context: Runtime.Runtime): Effect, E, A> -} = dual< - (context: Runtime.Runtime) => (self: Effect) => Effect, E, A>, - (self: Effect, context: Runtime.Runtime) => Effect, E, A> ->(2, (self, runtime) => { - const patchFlags = RuntimeFlags.diff(_runtime.defaultRuntime.runtimeFlags, runtime.runtimeFlags) - const inversePatchFlags = RuntimeFlags.diff(runtime.runtimeFlags, _runtime.defaultRuntime.runtimeFlags) - const patchRefs = FiberRefsPatch.diff(_runtime.defaultRuntime.fiberRefs, runtime.fiberRefs) - const inversePatchRefs = FiberRefsPatch.diff(runtime.fiberRefs, _runtime.defaultRuntime.fiberRefs) - return acquireUseRelease( - core.flatMap( - patchRuntimeFlags(patchFlags), - () => patchFiberRefs(patchRefs) - ), - () => provideSomeContext(self, runtime.context), - () => - core.flatMap( - patchRuntimeFlags(inversePatchFlags), - () => patchFiberRefs(inversePatchRefs) - ) - ) -}) - -/** - * Provides a layer to the effect, which translates it to another level. + * specified layer/context/runtime and leaving the remainder `R0`. * * @since 1.0.0 * @category context */ -export const provideLayer: { - (layer: Layer.Layer): (self: Effect) => Effect - (self: Effect, layer: Layer.Layer): Effect -} = layer.provideLayer +export const provide: { + ( + layer: Layer.Layer + ): (self: Effect) => Effect, E2 | E, A> + (context: Context.Context): (self: Effect) => Effect, E, A> + (runtime: Runtime.Runtime): (self: Effect) => Effect, E, A> + (self: Effect, layer: Layer.Layer): Effect, E | E2, A> + (self: Effect, context: Context.Context): Effect, E, A> + (self: Effect, runtime: Runtime.Runtime): Effect, E, A> +} = layer.effect_provide /** * Provides the effect with the single service it requires. If the effect @@ -3149,23 +3100,6 @@ export const provideServiceEffect: { ): Effect>, E | E1, A> } = effect.provideServiceEffect -/** - * Splits the context into two parts, providing one part using the - * specified layer and leaving the remainder `R0`. - * - * @since 1.0.0 - * @category context - */ -export const provideSomeLayer: { - ( - layer: Layer.Layer - ): (self: Effect) => Effect, E2 | E, A> - ( - self: Effect, - layer: Layer.Layer - ): Effect, E | E2, A> -} = layer.provideSomeLayer - /** * @since 1.0.0 * @category context diff --git a/src/internal/layer.ts b/src/internal/layer.ts index 08890db4..bb7bb430 100644 --- a/src/internal/layer.ts +++ b/src/internal/layer.ts @@ -8,7 +8,7 @@ import * as Clock from "@effect/io/Clock" import type * as Effect from "@effect/io/Effect" import type * as Exit from "@effect/io/Exit" import type { FiberRef } from "@effect/io/FiberRef" -import type * as FiberRefsPatch from "@effect/io/FiberRefsPatch" +import * as FiberRefsPatch from "@effect/io/FiberRefsPatch" import * as core from "@effect/io/internal/core" import * as effect from "@effect/io/internal/effect" import * as circular from "@effect/io/internal/effect/circular" @@ -17,6 +17,7 @@ import * as EffectOpCodes from "@effect/io/internal/opCodes/effect" import * as OpCodes from "@effect/io/internal/opCodes/layer" import * as ref from "@effect/io/internal/ref" import * as runtime from "@effect/io/internal/runtime" +import * as runtimeFlags from "@effect/io/internal/runtimeFlags" import * as synchronized from "@effect/io/internal/synchronizedRef" import type * as Layer from "@effect/io/Layer" import type * as Runtime from "@effect/io/Runtime" @@ -1115,12 +1116,67 @@ export const provideLayer = dual< )) /** @internal */ -export const provideSomeLayer: { - ( - layer: Layer.Layer - ): (self: Effect.Effect) => Effect.Effect, E | E2, A> - ( +export const provideSomeRuntime: { + (context: Runtime.Runtime): (self: Effect.Effect) => Effect.Effect, E, A> + (self: Effect.Effect, context: Runtime.Runtime): Effect.Effect, E, A> +} = dual< + (context: Runtime.Runtime) => (self: Effect.Effect) => Effect.Effect, E, A>, + (self: Effect.Effect, context: Runtime.Runtime) => Effect.Effect, E, A> +>(2, (self, rt) => { + const patchFlags = runtimeFlags.diff(runtime.defaultRuntime.runtimeFlags, rt.runtimeFlags) + const inversePatchFlags = runtimeFlags.diff(rt.runtimeFlags, runtime.defaultRuntime.runtimeFlags) + const patchRefs = FiberRefsPatch.diff(runtime.defaultRuntime.fiberRefs, rt.fiberRefs) + const inversePatchRefs = FiberRefsPatch.diff(rt.fiberRefs, runtime.defaultRuntime.fiberRefs) + return core.acquireUseRelease( + core.flatMap( + core.updateRuntimeFlags(patchFlags), + () => effect.patchFiberRefs(patchRefs) + ), + () => core.provideSomeContext(self, rt.context), + () => + core.flatMap( + core.updateRuntimeFlags(inversePatchFlags), + () => effect.patchFiberRefs(inversePatchRefs) + ) + ) +}) + +/** @internal */ +export const effect_provide = dual< + { + ( + layer: Layer.Layer + ): (self: Effect.Effect) => Effect.Effect, E | E2, A> + ( + context: Context.Context + ): (self: Effect.Effect) => Effect.Effect, E, A> + ( + runtime: Runtime.Runtime + ): (self: Effect.Effect) => Effect.Effect, E, A> + }, + { + ( + self: Effect.Effect, + layer: Layer.Layer + ): Effect.Effect, E | E2, A> + ( + self: Effect.Effect, + context: Context.Context + ): Effect.Effect, E, A> + ( + self: Effect.Effect, + runtime: Runtime.Runtime + ): Effect.Effect, E, A> + } +>( + 2, + ( self: Effect.Effect, - layer: Layer.Layer - ): Effect.Effect, E | E2, A> -} = dual(2, (self, layer) => provideLayer(self, merge(context(), layer))) + source: Layer.Layer | Context.Context | Runtime.Runtime + ): Effect.Effect, any, any> => + isLayer(source) + ? provideLayer(self as any, merge(context(), source as Layer.Layer)) + : Context.isContext(source) + ? core.provideSomeContext(self, source) + : provideSomeRuntime(self, source as Runtime.Runtime) +) diff --git a/test/Effect/environment.ts b/test/Effect/environment.ts index dd130296..389e4e9f 100644 --- a/test/Effect/environment.ts +++ b/test/Effect/environment.ts @@ -24,7 +24,7 @@ describe.concurrent("Effect", () => { const v2 = yield* $( pipe( NumberService, - Effect.provideContext(Context.make(NumberService, { n: 2 })) + Effect.provide(Context.make(NumberService, { n: 2 })) ) ) const v3 = yield* $(NumberService) @@ -32,7 +32,7 @@ describe.concurrent("Effect", () => { assert.strictEqual(v2.n, 2) assert.strictEqual(v3.n, 4) }), - Effect.provideContext(Context.make(NumberService, { n: 4 })) + Effect.provide(Context.make(NumberService, { n: 4 })) )) it.effect("environment - provideSomeContext provides context in the right order", () => pipe( @@ -42,15 +42,15 @@ describe.concurrent("Effect", () => { assert.strictEqual(v1.n, 1) assert.strictEqual(v2.s, "ok") }), - Effect.provideSomeContext(Context.make(NumberService, { n: 1 })), - Effect.provideSomeContext(Context.make(NumberService, { n: 2 })), - Effect.provideSomeContext(Context.make(StringService, { s: "ok" })) + Effect.provide(Context.make(NumberService, { n: 1 })), + Effect.provide(Context.make(NumberService, { n: 2 })), + Effect.provide(Context.make(StringService, { s: "ok" })) )) it.effect("environment - async can use environment", () => Effect.gen(function*($) { const result = yield* $( Effect.async((cb) => cb(Effect.map(NumberService, ({ n }) => n))), - Effect.provideContext(Context.make(NumberService, { n: 10 })) + Effect.provide(Context.make(NumberService, { n: 10 })) ) assert.strictEqual(result, 10) })) @@ -58,7 +58,7 @@ describe.concurrent("Effect", () => { Effect.gen(function*($) { const result = yield* $( Effect.flatMap(NumberService, ({ n }) => Effect.succeed(n + 3)), - Effect.provideContext(Context.make(NumberService, { n: 0 })) + Effect.provide(Context.make(NumberService, { n: 0 })) ) assert.strictEqual(result, 3) })) @@ -79,7 +79,7 @@ describe.concurrent("Effect", () => { assert.strictEqual(a.n, 1) assert.strictEqual(b.n, 0) }), - Effect.provideContext(pipe(Context.make(NumberService, { n: 0 }))) + Effect.provide(Context.make(NumberService, { n: 0 })) )) it.effect("serviceFunctions - expose service functions", () => { diff --git a/test/Effect/provide-runtime.ts b/test/Effect/provide-runtime.ts index e389d484..f88d8620 100644 --- a/test/Effect/provide-runtime.ts +++ b/test/Effect/provide-runtime.ts @@ -32,7 +32,7 @@ describe.concurrent("Effect", () => { const all = await Effect.runPromise(Effect.all( [ - Effect.provideSomeRuntime( + Effect.provide( Effect.gen(function*($) { const a = yield* $(FiberRef.get(ref)) const b = yield* $(A) diff --git a/test/Effect/query-nested.ts b/test/Effect/query-nested.ts index 57fff51d..37cdb9cd 100644 --- a/test/Effect/query-nested.ts +++ b/test/Effect/query-nested.ts @@ -174,6 +174,6 @@ describe.concurrent("Effect", () => { expect(count.count).toBe(3) expect(requests.count).toBe(7) }).pipe( - Effect.provideSomeLayer(EnvLive) + Effect.provide(EnvLive) )) }) diff --git a/test/Effect/query.ts b/test/Effect/query.ts index 10edc451..3093a8a7 100644 --- a/test/Effect/query.ts +++ b/test/Effect/query.ts @@ -121,7 +121,7 @@ const EnvLive = Layer.provideMerge( ) ) -const provideEnv = Effect.provideSomeLayer(EnvLive) +const provideEnv = Effect.provide(EnvLive) describe.concurrent("Effect", () => { it.effect("requests are executed correctly", () => diff --git a/test/Effect/scope-ref.ts b/test/Effect/scope-ref.ts index a549bec0..0499add3 100644 --- a/test/Effect/scope-ref.ts +++ b/test/Effect/scope-ref.ts @@ -41,7 +41,7 @@ describe("Effect", () => { withValue("INNER"), Effect.scoped, withValue("OUTER"), - Effect.provideSomeLayer(layer), + Effect.provide(layer), withValue("EXTERN") ) diff --git a/test/Layer.ts b/test/Layer.ts index 143f16f1..9f35fd5b 100644 --- a/test/Layer.ts +++ b/test/Layer.ts @@ -175,7 +175,7 @@ describe.concurrent("Layer", () => { Effect.scoped(Effect.acquireRelease(sleep, () => sleep)) ) const layer = layer1.pipe(Layer.merge(layer2.pipe(Layer.merge(layer3), Layer.provide(layer4)))) - const result = yield* $(Effect.unit, Effect.provideLayer(layer), Effect.exit) + const result = yield* $(Effect.unit, Effect.provide(layer), Effect.exit) assert.isTrue(Exit.isFailure(result)) })) it.effect("fresh with merge", () => @@ -305,7 +305,7 @@ describe.concurrent("Layer", () => { Layer.map((context) => Context.make(StringTag, Context.get(context, ServiceATag).name)), Layer.provide(layer2) ) - const result = yield* $(ServiceBTag, Effect.provideLayer(live)) + const result = yield* $(ServiceBTag, Effect.provide(live)) assert.strictEqual(result.name, "name") })) it.effect("memoizes acquisition of resources", () => @@ -316,8 +316,8 @@ describe.concurrent("Layer", () => { memoized, Effect.flatMap((layer) => Effect.context().pipe( - Effect.provideLayer(layer), - Effect.flatMap(() => Effect.context().pipe(Effect.provideLayer(layer))) + Effect.provide(layer), + Effect.flatMap(() => Effect.context().pipe(Effect.provide(layer))) ) ), Effect.scoped @@ -342,8 +342,8 @@ describe.concurrent("Layer", () => { const needsNumberAndString = Effect.all([NumberTag, StringTag]) const providesNumber = Layer.succeed(NumberTag, 10) const providesString = Layer.succeed(StringTag, "hi") - const needsString = needsNumberAndString.pipe(Effect.provideSomeLayer(providesNumber)) - const result = yield* $(needsString, Effect.provideLayer(providesString)) + const needsString = needsNumberAndString.pipe(Effect.provide(providesNumber)) + const result = yield* $(needsString, Effect.provide(providesString)) assert.strictEqual(result[0], 10) assert.strictEqual(result[1], "hi") })) @@ -379,7 +379,7 @@ describe.concurrent("Layer", () => { const provideString = Layer.succeed(StringTag, "hi") const needsString = provideNumberRef.pipe(Layer.provide(fooBuilder)) const layer = provideString.pipe(Layer.provide(needsString)) - const result = yield* $(Effect.flatMap(FooTag, (_) => _.get), Effect.provideLayer(layer)) + const result = yield* $(Effect.flatMap(FooTag, (_) => _.get), Effect.provide(layer)) assert.strictEqual(result[0], 10) assert.strictEqual(result[1], "hi") })) @@ -420,7 +420,7 @@ describe.concurrent("Layer", () => { Effect.flatMap(([i1, s]) => NumberRefTag.pipe(Effect.flatMap(Ref.get), Effect.map((i2) => [i1, i2, s] as const)) ), - Effect.provideLayer(layer) + Effect.provide(layer) ) assert.strictEqual(result[0], 10) assert.strictEqual(result[1], 10) @@ -445,7 +445,7 @@ describe.concurrent("Layer", () => { i: NumberTag, s: ToStringTag }), - Effect.provideLayer(live) + Effect.provide(live) ) assert.strictEqual(i.value, 1) assert.strictEqual(s.value, "1") @@ -462,7 +462,7 @@ describe.concurrent("Layer", () => { const AgeTag = Context.Tag() const personLayer = Layer.succeed(PersonTag, { name: "User", age: 42 }) const ageLayer = personLayer.pipe(Layer.project(PersonTag, AgeTag, (_) => ({ age: _.age }))) - const { age } = yield* $(AgeTag, Effect.provideLayer(ageLayer)) + const { age } = yield* $(AgeTag, Effect.provide(ageLayer)) assert.strictEqual(age, 42) })) it.effect("sharing with provideTo", () => diff --git a/test/Reloadable.ts b/test/Reloadable.ts index c9a55a7e..819cbae1 100644 --- a/test/Reloadable.ts +++ b/test/Reloadable.ts @@ -27,7 +27,7 @@ describe.concurrent("Reloadable", () => { const layer = Reloadable.manual(Tag, { layer: Layer.scoped(Tag, pipe(counter.acquire(), Effect.as(DummyService))) }) - yield* $(Reloadable.get(Tag), Effect.provideLayer(layer)) + yield* $(Reloadable.get(Tag), Effect.provide(layer)) const acquired = yield* $(counter.acquired()) assert.strictEqual(acquired, 1) })) @@ -37,7 +37,7 @@ describe.concurrent("Reloadable", () => { const layer = Reloadable.manual(Tag, { layer: Layer.scoped(Tag, pipe(counter.acquire(), Effect.as(DummyService))) }) - yield* $(Reloadable.reload(Tag), Effect.provideLayer(layer)) + yield* $(Reloadable.reload(Tag), Effect.provide(layer)) const acquired = yield* $(counter.acquired()) assert.strictEqual(acquired, 2) })) diff --git a/test/ScopedCache.ts b/test/ScopedCache.ts index cb4f9eb9..1d24aca0 100644 --- a/test/ScopedCache.ts +++ b/test/ScopedCache.ts @@ -336,9 +336,9 @@ describe.concurrent("ScopedCache", () => { const scoped = cache.get(void 0) const scope1 = yield* $(Scope.make()) const scope2 = yield* $(Scope.make()) - const acquire1 = Effect.provideContext(scoped, Context.make(Scope.Scope, scope1)) + const acquire1 = Effect.provide(scoped, Context.make(Scope.Scope, scope1)) const release1: Scope.Scope.Finalizer = (exit) => Scope.close(scope1, exit) - const acquire2 = Effect.provideContext(scoped, Context.make(Scope.Scope, scope2)) + const acquire2 = Effect.provide(scoped, Context.make(Scope.Scope, scope2)) const release2: Scope.Scope.Finalizer = (exit) => Scope.close(scope2, exit) yield* $(subResource.assertNotAcquired()) yield* $(acquire2) @@ -391,11 +391,11 @@ describe.concurrent("ScopedCache", () => { const scope2 = yield* $(Scope.make()) const [release1, release2] = yield* $(Effect.scoped(Effect.gen(function*($) { const cache = yield* $(scopedCache) - yield* $(Effect.provideContext( + yield* $(Effect.provide( cache.get(void 0), Context.make(Scope.Scope, scope1) )) - yield* $(Effect.provideContext( + yield* $(Effect.provide( cache.get(void 0), Context.make(Scope.Scope, scope2) )) @@ -423,8 +423,8 @@ describe.concurrent("ScopedCache", () => { const [release1, release2] = yield* $(Effect.scoped(Effect.gen(function*($) { const cache = yield* $(scopedCache) const scoped = cache.get(void 0) - yield* $(Effect.provideContext(scoped, Context.make(Scope.Scope, scope1))) - yield* $(Effect.provideContext(scoped, Context.make(Scope.Scope, scope2))) + yield* $(Effect.provide(scoped, Context.make(Scope.Scope, scope1))) + yield* $(Effect.provide(scoped, Context.make(Scope.Scope, scope2))) const release1: Scope.Scope.Finalizer = (exit) => Scope.close(scope1, exit) const release2: Scope.Scope.Finalizer = (exit) => Scope.close(scope2, exit) return [release1, release2] as const @@ -538,7 +538,7 @@ describe.concurrent("ScopedCache", () => { lookup: (key: void) => watchableLookup(key) })) const scope = yield* $(Scope.make()) - const acquire = Effect.provideContext( + const acquire = Effect.provide( cache.get(void 0), Context.make(Scope.Scope, scope) ) @@ -820,7 +820,7 @@ describe.concurrent("ScopedCache", () => { lookup: watchableLookup })) const scope = yield* $(Scope.make()) - const acquire = Effect.provideContext( + const acquire = Effect.provide( cache.get(void 0), Context.make(Scope.Scope, scope) ) diff --git a/test/Tracer.ts b/test/Tracer.ts index fd0adbbc..6e8ca9ff 100644 --- a/test/Tracer.ts +++ b/test/Tracer.ts @@ -187,7 +187,7 @@ describe("Tracer", () => { Option.some("parent") ) }).pipe( - Effect.provideLayer(Layer.unwrapScoped( + Effect.provide(Layer.unwrapScoped( Effect.map( Effect.useSpanScoped("parent"), (span) => Effect.setParentSpan(span) @@ -206,7 +206,7 @@ describe("Tracer", () => { Option.some("parent") ) }).pipe( - Effect.provideLayer(Effect.setSpan("parent")) + Effect.provide(Effect.setSpan("parent")) )) it.effect("linkSpans", () => diff --git a/test/utils/extend.ts b/test/utils/extend.ts index e63d3450..6e03c364 100644 --- a/test/utils/extend.ts +++ b/test/utils/extend.ts @@ -23,7 +23,7 @@ export const effect = (() => { () => pipe( Effect.suspend(self), - Effect.provideLayer(TestEnvironment.testContext()), + Effect.provide(TestEnvironment.testContext()), Effect.runPromise ), timeout @@ -40,7 +40,7 @@ export const effect = (() => { () => pipe( Effect.suspend(self), - Effect.provideLayer(TestEnvironment.testContext()), + Effect.provide(TestEnvironment.testContext()), Effect.runPromise ), timeout @@ -56,7 +56,7 @@ export const effect = (() => { () => pipe( Effect.suspend(self), - Effect.provideLayer(TestEnvironment.testContext()), + Effect.provide(TestEnvironment.testContext()), Effect.runPromise ), timeout @@ -109,7 +109,7 @@ export const scoped = ( pipe( Effect.suspend(self), Effect.scoped, - Effect.provideLayer(TestEnvironment.testContext()), + Effect.provide(TestEnvironment.testContext()), Effect.runPromise ), timeout