effect 4.0.0-rc.118 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -4
- package/dist/Array.d.ts +25 -25
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +16 -16
- package/dist/Array.js.map +1 -1
- package/dist/Chunk.d.ts +26 -26
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +15 -15
- package/dist/Chunk.js.map +1 -1
- package/dist/Effect.d.ts +17 -17
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +5 -5
- package/dist/MutableHashMap.d.ts.map +1 -1
- package/dist/MutableHashMap.js +4 -22
- package/dist/MutableHashMap.js.map +1 -1
- package/dist/Option.d.ts +17 -17
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +6 -6
- package/dist/Option.js.map +1 -1
- package/dist/Queue.d.ts +19 -2
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +9 -4
- package/dist/Queue.js.map +1 -1
- package/dist/Record.d.ts +14 -14
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +10 -10
- package/dist/Record.js.map +1 -1
- package/dist/Schema.d.ts +37 -21
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +29 -10
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +116 -97
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +3 -1
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +3 -1
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/ai/McpSchema.d.ts +110 -110
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +5 -1
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +32 -8
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +2 -1
- package/dist/cluster/MessageStorage.js.map +1 -1
- package/dist/cluster/Sharding.d.ts +5 -2
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +1 -1
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +15 -4
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/http/HttpEffect.d.ts +1 -0
- package/dist/http/HttpEffect.d.ts.map +1 -1
- package/dist/http/HttpEffect.js +29 -22
- package/dist/http/HttpEffect.js.map +1 -1
- package/dist/internal/effect.js +75 -84
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/schema/annotations.js +1 -7
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/codegen.js +56 -28
- package/dist/internal/schema/codegen.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +10 -30
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/schema/toCodec.js +1 -15
- package/dist/internal/schema/toCodec.js.map +1 -1
- package/dist/internal/schema/toEquivalence.js +4 -3
- package/dist/internal/schema/toEquivalence.js.map +1 -1
- package/dist/internal/schema/toFormatter.js +4 -4
- package/dist/internal/schema/toFormatter.js.map +1 -1
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +6 -2
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/reactivity/AtomRpc.d.ts +3 -3
- package/dist/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/rpc/Rpc.d.ts +2 -2
- package/dist/rpc/Rpc.d.ts.map +1 -1
- package/dist/rpc/RpcClient.d.ts +7 -7
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +1 -2
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcMessage.d.ts +1 -1
- package/dist/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/schema/SchemaCompiler/runtime.js +6 -1
- package/dist/schema/SchemaCompiler/runtime.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +234 -6
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +244 -25
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/workflow/DurableDeferred.js +1 -1
- package/dist/workflow/DurableDeferred.js.map +1 -1
- package/dist/workflow/Workflow.js +1 -1
- package/dist/workflow/Workflow.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +31 -31
- package/src/Chunk.ts +29 -29
- package/src/Effect.ts +17 -17
- package/src/MutableHashMap.ts +4 -24
- package/src/Option.ts +19 -19
- package/src/Queue.ts +26 -6
- package/src/Record.ts +20 -20
- package/src/Schema.ts +48 -24
- package/src/SchemaAST.ts +135 -115
- package/src/SchemaRepresentation.ts +3 -1
- package/src/cluster/ClusterWorkflowEngine.ts +8 -1
- package/src/cluster/MessageStorage.ts +22 -5
- package/src/cluster/Sharding.ts +8 -4
- package/src/cluster/SqlMessageStorage.ts +19 -8
- package/src/http/HttpEffect.ts +15 -9
- package/src/internal/effect.ts +37 -62
- package/src/internal/schema/annotations.ts +0 -9
- package/src/internal/schema/codegen.ts +90 -43
- package/src/internal/schema/toCodeDocument.ts +10 -47
- package/src/internal/schema/toCodec.ts +3 -16
- package/src/internal/schema/toEquivalence.ts +4 -5
- package/src/internal/schema/toFormatter.ts +4 -6
- package/src/reactivity/Atom.ts +6 -2
- package/src/reactivity/AtomRpc.ts +5 -5
- package/src/rpc/Rpc.ts +2 -2
- package/src/rpc/RpcClient.ts +9 -10
- package/src/rpc/RpcMessage.ts +1 -1
- package/src/schema/SchemaCompiler/runtime.ts +17 -1
- package/src/testing/TestSchema.ts +315 -63
- package/src/testing/index.ts +1 -0
- package/src/workflow/DurableDeferred.ts +1 -1
- package/src/workflow/Workflow.ts +1 -1
package/src/Array.ts
CHANGED
|
@@ -7770,7 +7770,7 @@ export const getSomes: <T extends Iterable<Option.Option<X>>, X = any>(
|
|
|
7770
7770
|
* ```
|
|
7771
7771
|
*
|
|
7772
7772
|
* @see {@link getSuccesses} — extract success values
|
|
7773
|
-
* @see {@link separate} — split into
|
|
7773
|
+
* @see {@link separate} — split into successes and failures
|
|
7774
7774
|
*
|
|
7775
7775
|
* @category filtering
|
|
7776
7776
|
* @since 4.0.0
|
|
@@ -7806,7 +7806,7 @@ export const getFailures = <T extends Iterable<Result.Result<any, any>>>(
|
|
|
7806
7806
|
* ```
|
|
7807
7807
|
*
|
|
7808
7808
|
* @see {@link getFailures} — extract failure values
|
|
7809
|
-
* @see {@link separate} — split into
|
|
7809
|
+
* @see {@link separate} — split into successes and failures
|
|
7810
7810
|
*
|
|
7811
7811
|
* @category filtering
|
|
7812
7812
|
* @since 4.0.0
|
|
@@ -7845,7 +7845,7 @@ export const getSuccesses = <T extends Iterable<Result.Result<any, any>>>(
|
|
|
7845
7845
|
* ```
|
|
7846
7846
|
*
|
|
7847
7847
|
* @see {@link filter} — keep original elements matching a predicate
|
|
7848
|
-
* @see {@link partition} for keeping both
|
|
7848
|
+
* @see {@link partition} for keeping both successes and failures
|
|
7849
7849
|
*
|
|
7850
7850
|
* @category filtering
|
|
7851
7851
|
* @since 2.0.0
|
|
@@ -7872,7 +7872,7 @@ export const filterMap: {
|
|
|
7872
7872
|
* ```
|
|
7873
7873
|
*
|
|
7874
7874
|
* @see {@link filter} — keep original elements matching a predicate
|
|
7875
|
-
* @see {@link partition} for keeping both
|
|
7875
|
+
* @see {@link partition} for keeping both successes and failures
|
|
7876
7876
|
*
|
|
7877
7877
|
* @category filtering
|
|
7878
7878
|
* @since 2.0.0
|
|
@@ -7899,7 +7899,7 @@ export const filterMap: {
|
|
|
7899
7899
|
* ```
|
|
7900
7900
|
*
|
|
7901
7901
|
* @see {@link filter} — keep original elements matching a predicate
|
|
7902
|
-
* @see {@link partition} for keeping both
|
|
7902
|
+
* @see {@link partition} for keeping both successes and failures
|
|
7903
7903
|
*
|
|
7904
7904
|
* @category filtering
|
|
7905
7905
|
* @since 2.0.0
|
|
@@ -8072,16 +8072,16 @@ export const filter: {
|
|
|
8072
8072
|
)
|
|
8073
8073
|
|
|
8074
8074
|
/**
|
|
8075
|
-
* Splits an iterable using a `Filter` into
|
|
8075
|
+
* Splits an iterable using a `Filter` into successes and failures.
|
|
8076
8076
|
*
|
|
8077
8077
|
* **When to use**
|
|
8078
8078
|
*
|
|
8079
8079
|
* Use to partition an iterable by evaluating each element with a
|
|
8080
|
-
* `Result`-returning filter and keeping both
|
|
8080
|
+
* `Result`-returning filter and keeping both success and failure values.
|
|
8081
8081
|
*
|
|
8082
8082
|
* **Details**
|
|
8083
8083
|
*
|
|
8084
|
-
* Returns `[
|
|
8084
|
+
* Returns `[passes, fails]`. The filter receives `(element, index)`.
|
|
8085
8085
|
*
|
|
8086
8086
|
* **Example** (Partitioning with a filter)
|
|
8087
8087
|
*
|
|
@@ -8090,7 +8090,7 @@ export const filter: {
|
|
|
8090
8090
|
*
|
|
8091
8091
|
* Array.partition([1, -2, 3], (n, i) =>
|
|
8092
8092
|
* n > 0 ? Result.succeed(n + i) : Result.fail(`negative:${n}`)
|
|
8093
|
-
* ) // => [["negative:-2"]
|
|
8093
|
+
* ) // => [[1, 5], ["negative:-2"]]
|
|
8094
8094
|
* ```
|
|
8095
8095
|
*
|
|
8096
8096
|
* @see {@link filter} — keep only matching elements
|
|
@@ -8102,16 +8102,16 @@ export const filter: {
|
|
|
8102
8102
|
*/
|
|
8103
8103
|
export const partition: {
|
|
8104
8104
|
/**
|
|
8105
|
-
* Splits an iterable using a `Filter` into
|
|
8105
|
+
* Splits an iterable using a `Filter` into successes and failures.
|
|
8106
8106
|
*
|
|
8107
8107
|
* **When to use**
|
|
8108
8108
|
*
|
|
8109
8109
|
* Use to partition an iterable by evaluating each element with a
|
|
8110
|
-
* `Result`-returning filter and keeping both
|
|
8110
|
+
* `Result`-returning filter and keeping both success and failure values.
|
|
8111
8111
|
*
|
|
8112
8112
|
* **Details**
|
|
8113
8113
|
*
|
|
8114
|
-
* Returns `[
|
|
8114
|
+
* Returns `[passes, fails]`. The filter receives `(element, index)`.
|
|
8115
8115
|
*
|
|
8116
8116
|
* **Example** (Partitioning with a filter)
|
|
8117
8117
|
*
|
|
@@ -8120,7 +8120,7 @@ export const partition: {
|
|
|
8120
8120
|
*
|
|
8121
8121
|
* Array.partition([1, -2, 3], (n, i) =>
|
|
8122
8122
|
* n > 0 ? Result.succeed(n + i) : Result.fail(`negative:${n}`)
|
|
8123
|
-
* ) // => [["negative:-2"]
|
|
8123
|
+
* ) // => [[1, 5], ["negative:-2"]]
|
|
8124
8124
|
* ```
|
|
8125
8125
|
*
|
|
8126
8126
|
* @see {@link filter} — keep only matching elements
|
|
@@ -8130,18 +8130,18 @@ export const partition: {
|
|
|
8130
8130
|
* @category filtering
|
|
8131
8131
|
* @since 2.0.0
|
|
8132
8132
|
*/
|
|
8133
|
-
<A, Pass, Fail>(f: (input: NoInfer<A>, i: number) => Result.Result<Pass, Fail>): (self: Iterable<A>) => [
|
|
8133
|
+
<A, Pass, Fail>(f: (input: NoInfer<A>, i: number) => Result.Result<Pass, Fail>): (self: Iterable<A>) => [passes: Array<Pass>, fails: Array<Fail>]
|
|
8134
8134
|
/**
|
|
8135
|
-
* Splits an iterable using a `Filter` into
|
|
8135
|
+
* Splits an iterable using a `Filter` into successes and failures.
|
|
8136
8136
|
*
|
|
8137
8137
|
* **When to use**
|
|
8138
8138
|
*
|
|
8139
8139
|
* Use to partition an iterable by evaluating each element with a
|
|
8140
|
-
* `Result`-returning filter and keeping both
|
|
8140
|
+
* `Result`-returning filter and keeping both success and failure values.
|
|
8141
8141
|
*
|
|
8142
8142
|
* **Details**
|
|
8143
8143
|
*
|
|
8144
|
-
* Returns `[
|
|
8144
|
+
* Returns `[passes, fails]`. The filter receives `(element, index)`.
|
|
8145
8145
|
*
|
|
8146
8146
|
* **Example** (Partitioning with a filter)
|
|
8147
8147
|
*
|
|
@@ -8150,7 +8150,7 @@ export const partition: {
|
|
|
8150
8150
|
*
|
|
8151
8151
|
* Array.partition([1, -2, 3], (n, i) =>
|
|
8152
8152
|
* n > 0 ? Result.succeed(n + i) : Result.fail(`negative:${n}`)
|
|
8153
|
-
* ) // => [["negative:-2"]
|
|
8153
|
+
* ) // => [[1, 5], ["negative:-2"]]
|
|
8154
8154
|
* ```
|
|
8155
8155
|
*
|
|
8156
8156
|
* @see {@link filter} — keep only matching elements
|
|
@@ -8160,38 +8160,38 @@ export const partition: {
|
|
|
8160
8160
|
* @category filtering
|
|
8161
8161
|
* @since 2.0.0
|
|
8162
8162
|
*/
|
|
8163
|
-
<A, Pass, Fail>(self: Iterable<A>, f: (input: A, i: number) => Result.Result<Pass, Fail>): [
|
|
8163
|
+
<A, Pass, Fail>(self: Iterable<A>, f: (input: A, i: number) => Result.Result<Pass, Fail>): [passes: Array<Pass>, fails: Array<Fail>]
|
|
8164
8164
|
} = dual(
|
|
8165
8165
|
2,
|
|
8166
8166
|
<A, Pass, Fail>(
|
|
8167
8167
|
self: Iterable<A>,
|
|
8168
8168
|
f: (input: A, i: number) => Result.Result<Pass, Fail>
|
|
8169
|
-
): [
|
|
8170
|
-
const
|
|
8171
|
-
const
|
|
8169
|
+
): [passes: Array<Pass>, fails: Array<Fail>] => {
|
|
8170
|
+
const passes: Array<Pass> = []
|
|
8171
|
+
const fails: Array<Fail> = []
|
|
8172
8172
|
let i = 0
|
|
8173
8173
|
for (const a of self) {
|
|
8174
8174
|
const result = f(a, i++)
|
|
8175
8175
|
if (Result.isSuccess(result)) {
|
|
8176
|
-
|
|
8176
|
+
passes.push(result.success)
|
|
8177
8177
|
} else {
|
|
8178
|
-
|
|
8178
|
+
fails.push(result.failure)
|
|
8179
8179
|
}
|
|
8180
8180
|
}
|
|
8181
|
-
return [
|
|
8181
|
+
return [passes, fails]
|
|
8182
8182
|
}
|
|
8183
8183
|
)
|
|
8184
8184
|
|
|
8185
8185
|
/**
|
|
8186
|
-
* Separates an iterable of `Result`s into
|
|
8186
|
+
* Separates an iterable of `Result`s into success values and failure values.
|
|
8187
8187
|
*
|
|
8188
8188
|
* **When to use**
|
|
8189
8189
|
*
|
|
8190
|
-
* Use to split an iterable of `Result` values into
|
|
8190
|
+
* Use to split an iterable of `Result` values into success and failure arrays.
|
|
8191
8191
|
*
|
|
8192
8192
|
* **Details**
|
|
8193
8193
|
*
|
|
8194
|
-
* Returns `[
|
|
8194
|
+
* Returns `[successes, failures]`. This is equivalent to
|
|
8195
8195
|
* `partition(identity)`.
|
|
8196
8196
|
*
|
|
8197
8197
|
* **Example** (Separating Results)
|
|
@@ -8199,7 +8199,7 @@ export const partition: {
|
|
|
8199
8199
|
* ```ts import.meta.vitest
|
|
8200
8200
|
* import { Array, Result } from "effect"
|
|
8201
8201
|
*
|
|
8202
|
-
* Array.separate([Result.succeed(1), Result.fail("error"), Result.succeed(2)]) // => [[
|
|
8202
|
+
* Array.separate([Result.succeed(1), Result.fail("error"), Result.succeed(2)]) // => [[1, 2], ["error"]]
|
|
8203
8203
|
* ```
|
|
8204
8204
|
*
|
|
8205
8205
|
* @see {@link getFailures} — extract only failures
|
|
@@ -8212,8 +8212,8 @@ export const partition: {
|
|
|
8212
8212
|
export const separate: <T extends Iterable<Result.Result<any, any>>>(
|
|
8213
8213
|
self: T
|
|
8214
8214
|
) => [
|
|
8215
|
-
|
|
8216
|
-
|
|
8215
|
+
successes: Array<Result.Result.Success<ReadonlyArray.Infer<T>>>,
|
|
8216
|
+
failures: Array<Result.Result.Failure<ReadonlyArray.Infer<T>>>
|
|
8217
8217
|
] = partition(identity)
|
|
8218
8218
|
|
|
8219
8219
|
/**
|
package/src/Chunk.ts
CHANGED
|
@@ -2854,23 +2854,23 @@ export const mapAccum: {
|
|
|
2854
2854
|
})
|
|
2855
2855
|
|
|
2856
2856
|
/**
|
|
2857
|
-
* Splits a chunk using a `Filter` into
|
|
2857
|
+
* Splits a chunk using a `Filter` into successes and failures.
|
|
2858
2858
|
*
|
|
2859
2859
|
* **Details**
|
|
2860
2860
|
*
|
|
2861
|
-
* Returns `[
|
|
2861
|
+
* Returns `[passes, fails]`. The filter receives `(element, index)`.
|
|
2862
2862
|
*
|
|
2863
2863
|
* **Example** (Partitioning with a Result)
|
|
2864
2864
|
*
|
|
2865
2865
|
* ```ts import.meta.vitest
|
|
2866
2866
|
* import { Chunk, Result } from "effect"
|
|
2867
2867
|
*
|
|
2868
|
-
* const [
|
|
2868
|
+
* const [passes, fails] = Chunk.partition(Chunk.make(1, -2, 3), (n, i) =>
|
|
2869
2869
|
* n > 0 ? Result.succeed(n + i) : Result.fail(`negative:${n}`)
|
|
2870
2870
|
* )
|
|
2871
2871
|
*
|
|
2872
|
-
* Chunk.toArray(
|
|
2873
|
-
* Chunk.toArray(
|
|
2872
|
+
* Chunk.toArray(passes) // => [1, 5]
|
|
2873
|
+
* Chunk.toArray(fails) // => ["negative:-2"]
|
|
2874
2874
|
* ```
|
|
2875
2875
|
*
|
|
2876
2876
|
* @category filtering
|
|
@@ -2878,74 +2878,74 @@ export const mapAccum: {
|
|
|
2878
2878
|
*/
|
|
2879
2879
|
export const partition: {
|
|
2880
2880
|
/**
|
|
2881
|
-
* Splits a chunk using a `Filter` into
|
|
2881
|
+
* Splits a chunk using a `Filter` into successes and failures.
|
|
2882
2882
|
*
|
|
2883
2883
|
* **Details**
|
|
2884
2884
|
*
|
|
2885
|
-
* Returns `[
|
|
2885
|
+
* Returns `[passes, fails]`. The filter receives `(element, index)`.
|
|
2886
2886
|
*
|
|
2887
2887
|
* **Example** (Partitioning with a Result)
|
|
2888
2888
|
*
|
|
2889
2889
|
* ```ts import.meta.vitest
|
|
2890
2890
|
* import { Chunk, Result } from "effect"
|
|
2891
2891
|
*
|
|
2892
|
-
* const [
|
|
2892
|
+
* const [passes, fails] = Chunk.partition(Chunk.make(1, -2, 3), (n, i) =>
|
|
2893
2893
|
* n > 0 ? Result.succeed(n + i) : Result.fail(`negative:${n}`)
|
|
2894
2894
|
* )
|
|
2895
2895
|
*
|
|
2896
|
-
* Chunk.toArray(
|
|
2897
|
-
* Chunk.toArray(
|
|
2896
|
+
* Chunk.toArray(passes) // => [1, 5]
|
|
2897
|
+
* Chunk.toArray(fails) // => ["negative:-2"]
|
|
2898
2898
|
* ```
|
|
2899
2899
|
*
|
|
2900
2900
|
* @category filtering
|
|
2901
2901
|
* @since 2.0.0
|
|
2902
2902
|
*/
|
|
2903
|
-
<A, Pass, Fail>(f: (input: NoInfer<A>, i: number) => Result<Pass, Fail>): (self: Chunk<A>) => [
|
|
2903
|
+
<A, Pass, Fail>(f: (input: NoInfer<A>, i: number) => Result<Pass, Fail>): (self: Chunk<A>) => [passes: Chunk<Pass>, fails: Chunk<Fail>]
|
|
2904
2904
|
/**
|
|
2905
|
-
* Splits a chunk using a `Filter` into
|
|
2905
|
+
* Splits a chunk using a `Filter` into successes and failures.
|
|
2906
2906
|
*
|
|
2907
2907
|
* **Details**
|
|
2908
2908
|
*
|
|
2909
|
-
* Returns `[
|
|
2909
|
+
* Returns `[passes, fails]`. The filter receives `(element, index)`.
|
|
2910
2910
|
*
|
|
2911
2911
|
* **Example** (Partitioning with a Result)
|
|
2912
2912
|
*
|
|
2913
2913
|
* ```ts import.meta.vitest
|
|
2914
2914
|
* import { Chunk, Result } from "effect"
|
|
2915
2915
|
*
|
|
2916
|
-
* const [
|
|
2916
|
+
* const [passes, fails] = Chunk.partition(Chunk.make(1, -2, 3), (n, i) =>
|
|
2917
2917
|
* n > 0 ? Result.succeed(n + i) : Result.fail(`negative:${n}`)
|
|
2918
2918
|
* )
|
|
2919
2919
|
*
|
|
2920
|
-
* Chunk.toArray(
|
|
2921
|
-
* Chunk.toArray(
|
|
2920
|
+
* Chunk.toArray(passes) // => [1, 5]
|
|
2921
|
+
* Chunk.toArray(fails) // => ["negative:-2"]
|
|
2922
2922
|
* ```
|
|
2923
2923
|
*
|
|
2924
2924
|
* @category filtering
|
|
2925
2925
|
* @since 2.0.0
|
|
2926
2926
|
*/
|
|
2927
|
-
<A, Pass, Fail>(self: Chunk<A>, f: (input: A, i: number) => Result<Pass, Fail>): [
|
|
2927
|
+
<A, Pass, Fail>(self: Chunk<A>, f: (input: A, i: number) => Result<Pass, Fail>): [passes: Chunk<Pass>, fails: Chunk<Fail>]
|
|
2928
2928
|
} = dual(
|
|
2929
2929
|
2,
|
|
2930
2930
|
<A, Pass, Fail>(
|
|
2931
2931
|
self: Chunk<A>,
|
|
2932
2932
|
f: (input: A, i: number) => Result<Pass, Fail>
|
|
2933
|
-
): [
|
|
2934
|
-
const [
|
|
2935
|
-
return [fromArrayUnsafe(
|
|
2933
|
+
): [passes: Chunk<Pass>, fails: Chunk<Fail>] => {
|
|
2934
|
+
const [passes, fails] = RA.partition(self, f)
|
|
2935
|
+
return [fromArrayUnsafe(passes), fromArrayUnsafe(fails)]
|
|
2936
2936
|
}
|
|
2937
2937
|
)
|
|
2938
2938
|
|
|
2939
2939
|
/**
|
|
2940
|
-
* Separates a chunk of `Result` values into a chunk of
|
|
2941
|
-
*
|
|
2940
|
+
* Separates a chunk of `Result` values into a chunk of successes and a chunk of
|
|
2941
|
+
* failures.
|
|
2942
2942
|
*
|
|
2943
2943
|
* **Details**
|
|
2944
2944
|
*
|
|
2945
|
-
* The returned tuple is `[
|
|
2945
|
+
* The returned tuple is `[successes, failures]`, preserving the original order
|
|
2946
2946
|
* within each side.
|
|
2947
2947
|
*
|
|
2948
|
-
* **Example** (Separating
|
|
2948
|
+
* **Example** (Separating successes and failures)
|
|
2949
2949
|
*
|
|
2950
2950
|
* ```ts import.meta.vitest
|
|
2951
2951
|
* import { Chunk, Result } from "effect"
|
|
@@ -2958,21 +2958,21 @@ export const partition: {
|
|
|
2958
2958
|
* Result.succeed(3)
|
|
2959
2959
|
* )
|
|
2960
2960
|
*
|
|
2961
|
-
* const [
|
|
2962
|
-
* Chunk.toArray(errors) // => ["error1", "error2"]
|
|
2961
|
+
* const [values, errors] = Chunk.separate(chunk)
|
|
2963
2962
|
* Chunk.toArray(values) // => [1, 2, 3]
|
|
2963
|
+
* Chunk.toArray(errors) // => ["error1", "error2"]
|
|
2964
2964
|
*
|
|
2965
2965
|
* // All successes
|
|
2966
2966
|
* const allSuccesses = Chunk.make(Result.succeed(1), Result.succeed(2))
|
|
2967
|
-
* const [
|
|
2968
|
-
* Chunk.toArray(noErrors) // => []
|
|
2967
|
+
* const [allValues, noErrors] = Chunk.separate(allSuccesses)
|
|
2969
2968
|
* Chunk.toArray(allValues) // => [1, 2]
|
|
2969
|
+
* Chunk.toArray(noErrors) // => []
|
|
2970
2970
|
* ```
|
|
2971
2971
|
*
|
|
2972
2972
|
* @category filtering
|
|
2973
2973
|
* @since 2.0.0
|
|
2974
2974
|
*/
|
|
2975
|
-
export const separate = <A, B>(self: Chunk<Result<B, A>>): [Chunk<
|
|
2975
|
+
export const separate = <A, B>(self: Chunk<Result<B, A>>): [Chunk<B>, Chunk<A>] =>
|
|
2976
2976
|
pipe(
|
|
2977
2977
|
RA.separate(toReadonlyArray(self)),
|
|
2978
2978
|
([l, r]) => [fromArrayUnsafe(l), fromArrayUnsafe(r)]
|
package/src/Effect.ts
CHANGED
|
@@ -503,13 +503,13 @@ export const all: <
|
|
|
503
503
|
) => All.Return<Arg, O> = internal.all
|
|
504
504
|
|
|
505
505
|
/**
|
|
506
|
-
* Applies an effectful function to each element and partitions
|
|
507
|
-
*
|
|
506
|
+
* Applies an effectful function to each element and partitions successes and
|
|
507
|
+
* failures.
|
|
508
508
|
*
|
|
509
509
|
* **Details**
|
|
510
510
|
*
|
|
511
|
-
* The returned tuple is `[
|
|
512
|
-
*
|
|
511
|
+
* The returned tuple is `[passes, fails]`, where `passes` contains all
|
|
512
|
+
* successes and `fails` contains all failures.
|
|
513
513
|
*
|
|
514
514
|
* This function runs every effect and never fails. Use `concurrency` to control
|
|
515
515
|
* parallelism.
|
|
@@ -523,7 +523,7 @@ export const all: <
|
|
|
523
523
|
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
524
524
|
* )
|
|
525
525
|
*
|
|
526
|
-
* await Effect.runPromise(program) // => [['0 is even', '2 is even']
|
|
526
|
+
* await Effect.runPromise(program) // => [[1, 3], ['0 is even', '2 is even']]
|
|
527
527
|
* ```
|
|
528
528
|
*
|
|
529
529
|
* @category collecting
|
|
@@ -531,13 +531,13 @@ export const all: <
|
|
|
531
531
|
*/
|
|
532
532
|
export const partition: {
|
|
533
533
|
/**
|
|
534
|
-
* Applies an effectful function to each element and partitions
|
|
535
|
-
*
|
|
534
|
+
* Applies an effectful function to each element and partitions successes and
|
|
535
|
+
* failures.
|
|
536
536
|
*
|
|
537
537
|
* **Details**
|
|
538
538
|
*
|
|
539
|
-
* The returned tuple is `[
|
|
540
|
-
*
|
|
539
|
+
* The returned tuple is `[passes, fails]`, where `passes` contains all
|
|
540
|
+
* successes and `fails` contains all failures.
|
|
541
541
|
*
|
|
542
542
|
* This function runs every effect and never fails. Use `concurrency` to control
|
|
543
543
|
* parallelism.
|
|
@@ -551,7 +551,7 @@ export const partition: {
|
|
|
551
551
|
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
552
552
|
* )
|
|
553
553
|
*
|
|
554
|
-
* await Effect.runPromise(program) // => [['0 is even', '2 is even']
|
|
554
|
+
* await Effect.runPromise(program) // => [[1, 3], ['0 is even', '2 is even']]
|
|
555
555
|
* ```
|
|
556
556
|
*
|
|
557
557
|
* @category collecting
|
|
@@ -560,15 +560,15 @@ export const partition: {
|
|
|
560
560
|
<A, B, E, R>(
|
|
561
561
|
f: (a: A, i: number) => Effect<B, E, R>,
|
|
562
562
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
563
|
-
): (elements: Iterable<A>) => Effect<[
|
|
563
|
+
): (elements: Iterable<A>) => Effect<[passes: Array<B>, fails: Array<E>], never, R>
|
|
564
564
|
/**
|
|
565
|
-
* Applies an effectful function to each element and partitions
|
|
566
|
-
*
|
|
565
|
+
* Applies an effectful function to each element and partitions successes and
|
|
566
|
+
* failures.
|
|
567
567
|
*
|
|
568
568
|
* **Details**
|
|
569
569
|
*
|
|
570
|
-
* The returned tuple is `[
|
|
571
|
-
*
|
|
570
|
+
* The returned tuple is `[passes, fails]`, where `passes` contains all
|
|
571
|
+
* successes and `fails` contains all failures.
|
|
572
572
|
*
|
|
573
573
|
* This function runs every effect and never fails. Use `concurrency` to control
|
|
574
574
|
* parallelism.
|
|
@@ -582,7 +582,7 @@ export const partition: {
|
|
|
582
582
|
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
583
583
|
* )
|
|
584
584
|
*
|
|
585
|
-
* await Effect.runPromise(program) // => [['0 is even', '2 is even']
|
|
585
|
+
* await Effect.runPromise(program) // => [[1, 3], ['0 is even', '2 is even']]
|
|
586
586
|
* ```
|
|
587
587
|
*
|
|
588
588
|
* @category collecting
|
|
@@ -592,7 +592,7 @@ export const partition: {
|
|
|
592
592
|
elements: Iterable<A>,
|
|
593
593
|
f: (a: A, i: number) => Effect<B, E, R>,
|
|
594
594
|
options?: { readonly concurrency?: Concurrency | undefined }
|
|
595
|
-
): Effect<[
|
|
595
|
+
): Effect<[passes: Array<B>, fails: Array<E>], never, R>
|
|
596
596
|
} = internal.partition
|
|
597
597
|
|
|
598
598
|
/**
|
package/src/MutableHashMap.ts
CHANGED
|
@@ -397,10 +397,6 @@ export const get: {
|
|
|
397
397
|
} else if (isSimpleKey(key)) {
|
|
398
398
|
return Option.none()
|
|
399
399
|
}
|
|
400
|
-
const refKey = referentialKeysCache.get(key)
|
|
401
|
-
if (refKey !== undefined && self.backing.has(refKey)) {
|
|
402
|
-
return Option.some(self.backing.get(refKey)!)
|
|
403
|
-
}
|
|
404
400
|
const hash = Hash.hash(key)
|
|
405
401
|
const bucket = self.buckets.get(hash)
|
|
406
402
|
if (bucket === undefined) {
|
|
@@ -409,7 +405,6 @@ export const get: {
|
|
|
409
405
|
return getFromBucket(self, bucket, key)
|
|
410
406
|
})
|
|
411
407
|
|
|
412
|
-
const referentialKeysCache = new WeakMap<any, any>()
|
|
413
408
|
const isSimpleKey = (u: unknown): boolean => typeof u !== "object" && typeof u !== "function"
|
|
414
409
|
|
|
415
410
|
/**
|
|
@@ -483,7 +478,6 @@ const getFromBucket = <K, V>(
|
|
|
483
478
|
for (let i = 0, len = bucket.length; i < len; i++) {
|
|
484
479
|
if (Equal.equals(key, bucket[i])) {
|
|
485
480
|
const refKey = bucket[i]
|
|
486
|
-
referentialKeysCache.set(key, refKey)
|
|
487
481
|
return Option.some(self.backing.get(refKey)!)
|
|
488
482
|
}
|
|
489
483
|
}
|
|
@@ -839,12 +833,6 @@ export const set: {
|
|
|
839
833
|
self.backing.set(key, value)
|
|
840
834
|
return self
|
|
841
835
|
}
|
|
842
|
-
let refKey = referentialKeysCache.get(key)
|
|
843
|
-
if (refKey !== undefined && self.backing.has(refKey)) {
|
|
844
|
-
self.backing.set(refKey, value)
|
|
845
|
-
return self
|
|
846
|
-
}
|
|
847
|
-
|
|
848
836
|
const hash = Hash.hash(key)
|
|
849
837
|
const bucket = self.buckets.get(hash)
|
|
850
838
|
if (bucket === undefined) {
|
|
@@ -853,7 +841,7 @@ export const set: {
|
|
|
853
841
|
return self
|
|
854
842
|
}
|
|
855
843
|
|
|
856
|
-
refKey = getRefKey(bucket, key)
|
|
844
|
+
let refKey = getRefKey(bucket, key)
|
|
857
845
|
if (refKey === undefined) {
|
|
858
846
|
bucket.push(key)
|
|
859
847
|
refKey = key
|
|
@@ -868,7 +856,6 @@ const getRefKey = <K>(
|
|
|
868
856
|
) => {
|
|
869
857
|
for (let i = 0, len = bucket.length; i < len; i++) {
|
|
870
858
|
if (Equal.equals(key, bucket[i])) {
|
|
871
|
-
referentialKeysCache.set(key, bucket[i])
|
|
872
859
|
return bucket[i]
|
|
873
860
|
}
|
|
874
861
|
}
|
|
@@ -1083,19 +1070,13 @@ export const modify: {
|
|
|
1083
1070
|
}
|
|
1084
1071
|
return self
|
|
1085
1072
|
}
|
|
1086
|
-
let refKey = referentialKeysCache.get(key)
|
|
1087
|
-
if (refKey !== undefined && self.backing.has(refKey)) {
|
|
1088
|
-
self.backing.set(refKey, f(self.backing.get(refKey)!))
|
|
1089
|
-
return self
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
1073
|
const hash = Hash.hash(key)
|
|
1093
1074
|
const bucket = self.buckets.get(hash)
|
|
1094
1075
|
if (bucket === undefined) {
|
|
1095
1076
|
return self
|
|
1096
1077
|
}
|
|
1097
1078
|
|
|
1098
|
-
refKey = getRefKey(bucket, key)
|
|
1079
|
+
const refKey = getRefKey(bucket, key)
|
|
1099
1080
|
if (refKey === undefined) {
|
|
1100
1081
|
return self
|
|
1101
1082
|
}
|
|
@@ -1607,15 +1588,14 @@ export const remove: {
|
|
|
1607
1588
|
return self
|
|
1608
1589
|
}
|
|
1609
1590
|
|
|
1610
|
-
const
|
|
1611
|
-
const hash = Hash.hash(key)
|
|
1591
|
+
const hash = Hash.hash(key_)
|
|
1612
1592
|
const bucket = self.buckets.get(hash)
|
|
1613
1593
|
if (bucket === undefined) {
|
|
1614
1594
|
return self
|
|
1615
1595
|
}
|
|
1616
1596
|
for (let i = 0, len = bucket.length; i < len; i++) {
|
|
1617
1597
|
const bkey = bucket[i]
|
|
1618
|
-
if (bkey ===
|
|
1598
|
+
if (bkey === key_ || Equal.equals(key_, bkey)) {
|
|
1619
1599
|
self.backing.delete(bkey)
|
|
1620
1600
|
bucket.splice(i, 1)
|
|
1621
1601
|
break
|
package/src/Option.ts
CHANGED
|
@@ -3185,14 +3185,14 @@ export const toArray = <A>(self: Option<A>): Array<A> => isNone(self) ? [] : [se
|
|
|
3185
3185
|
*
|
|
3186
3186
|
* **When to use**
|
|
3187
3187
|
*
|
|
3188
|
-
* Use when you need to split an optional value into
|
|
3188
|
+
* Use when you need to split an optional value into success and failure
|
|
3189
3189
|
* channels using a `Result`-returning function.
|
|
3190
3190
|
*
|
|
3191
3191
|
* **Details**
|
|
3192
3192
|
*
|
|
3193
3193
|
* - `None` → `[None, None]`
|
|
3194
|
-
* - `Some` where `f` returns `
|
|
3195
|
-
* - `Some` where `f` returns `
|
|
3194
|
+
* - `Some` where `f` returns `Ok` → `[Some(value), None]`
|
|
3195
|
+
* - `Some` where `f` returns `Err` → `[None, Some(error)]`
|
|
3196
3196
|
*
|
|
3197
3197
|
* **Example** (Partitioning by Result)
|
|
3198
3198
|
*
|
|
@@ -3204,8 +3204,8 @@ export const toArray = <A>(self: Option<A>): Array<A> => isNone(self) ? [] : [se
|
|
|
3204
3204
|
* return isNaN(n) ? Result.fail("Not a number") : Result.succeed(n)
|
|
3205
3205
|
* }
|
|
3206
3206
|
*
|
|
3207
|
-
* Option.partitionMap(Option.some("42"), parseNumber) // => [Option.
|
|
3208
|
-
* Option.partitionMap(Option.some("abc"), parseNumber) // => [Option.some("Not a number")
|
|
3207
|
+
* Option.partitionMap(Option.some("42"), parseNumber) // => [Option.some(42), Option.none()]
|
|
3208
|
+
* Option.partitionMap(Option.some("abc"), parseNumber) // => [Option.none(), Option.some("Not a number")]
|
|
3209
3209
|
* Option.partitionMap(Option.none(), parseNumber) // => [Option.none(), Option.none()]
|
|
3210
3210
|
* ```
|
|
3211
3211
|
*
|
|
@@ -3220,14 +3220,14 @@ export const partitionMap: {
|
|
|
3220
3220
|
*
|
|
3221
3221
|
* **When to use**
|
|
3222
3222
|
*
|
|
3223
|
-
* Use when you need to split an optional value into
|
|
3223
|
+
* Use when you need to split an optional value into success and failure
|
|
3224
3224
|
* channels using a `Result`-returning function.
|
|
3225
3225
|
*
|
|
3226
3226
|
* **Details**
|
|
3227
3227
|
*
|
|
3228
3228
|
* - `None` → `[None, None]`
|
|
3229
|
-
* - `Some` where `f` returns `
|
|
3230
|
-
* - `Some` where `f` returns `
|
|
3229
|
+
* - `Some` where `f` returns `Ok` → `[Some(value), None]`
|
|
3230
|
+
* - `Some` where `f` returns `Err` → `[None, Some(error)]`
|
|
3231
3231
|
*
|
|
3232
3232
|
* **Example** (Partitioning by Result)
|
|
3233
3233
|
*
|
|
@@ -3239,8 +3239,8 @@ export const partitionMap: {
|
|
|
3239
3239
|
* return isNaN(n) ? Result.fail("Not a number") : Result.succeed(n)
|
|
3240
3240
|
* }
|
|
3241
3241
|
*
|
|
3242
|
-
* Option.partitionMap(Option.some("42"), parseNumber) // => [Option.
|
|
3243
|
-
* Option.partitionMap(Option.some("abc"), parseNumber) // => [Option.some("Not a number")
|
|
3242
|
+
* Option.partitionMap(Option.some("42"), parseNumber) // => [Option.some(42), Option.none()]
|
|
3243
|
+
* Option.partitionMap(Option.some("abc"), parseNumber) // => [Option.none(), Option.some("Not a number")]
|
|
3244
3244
|
* Option.partitionMap(Option.none(), parseNumber) // => [Option.none(), Option.none()]
|
|
3245
3245
|
* ```
|
|
3246
3246
|
*
|
|
@@ -3249,20 +3249,20 @@ export const partitionMap: {
|
|
|
3249
3249
|
* @category filtering
|
|
3250
3250
|
* @since 2.0.0
|
|
3251
3251
|
*/
|
|
3252
|
-
<A, B, C>(f: (a: A) => Result<C, B>): (self: Option<A>) => [
|
|
3252
|
+
<A, B, C>(f: (a: A) => Result<C, B>): (self: Option<A>) => [passes: Option<C>, fails: Option<B>]
|
|
3253
3253
|
/**
|
|
3254
3254
|
* Splits an `Option` into two `Option`s using a function that returns a `Result`.
|
|
3255
3255
|
*
|
|
3256
3256
|
* **When to use**
|
|
3257
3257
|
*
|
|
3258
|
-
* Use when you need to split an optional value into
|
|
3258
|
+
* Use when you need to split an optional value into success and failure
|
|
3259
3259
|
* channels using a `Result`-returning function.
|
|
3260
3260
|
*
|
|
3261
3261
|
* **Details**
|
|
3262
3262
|
*
|
|
3263
3263
|
* - `None` → `[None, None]`
|
|
3264
|
-
* - `Some` where `f` returns `
|
|
3265
|
-
* - `Some` where `f` returns `
|
|
3264
|
+
* - `Some` where `f` returns `Ok` → `[Some(value), None]`
|
|
3265
|
+
* - `Some` where `f` returns `Err` → `[None, Some(error)]`
|
|
3266
3266
|
*
|
|
3267
3267
|
* **Example** (Partitioning by Result)
|
|
3268
3268
|
*
|
|
@@ -3274,8 +3274,8 @@ export const partitionMap: {
|
|
|
3274
3274
|
* return isNaN(n) ? Result.fail("Not a number") : Result.succeed(n)
|
|
3275
3275
|
* }
|
|
3276
3276
|
*
|
|
3277
|
-
* Option.partitionMap(Option.some("42"), parseNumber) // => [Option.
|
|
3278
|
-
* Option.partitionMap(Option.some("abc"), parseNumber) // => [Option.some("Not a number")
|
|
3277
|
+
* Option.partitionMap(Option.some("42"), parseNumber) // => [Option.some(42), Option.none()]
|
|
3278
|
+
* Option.partitionMap(Option.some("abc"), parseNumber) // => [Option.none(), Option.some("Not a number")]
|
|
3279
3279
|
* Option.partitionMap(Option.none(), parseNumber) // => [Option.none(), Option.none()]
|
|
3280
3280
|
* ```
|
|
3281
3281
|
*
|
|
@@ -3284,16 +3284,16 @@ export const partitionMap: {
|
|
|
3284
3284
|
* @category filtering
|
|
3285
3285
|
* @since 2.0.0
|
|
3286
3286
|
*/
|
|
3287
|
-
<A, B, C>(self: Option<A>, f: (a: A) => Result<C, B>): [
|
|
3287
|
+
<A, B, C>(self: Option<A>, f: (a: A) => Result<C, B>): [passes: Option<C>, fails: Option<B>]
|
|
3288
3288
|
} = dual(2, <A, B, C>(
|
|
3289
3289
|
self: Option<A>,
|
|
3290
3290
|
f: (a: A) => Result<C, B>
|
|
3291
|
-
): [
|
|
3291
|
+
): [passes: Option<C>, fails: Option<B>] => {
|
|
3292
3292
|
if (isNone(self)) {
|
|
3293
3293
|
return [none(), none()]
|
|
3294
3294
|
}
|
|
3295
3295
|
const e = f(self.value)
|
|
3296
|
-
return result.isFailure(e) ? [some(e.failure)
|
|
3296
|
+
return result.isFailure(e) ? [none(), some(e.failure)] : [some(e.success), none()]
|
|
3297
3297
|
})
|
|
3298
3298
|
|
|
3299
3299
|
/**
|