diff --git a/.changeset/wet-cooks-approve.md b/.changeset/wet-cooks-approve.md new file mode 100644 index 0000000000..3370d01553 --- /dev/null +++ b/.changeset/wet-cooks-approve.md @@ -0,0 +1,5 @@ +--- +"effect": minor +--- + +Layer: rename `zipWithPar` to `zipWith` (standard) diff --git a/docs/modules/Layer.ts.md b/docs/modules/Layer.ts.md index 94a1400a82..ecb0e4ed45 100644 --- a/docs/modules/Layer.ts.md +++ b/docs/modules/Layer.ts.md @@ -126,7 +126,7 @@ Added in v2.0.0 - [unwrapScoped](#unwrapscoped) - [zipping](#zipping) - [mergeAll](#mergeall) - - [zipWithPar](#zipwithpar) + - [zipWith](#zipwith) --- @@ -1353,7 +1353,7 @@ export declare const mergeAll: , ...Layer Added in v2.0.0 -## zipWithPar +## zipWith Combines this layer the specified layer, producing a new layer that has the inputs of both, and the outputs of both combined using the specified @@ -1362,7 +1362,7 @@ function. **Signature** ```ts -export declare const zipWithPar: { +export declare const zipWith: { ( that: Layer, f: (a: Context.Context, b: Context.Context) => Context.Context diff --git a/src/Layer.ts b/src/Layer.ts index 48f8d4d6c1..cabdc79a33 100644 --- a/src/Layer.ts +++ b/src/Layer.ts @@ -788,7 +788,7 @@ export const provideMerge: { * @since 2.0.0 * @category zipping */ -export const zipWithPar: { +export const zipWith: { ( that: Layer, f: (a: Context.Context, b: Context.Context) => Context.Context @@ -798,7 +798,7 @@ export const zipWithPar: { that: Layer, f: (a: Context.Context, b: Context.Context) => Context.Context ): Layer -} = internal.zipWithPar +} = internal.zipWith /** * @since 2.0.0 diff --git a/src/internal/layer.ts b/src/internal/layer.ts index c8ada06e23..5b2b18ebee 100644 --- a/src/internal/layer.ts +++ b/src/internal/layer.ts @@ -127,7 +127,7 @@ export interface Locally extends /** @internal */ export interface ProvideTo extends - Op readonly second: Layer.Layer }> @@ -135,7 +135,7 @@ export interface ProvideTo extends /** @internal */ export interface ZipWith extends - Op readonly second: Layer.Layer zipK(left: Context.Context, right: Context.Context): Context.Context @@ -144,7 +144,7 @@ export interface ZipWith extends /** @internal */ export interface ZipWithPar extends - Op readonly second: Layer.Layer zipK(left: Context.Context, right: Context.Context): Context.Context @@ -353,7 +353,7 @@ const withScope = ( case "FromEffect": { return core.sync(() => (_: MemoMap) => op.effect as Effect.Effect>) } - case "ProvideTo": { + case "Provide": { return core.sync(() => (memoMap: MemoMap) => pipe( memoMap.getOrElseMemoize(op.first, scope), @@ -382,7 +382,7 @@ const withScope = ( ) ) } - case "ZipWith": { + case "ProvideMerge": { return core.sync(() => (memoMap: MemoMap) => pipe( memoMap.getOrElseMemoize(op.first, scope), @@ -393,7 +393,7 @@ const withScope = ( ) ) } - case "ZipWithPar": { + case "ZipWith": { return core.sync(() => (memoMap: MemoMap) => pipe( memoMap.getOrElseMemoize(op.first, scope), @@ -688,7 +688,7 @@ export const merge = dual< E | E2, ROut | ROut2 > ->(2, (self, that) => zipWithPar(self, that, (a, b) => pipe(a, Context.merge(b)))) +>(2, (self, that) => zipWith(self, that, (a, b) => pipe(a, Context.merge(b)))) /** @internal */ export const mergeAll = , ...Array>]>( @@ -991,9 +991,9 @@ export const provide = dual< ) => suspend(() => { const provideTo = Object.create(proto) - provideTo._tag = OpCodes.OP_PROVIDE_TO + provideTo._tag = OpCodes.OP_PROVIDE provideTo.first = Object.create(proto, { - _tag: { value: OpCodes.OP_ZIP_WITH, enumerable: true }, + _tag: { value: OpCodes.OP_PROVIDE_MERGE, enumerable: true }, first: { value: context>(), enumerable: true }, second: { value: self }, zipK: { value: (a: Context.Context, b: Context.Context) => pipe(a, Context.merge(b)) } @@ -1015,7 +1015,7 @@ export const provideMerge = dual< ) => Layer.Layer, E2 | E, ROut | ROut2> >(2, (that: Layer.Layer, self: Layer.Layer) => { const zipWith = Object.create(proto) - zipWith._tag = OpCodes.OP_ZIP_WITH + zipWith._tag = OpCodes.OP_PROVIDE_MERGE zipWith.first = self zipWith.second = provide(that, self) zipWith.zipK = (a: Context.Context, b: Context.Context): Context.Context => { @@ -1025,7 +1025,7 @@ export const provideMerge = dual< }) /** @internal */ -export const zipWithPar = dual< +export const zipWith = dual< ( that: Layer.Layer, f: (a: Context.Context, b: Context.Context) => Context.Context @@ -1037,12 +1037,12 @@ export const zipWithPar = dual< ) => Layer.Layer >(3, (self, that, f) => suspend(() => { - const zipWithPar = Object.create(proto) - zipWithPar._tag = OpCodes.OP_ZIP_WITH_PAR - zipWithPar.first = self - zipWithPar.second = that - zipWithPar.zipK = f - return zipWithPar + const zipWith = Object.create(proto) + zipWith._tag = OpCodes.OP_ZIP_WITH + zipWith.first = self + zipWith.second = that + zipWith.zipK = f + return zipWith })) /** @internal */ diff --git a/src/internal/opCodes/layer.ts b/src/internal/opCodes/layer.ts index f8f979c314..2c2cbe10b5 100644 --- a/src/internal/opCodes/layer.ts +++ b/src/internal/opCodes/layer.ts @@ -35,19 +35,19 @@ export const OP_SUSPEND = "Suspend" as const export type OP_SUSPEND = typeof OP_SUSPEND /** @internal */ -export const OP_PROVIDE_TO = "ProvideTo" as const +export const OP_PROVIDE = "Provide" as const /** @internal */ -export type OP_PROVIDE_TO = typeof OP_PROVIDE_TO +export type OP_PROVIDE = typeof OP_PROVIDE /** @internal */ -export const OP_ZIP_WITH = "ZipWith" as const +export const OP_PROVIDE_MERGE = "ProvideMerge" as const /** @internal */ -export type OP_ZIP_WITH = typeof OP_ZIP_WITH +export type OP_PROVIDE_MERGE = typeof OP_PROVIDE_MERGE /** @internal */ -export const OP_ZIP_WITH_PAR = "ZipWithPar" as const +export const OP_ZIP_WITH = "ZipWith" as const /** @internal */ -export type OP_ZIP_WITH_PAR = typeof OP_ZIP_WITH_PAR +export type OP_ZIP_WITH = typeof OP_ZIP_WITH