diff --git a/.changeset/real-kangaroos-push.md b/.changeset/real-kangaroos-push.md
new file mode 100644
index 00000000000..b01f92b2f11
--- /dev/null
+++ b/.changeset/real-kangaroos-push.md
@@ -0,0 +1,5 @@
+---
+"effect": minor
+---
+
+The signatures of the `HaltStrategy.match` `StreamHaltStrategy.match` functions have been changed to the generally accepted ones
diff --git a/packages/effect/src/ExecutionStrategy.ts b/packages/effect/src/ExecutionStrategy.ts
index 94cdb14956c..5dba91eda74 100644
--- a/packages/effect/src/ExecutionStrategy.ts
+++ b/packages/effect/src/ExecutionStrategy.ts
@@ -106,6 +106,14 @@ export const isParallelN: (self: ExecutionStrategy) => self is ParallelN = inter
* @category folding
*/
export const match: {
- (onSequential: LazyArg, onParallel: LazyArg, onParallelN: (n: number) => A): (self: ExecutionStrategy) => A
- (self: ExecutionStrategy, onSequential: LazyArg, onParallel: LazyArg, onParallelN: (n: number) => A): A
+ (options: {
+ readonly onSequential: LazyArg
+ readonly onParallel: LazyArg
+ readonly onParallelN: (n: number) => A
+ }): (self: ExecutionStrategy) => A
+ (self: ExecutionStrategy, options: {
+ readonly onSequential: LazyArg
+ readonly onParallel: LazyArg
+ readonly onParallelN: (n: number) => A
+ }): A
} = internal.match
diff --git a/packages/effect/src/StreamHaltStrategy.ts b/packages/effect/src/StreamHaltStrategy.ts
index 1a582d3b782..5d7b055afbf 100644
--- a/packages/effect/src/StreamHaltStrategy.ts
+++ b/packages/effect/src/StreamHaltStrategy.ts
@@ -102,10 +102,22 @@ export const isBoth: (self: HaltStrategy) => self is Both = internal.isBoth
export const isEither: (self: HaltStrategy) => self is Either = internal.isEither
/**
+ * Folds over the specified `HaltStrategy` using the provided case functions.
+ *
* @since 2.0.0
* @category folding
*/
export const match: {
- (onLeft: () => Z, onRight: () => Z, onBoth: () => Z, onEither: () => Z): (self: HaltStrategy) => Z
- (self: HaltStrategy, onLeft: () => Z, onRight: () => Z, onBoth: () => Z, onEither: () => Z): Z
+ (options: {
+ readonly onLeft: () => Z
+ readonly onRight: () => Z
+ readonly onBoth: () => Z
+ readonly onEither: () => Z
+ }): (self: HaltStrategy) => Z
+ (self: HaltStrategy, options: {
+ readonly onLeft: () => Z
+ readonly onRight: () => Z
+ readonly onBoth: () => Z
+ readonly onEither: () => Z
+ }): Z
} = internal.match
diff --git a/packages/effect/src/internal/executionStrategy.ts b/packages/effect/src/internal/executionStrategy.ts
index fbd78740296..426a0d93d21 100644
--- a/packages/effect/src/internal/executionStrategy.ts
+++ b/packages/effect/src/internal/executionStrategy.ts
@@ -46,27 +46,29 @@ export const isParallelN = (self: ExecutionStrategy.ExecutionStrategy): self is
/** @internal */
export const match = dual<
- (
- onSequential: LazyArg,
- onParallel: LazyArg,
- onParallelN: (n: number) => A
- ) => (self: ExecutionStrategy.ExecutionStrategy) => A,
+ (options: {
+ readonly onSequential: LazyArg
+ readonly onParallel: LazyArg
+ readonly onParallelN: (n: number) => A
+ }) => (self: ExecutionStrategy.ExecutionStrategy) => A,
(
self: ExecutionStrategy.ExecutionStrategy,
- onSequential: LazyArg,
- onParallel: LazyArg,
- onParallelN: (n: number) => A
+ options: {
+ readonly onSequential: LazyArg
+ readonly onParallel: LazyArg
+ readonly onParallelN: (n: number) => A
+ }
) => A
->(4, (self, onSequential, onParallel, onParallelN) => {
+>(2, (self, options) => {
switch (self._tag) {
case OP_SEQUENTIAL: {
- return onSequential()
+ return options.onSequential()
}
case OP_PARALLEL: {
- return onParallel()
+ return options.onParallel()
}
case OP_PARALLEL_N: {
- return onParallelN(self.parallelism)
+ return options.onParallelN(self.parallelism)
}
}
})
diff --git a/packages/effect/src/internal/stream/haltStrategy.ts b/packages/effect/src/internal/stream/haltStrategy.ts
index 1ffe4dad61c..0115554ef47 100644
--- a/packages/effect/src/internal/stream/haltStrategy.ts
+++ b/packages/effect/src/internal/stream/haltStrategy.ts
@@ -53,33 +53,42 @@ export const isEither = (self: HaltStrategy.HaltStrategy): self is HaltStrategy.
/** @internal */
export const match = dual<
- (onLeft: () => Z, onRight: () => Z, onBoth: () => Z, onEither: () => Z) => (self: HaltStrategy.HaltStrategy) => Z,
+ (options: {
+ readonly onLeft: () => Z
+ readonly onRight: () => Z
+ readonly onBoth: () => Z
+ readonly onEither: () => Z
+ }) => (self: HaltStrategy.HaltStrategy) => Z,
(
self: HaltStrategy.HaltStrategy,
- onLeft: () => Z,
- onRight: () => Z,
- onBoth: () => Z,
- onEither: () => Z
+ options: {
+ readonly onLeft: () => Z
+ readonly onRight: () => Z
+ readonly onBoth: () => Z
+ readonly onEither: () => Z
+ }
) => Z
->(5, (
+>(2, (
self: HaltStrategy.HaltStrategy,
- onLeft: () => Z,
- onRight: () => Z,
- onBoth: () => Z,
- onEither: () => Z
+ options: {
+ readonly onLeft: () => Z
+ readonly onRight: () => Z
+ readonly onBoth: () => Z
+ readonly onEither: () => Z
+ }
): Z => {
switch (self._tag) {
case OpCodes.OP_LEFT: {
- return onLeft()
+ return options.onLeft()
}
case OpCodes.OP_RIGHT: {
- return onRight()
+ return options.onRight()
}
case OpCodes.OP_BOTH: {
- return onBoth()
+ return options.onBoth()
}
case OpCodes.OP_EITHER: {
- return onEither()
+ return options.onEither()
}
}
})