Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layer: rename zipWithPar to zipWith (standard) #1707

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wet-cooks-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": minor
---

Layer: rename `zipWithPar` to `zipWith` (standard)
6 changes: 3 additions & 3 deletions docs/modules/Layer.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Added in v2.0.0
- [unwrapScoped](#unwrapscoped)
- [zipping](#zipping)
- [mergeAll](#mergeall)
- [zipWithPar](#zipwithpar)
- [zipWith](#zipwith)

---

Expand Down Expand Up @@ -1353,7 +1353,7 @@ export declare const mergeAll: <Layers extends [Layer<any, any, never>, ...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
Expand All @@ -1362,7 +1362,7 @@ function.
**Signature**

```ts
export declare const zipWithPar: {
export declare const zipWith: {
<R2, E2, B, A, C>(
that: Layer<R2, E2, B>,
f: (a: Context.Context<A>, b: Context.Context<B>) => Context.Context<C>
Expand Down
4 changes: 2 additions & 2 deletions src/Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ export const provideMerge: {
* @since 2.0.0
* @category zipping
*/
export const zipWithPar: {
export const zipWith: {
<R2, E2, B, A, C>(
that: Layer<R2, E2, B>,
f: (a: Context.Context<A>, b: Context.Context<B>) => Context.Context<C>
Expand All @@ -798,7 +798,7 @@ export const zipWithPar: {
that: Layer<R2, E2, B>,
f: (a: Context.Context<A>, b: Context.Context<B>) => Context.Context<C>
): Layer<R | R2, E | E2, C>
} = internal.zipWithPar
} = internal.zipWith

/**
* @since 2.0.0
Expand Down
34 changes: 17 additions & 17 deletions src/internal/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ export interface Locally extends

/** @internal */
export interface ProvideTo extends
Op<OpCodes.OP_PROVIDE_TO, {
Op<OpCodes.OP_PROVIDE, {
readonly first: Layer.Layer<never, never, unknown>
readonly second: Layer.Layer<never, never, unknown>
}>
{}

/** @internal */
export interface ZipWith extends
Op<OpCodes.OP_ZIP_WITH, {
Op<OpCodes.OP_PROVIDE_MERGE, {
readonly first: Layer.Layer<never, never, unknown>
readonly second: Layer.Layer<never, never, unknown>
zipK(left: Context.Context<unknown>, right: Context.Context<unknown>): Context.Context<unknown>
Expand All @@ -144,7 +144,7 @@ export interface ZipWith extends

/** @internal */
export interface ZipWithPar extends
Op<OpCodes.OP_ZIP_WITH_PAR, {
Op<OpCodes.OP_ZIP_WITH, {
readonly first: Layer.Layer<never, never, unknown>
readonly second: Layer.Layer<never, never, unknown>
zipK(left: Context.Context<unknown>, right: Context.Context<unknown>): Context.Context<unknown>
Expand Down Expand Up @@ -353,7 +353,7 @@ const withScope = <RIn, E, ROut>(
case "FromEffect": {
return core.sync(() => (_: MemoMap) => op.effect as Effect.Effect<RIn, E, Context.Context<ROut>>)
}
case "ProvideTo": {
case "Provide": {
return core.sync(() => (memoMap: MemoMap) =>
pipe(
memoMap.getOrElseMemoize(op.first, scope),
Expand Down Expand Up @@ -382,7 +382,7 @@ const withScope = <RIn, E, ROut>(
)
)
}
case "ZipWith": {
case "ProvideMerge": {
return core.sync(() => (memoMap: MemoMap) =>
pipe(
memoMap.getOrElseMemoize(op.first, scope),
Expand All @@ -393,7 +393,7 @@ const withScope = <RIn, E, ROut>(
)
)
}
case "ZipWithPar": {
case "ZipWith": {
return core.sync(() => (memoMap: MemoMap) =>
pipe(
memoMap.getOrElseMemoize(op.first, scope),
Expand Down Expand Up @@ -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 = <Layers extends [Layer.Layer<any, any, never>, ...Array<Layer.Layer<any, any, never>>]>(
Expand Down Expand Up @@ -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<Exclude<RIn2, ROut>>(), enumerable: true },
second: { value: self },
zipK: { value: (a: Context.Context<ROut>, b: Context.Context<ROut2>) => pipe(a, Context.merge(b)) }
Expand All @@ -1015,7 +1015,7 @@ export const provideMerge = dual<
) => Layer.Layer<RIn | Exclude<RIn2, ROut>, E2 | E, ROut | ROut2>
>(2, <RIn2, E2, ROut2, RIn, E, ROut>(that: Layer.Layer<RIn2, E2, ROut2>, self: Layer.Layer<RIn, E, ROut>) => {
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<ROut>, b: Context.Context<ROut2>): Context.Context<ROut | ROut2> => {
Expand All @@ -1025,7 +1025,7 @@ export const provideMerge = dual<
})

/** @internal */
export const zipWithPar = dual<
export const zipWith = dual<
<R2, E2, B, A, C>(
that: Layer.Layer<R2, E2, B>,
f: (a: Context.Context<A>, b: Context.Context<B>) => Context.Context<C>
Expand All @@ -1037,12 +1037,12 @@ export const zipWithPar = dual<
) => Layer.Layer<R | R2, E | E2, C>
>(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 */
Expand Down
12 changes: 6 additions & 6 deletions src/internal/opCodes/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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