effect 4.0.0-beta.40 → 4.0.0-beta.42
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/dist/BigDecimal.d.ts +36 -0
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +52 -0
- package/dist/BigDecimal.js.map +1 -1
- package/dist/Effect.d.ts +20 -63
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +24 -65
- package/dist/Effect.js.map +1 -1
- package/dist/Layer.js +1 -1
- package/dist/Layer.js.map +1 -1
- package/dist/ManagedRuntime.d.ts.map +1 -1
- package/dist/ManagedRuntime.js +19 -7
- package/dist/ManagedRuntime.js.map +1 -1
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +3 -0
- package/dist/MutableList.js.map +1 -1
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +12 -3
- package/dist/Number.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +16 -14
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/ServiceMap.d.ts +14 -26
- package/dist/ServiceMap.d.ts.map +1 -1
- package/dist/ServiceMap.js +6 -5
- package/dist/ServiceMap.js.map +1 -1
- package/dist/TxChunk.d.ts +39 -39
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +3 -3
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +9 -9
- package/dist/TxDeferred.d.ts.map +1 -1
- package/dist/TxDeferred.js +2 -2
- package/dist/TxDeferred.js.map +1 -1
- package/dist/TxHashMap.d.ts +59 -59
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +8 -8
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +35 -35
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +7 -7
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +23 -23
- package/dist/TxPriorityQueue.d.ts.map +1 -1
- package/dist/TxPriorityQueue.js +4 -4
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/TxPubSub.d.ts +14 -14
- package/dist/TxPubSub.d.ts.map +1 -1
- package/dist/TxPubSub.js +12 -12
- package/dist/TxPubSub.js.map +1 -1
- package/dist/TxQueue.d.ts +33 -33
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +29 -44
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +10 -33
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +14 -37
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/TxRef.d.ts +36 -42
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +16 -25
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +8 -8
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +10 -10
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +14 -14
- package/dist/TxSubscriptionRef.d.ts.map +1 -1
- package/dist/TxSubscriptionRef.js +5 -5
- package/dist/TxSubscriptionRef.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/internal/effect.js +3 -0
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/schema/representation.js +28 -0
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +31 -2
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +68 -6
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +88 -11
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/OpenAiStructuredOutput.js +3 -0
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +1 -1
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +12 -1
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.d.ts +18 -0
- package/dist/unstable/cluster/ClusterSchema.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterSchema.js +21 -1
- package/dist/unstable/cluster/ClusterSchema.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +6 -3
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js +1 -0
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +4 -2
- package/dist/unstable/cluster/Message.d.ts.map +1 -1
- package/dist/unstable/cluster/Message.js +13 -6
- package/dist/unstable/cluster/Message.js.map +1 -1
- package/dist/unstable/cluster/MessageStorage.d.ts +23 -0
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +22 -7
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +24 -20
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +3 -1
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +10 -4
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/http/index.d.ts +2 -2
- package/dist/unstable/http/index.d.ts.map +1 -1
- package/dist/unstable/http/index.js +2 -2
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +1 -3
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts +1 -0
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +1 -0
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +43 -26
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +1 -1
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +5 -0
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +13 -0
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/package.json +1 -1
- package/src/BigDecimal.ts +54 -0
- package/src/Effect.ts +25 -75
- package/src/Layer.ts +1 -1
- package/src/ManagedRuntime.ts +33 -20
- package/src/MutableList.ts +3 -0
- package/src/Number.ts +13 -3
- package/src/SchemaRepresentation.ts +8 -6
- package/src/ServiceMap.ts +16 -31
- package/src/TxChunk.ts +53 -62
- package/src/TxDeferred.ts +14 -17
- package/src/TxHashMap.ts +91 -101
- package/src/TxHashSet.ts +68 -70
- package/src/TxPriorityQueue.ts +34 -38
- package/src/TxPubSub.ts +30 -32
- package/src/TxQueue.ts +70 -84
- package/src/TxReentrantLock.ts +30 -54
- package/src/TxRef.ts +53 -65
- package/src/TxSemaphore.ts +23 -24
- package/src/TxSubscriptionRef.ts +25 -27
- package/src/index.ts +6 -6
- package/src/internal/effect.ts +3 -0
- package/src/internal/schema/representation.ts +28 -0
- package/src/unstable/ai/Chat.ts +79 -18
- package/src/unstable/ai/LanguageModel.ts +182 -66
- package/src/unstable/ai/OpenAiStructuredOutput.ts +3 -0
- package/src/unstable/cli/Prompt.ts +3 -1
- package/src/unstable/cli/internal/command.ts +16 -1
- package/src/unstable/cluster/ClusterSchema.ts +29 -1
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +22 -3
- package/src/unstable/cluster/Entity.ts +1 -0
- package/src/unstable/cluster/Message.ts +22 -10
- package/src/unstable/cluster/MessageStorage.ts +37 -6
- package/src/unstable/cluster/Sharding.ts +31 -23
- package/src/unstable/cluster/SqlMessageStorage.ts +6 -1
- package/src/unstable/cluster/internal/entityManager.ts +14 -5
- package/src/unstable/http/index.ts +2 -2
- package/src/unstable/httpapi/HttpApiSchema.ts +1 -1
- package/src/unstable/httpapi/OpenApi.ts +1 -0
- package/src/unstable/rpc/Rpc.ts +1 -0
- package/src/unstable/rpc/RpcClient.ts +45 -33
- package/src/unstable/socket/Socket.ts +1 -1
- package/src/unstable/workflow/Activity.ts +23 -0
package/src/TxChunk.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Accessed values are tracked by the transaction in order to detect conflicts and to track changes.
|
|
7
7
|
* A transaction will retry whenever a conflict is detected or whenever the transaction explicitly
|
|
8
|
-
* calls `Effect.
|
|
8
|
+
* calls `Effect.txRetry` and any of the accessed TxChunk values change.
|
|
9
9
|
*
|
|
10
10
|
* @since 4.0.0
|
|
11
11
|
*/
|
|
@@ -28,7 +28,7 @@ const TypeId = "~effect/transactions/TxChunk"
|
|
|
28
28
|
*
|
|
29
29
|
* Accessed values are tracked by the transaction in order to detect conflicts and to track changes.
|
|
30
30
|
* A transaction will retry whenever a conflict is detected or whenever the transaction explicitly
|
|
31
|
-
* calls `Effect.
|
|
31
|
+
* calls `Effect.txRetry` and any of the accessed TxChunk values change.
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
34
|
* ```ts
|
|
@@ -48,7 +48,7 @@ const TypeId = "~effect/transactions/TxChunk"
|
|
|
48
48
|
* console.log(Chunk.toReadonlyArray(result)) // [1, 2, 3, 4]
|
|
49
49
|
*
|
|
50
50
|
* // Multi-step atomic operation - use explicit transaction
|
|
51
|
-
* yield* Effect.
|
|
51
|
+
* yield* Effect.tx(
|
|
52
52
|
* Effect.gen(function*() {
|
|
53
53
|
* yield* TxChunk.prepend(txChunk, 0)
|
|
54
54
|
* yield* TxChunk.append(txChunk, 5)
|
|
@@ -109,7 +109,7 @@ const TxChunkProto = {
|
|
|
109
109
|
* })
|
|
110
110
|
* ```
|
|
111
111
|
*/
|
|
112
|
-
export const make = <A>(initial: Chunk.Chunk<A>): Effect.Effect<TxChunk<A
|
|
112
|
+
export const make = <A>(initial: Chunk.Chunk<A>): Effect.Effect<TxChunk<A>> =>
|
|
113
113
|
Effect.map(TxRef.make(initial), (ref) => makeUnsafe(ref))
|
|
114
114
|
|
|
115
115
|
/**
|
|
@@ -140,7 +140,7 @@ export const make = <A>(initial: Chunk.Chunk<A>): Effect.Effect<TxChunk<A>, neve
|
|
|
140
140
|
* })
|
|
141
141
|
* ```
|
|
142
142
|
*/
|
|
143
|
-
export const empty = <A = never>(): Effect.Effect<TxChunk<A
|
|
143
|
+
export const empty = <A = never>(): Effect.Effect<TxChunk<A>> =>
|
|
144
144
|
Effect.map(TxRef.make(Chunk.empty<A>()), (ref) => makeUnsafe(ref))
|
|
145
145
|
|
|
146
146
|
/**
|
|
@@ -164,7 +164,7 @@ export const empty = <A = never>(): Effect.Effect<TxChunk<A>, never, Effect.Tran
|
|
|
164
164
|
* console.log(Chunk.toReadonlyArray(chunk)) // [1, 2, 3, 4, 5]
|
|
165
165
|
*
|
|
166
166
|
* // Multi-step atomic modification - use explicit transaction
|
|
167
|
-
* yield* Effect.
|
|
167
|
+
* yield* Effect.tx(
|
|
168
168
|
* Effect.gen(function*() {
|
|
169
169
|
* yield* TxChunk.append(txChunk, 6)
|
|
170
170
|
* yield* TxChunk.prepend(txChunk, 0)
|
|
@@ -176,7 +176,7 @@ export const empty = <A = never>(): Effect.Effect<TxChunk<A>, never, Effect.Tran
|
|
|
176
176
|
* })
|
|
177
177
|
* ```
|
|
178
178
|
*/
|
|
179
|
-
export const fromIterable = <A>(iterable: Iterable<A>): Effect.Effect<TxChunk<A
|
|
179
|
+
export const fromIterable = <A>(iterable: Iterable<A>): Effect.Effect<TxChunk<A>> =>
|
|
180
180
|
Effect.map(TxRef.make(Chunk.fromIterable(iterable)), (ref) => makeUnsafe(ref))
|
|
181
181
|
|
|
182
182
|
/**
|
|
@@ -263,9 +263,7 @@ export const modify: {
|
|
|
263
263
|
*/
|
|
264
264
|
<A, R>(
|
|
265
265
|
f: (current: Chunk.Chunk<NoInfer<A>>) => [returnValue: R, newValue: Chunk.Chunk<A>]
|
|
266
|
-
): (
|
|
267
|
-
self: TxChunk<A>
|
|
268
|
-
) => Effect.Effect<R, never, Effect.Transaction>
|
|
266
|
+
): (self: TxChunk<A>) => Effect.Effect<R>
|
|
269
267
|
/**
|
|
270
268
|
* Modifies the value of the `TxChunk` using the provided function.
|
|
271
269
|
*
|
|
@@ -297,13 +295,13 @@ export const modify: {
|
|
|
297
295
|
<A, R>(
|
|
298
296
|
self: TxChunk<A>,
|
|
299
297
|
f: (current: Chunk.Chunk<A>) => [returnValue: R, newValue: Chunk.Chunk<A>]
|
|
300
|
-
): Effect.Effect<R
|
|
298
|
+
): Effect.Effect<R>
|
|
301
299
|
} = dual(
|
|
302
300
|
2,
|
|
303
301
|
<A, R>(
|
|
304
302
|
self: TxChunk<A>,
|
|
305
303
|
f: (current: Chunk.Chunk<A>) => [returnValue: R, newValue: Chunk.Chunk<A>]
|
|
306
|
-
): Effect.Effect<R
|
|
304
|
+
): Effect.Effect<R> => TxRef.modify(self.ref, f)
|
|
307
305
|
)
|
|
308
306
|
|
|
309
307
|
/**
|
|
@@ -357,7 +355,7 @@ export const update: {
|
|
|
357
355
|
* @since 4.0.0
|
|
358
356
|
* @category combinators
|
|
359
357
|
*/
|
|
360
|
-
<A>(f: (current: Chunk.Chunk<NoInfer<A>>) => Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void
|
|
358
|
+
<A>(f: (current: Chunk.Chunk<NoInfer<A>>) => Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void>
|
|
361
359
|
/**
|
|
362
360
|
* Updates the value of the `TxChunk` using the provided function.
|
|
363
361
|
*
|
|
@@ -383,13 +381,13 @@ export const update: {
|
|
|
383
381
|
* @since 4.0.0
|
|
384
382
|
* @category combinators
|
|
385
383
|
*/
|
|
386
|
-
<A>(self: TxChunk<A>, f: (current: Chunk.Chunk<A>) => Chunk.Chunk<A>): Effect.Effect<void
|
|
384
|
+
<A>(self: TxChunk<A>, f: (current: Chunk.Chunk<A>) => Chunk.Chunk<A>): Effect.Effect<void>
|
|
387
385
|
} = dual(
|
|
388
386
|
2,
|
|
389
387
|
<A>(
|
|
390
388
|
self: TxChunk<A>,
|
|
391
389
|
f: (current: Chunk.Chunk<A>) => Chunk.Chunk<A>
|
|
392
|
-
): Effect.Effect<void
|
|
390
|
+
): Effect.Effect<void> => TxRef.update(self.ref, f)
|
|
393
391
|
)
|
|
394
392
|
|
|
395
393
|
/**
|
|
@@ -415,8 +413,7 @@ export const update: {
|
|
|
415
413
|
* @since 4.0.0
|
|
416
414
|
* @category combinators
|
|
417
415
|
*/
|
|
418
|
-
export const get = <A>(self: TxChunk<A>): Effect.Effect<Chunk.Chunk<A
|
|
419
|
-
TxRef.get(self.ref)
|
|
416
|
+
export const get = <A>(self: TxChunk<A>): Effect.Effect<Chunk.Chunk<A>> => TxRef.get(self.ref)
|
|
420
417
|
|
|
421
418
|
/**
|
|
422
419
|
* Sets the value of the `TxChunk`.
|
|
@@ -469,7 +466,7 @@ export const set: {
|
|
|
469
466
|
* @since 4.0.0
|
|
470
467
|
* @category combinators
|
|
471
468
|
*/
|
|
472
|
-
<A>(chunk: Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void
|
|
469
|
+
<A>(chunk: Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void>
|
|
473
470
|
/**
|
|
474
471
|
* Sets the value of the `TxChunk`.
|
|
475
472
|
*
|
|
@@ -495,11 +492,10 @@ export const set: {
|
|
|
495
492
|
* @since 4.0.0
|
|
496
493
|
* @category combinators
|
|
497
494
|
*/
|
|
498
|
-
<A>(self: TxChunk<A>, chunk: Chunk.Chunk<A>): Effect.Effect<void
|
|
495
|
+
<A>(self: TxChunk<A>, chunk: Chunk.Chunk<A>): Effect.Effect<void>
|
|
499
496
|
} = dual(
|
|
500
497
|
2,
|
|
501
|
-
<A>(self: TxChunk<A>, chunk: Chunk.Chunk<A>): Effect.Effect<void
|
|
502
|
-
TxRef.set(self.ref, chunk)
|
|
498
|
+
<A>(self: TxChunk<A>, chunk: Chunk.Chunk<A>): Effect.Effect<void> => TxRef.set(self.ref, chunk)
|
|
503
499
|
)
|
|
504
500
|
|
|
505
501
|
/**
|
|
@@ -551,7 +547,7 @@ export const append: {
|
|
|
551
547
|
* @since 4.0.0
|
|
552
548
|
* @category combinators
|
|
553
549
|
*/
|
|
554
|
-
<A>(element: A): (self: TxChunk<A>) => Effect.Effect<void
|
|
550
|
+
<A>(element: A): (self: TxChunk<A>) => Effect.Effect<void>
|
|
555
551
|
/**
|
|
556
552
|
* Appends an element to the end of the `TxChunk`.
|
|
557
553
|
*
|
|
@@ -576,11 +572,10 @@ export const append: {
|
|
|
576
572
|
* @since 4.0.0
|
|
577
573
|
* @category combinators
|
|
578
574
|
*/
|
|
579
|
-
<A>(self: TxChunk<A>, element: A): Effect.Effect<void
|
|
575
|
+
<A>(self: TxChunk<A>, element: A): Effect.Effect<void>
|
|
580
576
|
} = dual(
|
|
581
577
|
2,
|
|
582
|
-
<A>(self: TxChunk<A>, element: A): Effect.Effect<void
|
|
583
|
-
update(self, (current) => Chunk.append(current, element))
|
|
578
|
+
<A>(self: TxChunk<A>, element: A): Effect.Effect<void> => update(self, (current) => Chunk.append(current, element))
|
|
584
579
|
)
|
|
585
580
|
|
|
586
581
|
/**
|
|
@@ -632,7 +627,7 @@ export const prepend: {
|
|
|
632
627
|
* @since 4.0.0
|
|
633
628
|
* @category combinators
|
|
634
629
|
*/
|
|
635
|
-
<A>(element: A): (self: TxChunk<A>) => Effect.Effect<void
|
|
630
|
+
<A>(element: A): (self: TxChunk<A>) => Effect.Effect<void>
|
|
636
631
|
/**
|
|
637
632
|
* Prepends an element to the beginning of the `TxChunk`.
|
|
638
633
|
*
|
|
@@ -657,11 +652,10 @@ export const prepend: {
|
|
|
657
652
|
* @since 4.0.0
|
|
658
653
|
* @category combinators
|
|
659
654
|
*/
|
|
660
|
-
<A>(self: TxChunk<A>, element: A): Effect.Effect<void
|
|
655
|
+
<A>(self: TxChunk<A>, element: A): Effect.Effect<void>
|
|
661
656
|
} = dual(
|
|
662
657
|
2,
|
|
663
|
-
<A>(self: TxChunk<A>, element: A): Effect.Effect<void
|
|
664
|
-
update(self, (current) => Chunk.prepend(current, element))
|
|
658
|
+
<A>(self: TxChunk<A>, element: A): Effect.Effect<void> => update(self, (current) => Chunk.prepend(current, element))
|
|
665
659
|
)
|
|
666
660
|
|
|
667
661
|
/**
|
|
@@ -688,7 +682,7 @@ export const prepend: {
|
|
|
688
682
|
* @since 4.0.0
|
|
689
683
|
* @category combinators
|
|
690
684
|
*/
|
|
691
|
-
export const size = <A>(self: TxChunk<A>): Effect.Effect<number
|
|
685
|
+
export const size = <A>(self: TxChunk<A>): Effect.Effect<number> =>
|
|
692
686
|
modify(self, (current) => [Chunk.size(current), current])
|
|
693
687
|
|
|
694
688
|
/**
|
|
@@ -714,7 +708,7 @@ export const size = <A>(self: TxChunk<A>): Effect.Effect<number, never, Effect.T
|
|
|
714
708
|
* @since 4.0.0
|
|
715
709
|
* @category combinators
|
|
716
710
|
*/
|
|
717
|
-
export const isEmpty = <A>(self: TxChunk<A>): Effect.Effect<boolean
|
|
711
|
+
export const isEmpty = <A>(self: TxChunk<A>): Effect.Effect<boolean> =>
|
|
718
712
|
modify(self, (current) => [Chunk.isEmpty(current), current])
|
|
719
713
|
|
|
720
714
|
/**
|
|
@@ -740,7 +734,7 @@ export const isEmpty = <A>(self: TxChunk<A>): Effect.Effect<boolean, never, Effe
|
|
|
740
734
|
* @since 4.0.0
|
|
741
735
|
* @category combinators
|
|
742
736
|
*/
|
|
743
|
-
export const isNonEmpty = <A>(self: TxChunk<A>): Effect.Effect<boolean
|
|
737
|
+
export const isNonEmpty = <A>(self: TxChunk<A>): Effect.Effect<boolean> =>
|
|
744
738
|
modify(self, (current) => [Chunk.isNonEmpty(current), current])
|
|
745
739
|
|
|
746
740
|
/**
|
|
@@ -792,7 +786,7 @@ export const take: {
|
|
|
792
786
|
* @since 4.0.0
|
|
793
787
|
* @category combinators
|
|
794
788
|
*/
|
|
795
|
-
(n: number): <A>(self: TxChunk<A>) => Effect.Effect<void
|
|
789
|
+
(n: number): <A>(self: TxChunk<A>) => Effect.Effect<void>
|
|
796
790
|
/**
|
|
797
791
|
* Takes the first `n` elements from the `TxChunk`.
|
|
798
792
|
*
|
|
@@ -817,11 +811,10 @@ export const take: {
|
|
|
817
811
|
* @since 4.0.0
|
|
818
812
|
* @category combinators
|
|
819
813
|
*/
|
|
820
|
-
<A>(self: TxChunk<A>, n: number): Effect.Effect<void
|
|
814
|
+
<A>(self: TxChunk<A>, n: number): Effect.Effect<void>
|
|
821
815
|
} = dual(
|
|
822
816
|
2,
|
|
823
|
-
<A>(self: TxChunk<A>, n: number): Effect.Effect<void
|
|
824
|
-
update(self, (current) => Chunk.take(current, n))
|
|
817
|
+
<A>(self: TxChunk<A>, n: number): Effect.Effect<void> => update(self, (current) => Chunk.take(current, n))
|
|
825
818
|
)
|
|
826
819
|
|
|
827
820
|
/**
|
|
@@ -873,7 +866,7 @@ export const drop: {
|
|
|
873
866
|
* @since 4.0.0
|
|
874
867
|
* @category combinators
|
|
875
868
|
*/
|
|
876
|
-
(n: number): <A>(self: TxChunk<A>) => Effect.Effect<void
|
|
869
|
+
(n: number): <A>(self: TxChunk<A>) => Effect.Effect<void>
|
|
877
870
|
/**
|
|
878
871
|
* Drops the first `n` elements from the `TxChunk`.
|
|
879
872
|
*
|
|
@@ -898,11 +891,10 @@ export const drop: {
|
|
|
898
891
|
* @since 4.0.0
|
|
899
892
|
* @category combinators
|
|
900
893
|
*/
|
|
901
|
-
<A>(self: TxChunk<A>, n: number): Effect.Effect<void
|
|
894
|
+
<A>(self: TxChunk<A>, n: number): Effect.Effect<void>
|
|
902
895
|
} = dual(
|
|
903
896
|
2,
|
|
904
|
-
<A>(self: TxChunk<A>, n: number): Effect.Effect<void
|
|
905
|
-
update(self, (current) => Chunk.drop(current, n))
|
|
897
|
+
<A>(self: TxChunk<A>, n: number): Effect.Effect<void> => update(self, (current) => Chunk.drop(current, n))
|
|
906
898
|
)
|
|
907
899
|
|
|
908
900
|
/**
|
|
@@ -954,7 +946,7 @@ export const slice: {
|
|
|
954
946
|
* @since 4.0.0
|
|
955
947
|
* @category combinators
|
|
956
948
|
*/
|
|
957
|
-
(start: number, end: number): <A>(self: TxChunk<A>) => Effect.Effect<void
|
|
949
|
+
(start: number, end: number): <A>(self: TxChunk<A>) => Effect.Effect<void>
|
|
958
950
|
/**
|
|
959
951
|
* Takes a slice of the `TxChunk` from `start` to `end` (exclusive).
|
|
960
952
|
*
|
|
@@ -979,10 +971,10 @@ export const slice: {
|
|
|
979
971
|
* @since 4.0.0
|
|
980
972
|
* @category combinators
|
|
981
973
|
*/
|
|
982
|
-
<A>(self: TxChunk<A>, start: number, end: number): Effect.Effect<void
|
|
974
|
+
<A>(self: TxChunk<A>, start: number, end: number): Effect.Effect<void>
|
|
983
975
|
} = dual(
|
|
984
976
|
3,
|
|
985
|
-
<A>(self: TxChunk<A>, start: number, end: number): Effect.Effect<void
|
|
977
|
+
<A>(self: TxChunk<A>, start: number, end: number): Effect.Effect<void> =>
|
|
986
978
|
update(self, (current) => Chunk.take(Chunk.drop(current, start), end - start))
|
|
987
979
|
)
|
|
988
980
|
|
|
@@ -1039,7 +1031,7 @@ export const map: {
|
|
|
1039
1031
|
* @since 4.0.0
|
|
1040
1032
|
* @category combinators
|
|
1041
1033
|
*/
|
|
1042
|
-
<A>(f: (a: NoInfer<A>) => A): (self: TxChunk<A>) => Effect.Effect<void
|
|
1034
|
+
<A>(f: (a: NoInfer<A>) => A): (self: TxChunk<A>) => Effect.Effect<void>
|
|
1043
1035
|
/**
|
|
1044
1036
|
* Maps each element of the `TxChunk` using the provided function.
|
|
1045
1037
|
* Note: This only works when the mapped type B is assignable to A.
|
|
@@ -1066,11 +1058,10 @@ export const map: {
|
|
|
1066
1058
|
* @since 4.0.0
|
|
1067
1059
|
* @category combinators
|
|
1068
1060
|
*/
|
|
1069
|
-
<A>(self: TxChunk<A>, f: (a: A) => A): Effect.Effect<void
|
|
1061
|
+
<A>(self: TxChunk<A>, f: (a: A) => A): Effect.Effect<void>
|
|
1070
1062
|
} = dual(
|
|
1071
1063
|
2,
|
|
1072
|
-
<A>(self: TxChunk<A>, f: (a: A) => A): Effect.Effect<void
|
|
1073
|
-
update(self, (current) => Chunk.map(current, f))
|
|
1064
|
+
<A>(self: TxChunk<A>, f: (a: A) => A): Effect.Effect<void> => update(self, (current) => Chunk.map(current, f))
|
|
1074
1065
|
)
|
|
1075
1066
|
|
|
1076
1067
|
/**
|
|
@@ -1124,7 +1115,7 @@ export const filter: {
|
|
|
1124
1115
|
* @since 4.0.0
|
|
1125
1116
|
* @category combinators
|
|
1126
1117
|
*/
|
|
1127
|
-
<A, B extends A>(refinement: (a: A) => a is B): (self: TxChunk<A>) => Effect.Effect<void
|
|
1118
|
+
<A, B extends A>(refinement: (a: A) => a is B): (self: TxChunk<A>) => Effect.Effect<void>
|
|
1128
1119
|
/**
|
|
1129
1120
|
* Filters the `TxChunk` keeping only elements that satisfy the predicate.
|
|
1130
1121
|
*
|
|
@@ -1150,7 +1141,7 @@ export const filter: {
|
|
|
1150
1141
|
* @since 4.0.0
|
|
1151
1142
|
* @category combinators
|
|
1152
1143
|
*/
|
|
1153
|
-
<A>(predicate: (a: A) => boolean): (self: TxChunk<A>) => Effect.Effect<void
|
|
1144
|
+
<A>(predicate: (a: A) => boolean): (self: TxChunk<A>) => Effect.Effect<void>
|
|
1154
1145
|
/**
|
|
1155
1146
|
* Filters the `TxChunk` keeping only elements that satisfy the predicate.
|
|
1156
1147
|
*
|
|
@@ -1176,7 +1167,7 @@ export const filter: {
|
|
|
1176
1167
|
* @since 4.0.0
|
|
1177
1168
|
* @category combinators
|
|
1178
1169
|
*/
|
|
1179
|
-
<A, B extends A>(self: TxChunk<A>, refinement: (a: A) => a is B): Effect.Effect<void
|
|
1170
|
+
<A, B extends A>(self: TxChunk<A>, refinement: (a: A) => a is B): Effect.Effect<void>
|
|
1180
1171
|
/**
|
|
1181
1172
|
* Filters the `TxChunk` keeping only elements that satisfy the predicate.
|
|
1182
1173
|
*
|
|
@@ -1202,10 +1193,10 @@ export const filter: {
|
|
|
1202
1193
|
* @since 4.0.0
|
|
1203
1194
|
* @category combinators
|
|
1204
1195
|
*/
|
|
1205
|
-
<A>(self: TxChunk<A>, predicate: (a: A) => boolean): Effect.Effect<void
|
|
1196
|
+
<A>(self: TxChunk<A>, predicate: (a: A) => boolean): Effect.Effect<void>
|
|
1206
1197
|
} = dual(
|
|
1207
1198
|
2,
|
|
1208
|
-
<A>(self: TxChunk<A>, predicate: (a: A) => boolean): Effect.Effect<void
|
|
1199
|
+
<A>(self: TxChunk<A>, predicate: (a: A) => boolean): Effect.Effect<void> =>
|
|
1209
1200
|
update(self, (current) => Chunk.filter(current, predicate))
|
|
1210
1201
|
)
|
|
1211
1202
|
|
|
@@ -1262,7 +1253,7 @@ export const appendAll: {
|
|
|
1262
1253
|
* @since 4.0.0
|
|
1263
1254
|
* @category combinators
|
|
1264
1255
|
*/
|
|
1265
|
-
<A>(other: Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void
|
|
1256
|
+
<A>(other: Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void>
|
|
1266
1257
|
/**
|
|
1267
1258
|
* Concatenates another chunk to the end of the `TxChunk`.
|
|
1268
1259
|
*
|
|
@@ -1289,10 +1280,10 @@ export const appendAll: {
|
|
|
1289
1280
|
* @since 4.0.0
|
|
1290
1281
|
* @category combinators
|
|
1291
1282
|
*/
|
|
1292
|
-
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void
|
|
1283
|
+
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void>
|
|
1293
1284
|
} = dual(
|
|
1294
1285
|
2,
|
|
1295
|
-
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void
|
|
1286
|
+
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void> =>
|
|
1296
1287
|
update(self, (current) => Chunk.appendAll(current, other))
|
|
1297
1288
|
)
|
|
1298
1289
|
|
|
@@ -1349,7 +1340,7 @@ export const prependAll: {
|
|
|
1349
1340
|
* @since 4.0.0
|
|
1350
1341
|
* @category combinators
|
|
1351
1342
|
*/
|
|
1352
|
-
<A>(other: Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void
|
|
1343
|
+
<A>(other: Chunk.Chunk<A>): (self: TxChunk<A>) => Effect.Effect<void>
|
|
1353
1344
|
/**
|
|
1354
1345
|
* Concatenates another chunk to the beginning of the `TxChunk`.
|
|
1355
1346
|
*
|
|
@@ -1376,10 +1367,10 @@ export const prependAll: {
|
|
|
1376
1367
|
* @since 4.0.0
|
|
1377
1368
|
* @category combinators
|
|
1378
1369
|
*/
|
|
1379
|
-
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void
|
|
1370
|
+
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void>
|
|
1380
1371
|
} = dual(
|
|
1381
1372
|
2,
|
|
1382
|
-
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void
|
|
1373
|
+
<A>(self: TxChunk<A>, other: Chunk.Chunk<A>): Effect.Effect<void> =>
|
|
1383
1374
|
update(self, (current) => Chunk.prependAll(current, other))
|
|
1384
1375
|
)
|
|
1385
1376
|
|
|
@@ -1440,7 +1431,7 @@ export const concat: {
|
|
|
1440
1431
|
* })
|
|
1441
1432
|
* ```
|
|
1442
1433
|
*/
|
|
1443
|
-
<A>(other: TxChunk<A>): (self: TxChunk<A>) => Effect.Effect<void
|
|
1434
|
+
<A>(other: TxChunk<A>): (self: TxChunk<A>) => Effect.Effect<void>
|
|
1444
1435
|
/**
|
|
1445
1436
|
* Concatenates another `TxChunk` to the end of this `TxChunk`.
|
|
1446
1437
|
*
|
|
@@ -1469,12 +1460,12 @@ export const concat: {
|
|
|
1469
1460
|
* })
|
|
1470
1461
|
* ```
|
|
1471
1462
|
*/
|
|
1472
|
-
<A>(self: TxChunk<A>, other: TxChunk<A>): Effect.Effect<void
|
|
1463
|
+
<A>(self: TxChunk<A>, other: TxChunk<A>): Effect.Effect<void>
|
|
1473
1464
|
} = dual(
|
|
1474
1465
|
2,
|
|
1475
|
-
<A>(self: TxChunk<A>, other: TxChunk<A>): Effect.Effect<void
|
|
1466
|
+
<A>(self: TxChunk<A>, other: TxChunk<A>): Effect.Effect<void> =>
|
|
1476
1467
|
Effect.gen(function*() {
|
|
1477
1468
|
const otherChunk = yield* get(other)
|
|
1478
1469
|
yield* appendAll(self, otherChunk)
|
|
1479
|
-
})
|
|
1470
|
+
}).pipe(Effect.tx)
|
|
1480
1471
|
)
|
package/src/TxDeferred.ts
CHANGED
|
@@ -93,7 +93,7 @@ const makeTxDeferred = <A, E>(ref: TxRef.TxRef<Option<Result<A, E>>>): TxDeferre
|
|
|
93
93
|
* @since 4.0.0
|
|
94
94
|
* @category constructors
|
|
95
95
|
*/
|
|
96
|
-
export const make = <A, E = never>(): Effect.Effect<TxDeferred<A, E
|
|
96
|
+
export const make = <A, E = never>(): Effect.Effect<TxDeferred<A, E>> =>
|
|
97
97
|
Effect.map(TxRef.make<Option<Result<A, E>>>(O.none()), makeTxDeferred)
|
|
98
98
|
|
|
99
99
|
/**
|
|
@@ -115,16 +115,16 @@ export const make = <A, E = never>(): Effect.Effect<TxDeferred<A, E>, never, Eff
|
|
|
115
115
|
* @since 4.0.0
|
|
116
116
|
* @category getters
|
|
117
117
|
*/
|
|
118
|
-
const await_ = <A, E>(self: TxDeferred<A, E>): Effect.Effect<A, E
|
|
118
|
+
const await_ = <A, E>(self: TxDeferred<A, E>): Effect.Effect<A, E> =>
|
|
119
119
|
Effect.gen(function*() {
|
|
120
120
|
const option = yield* TxRef.get(self.ref)
|
|
121
121
|
if (O.isNone(option)) {
|
|
122
|
-
return yield* Effect.
|
|
122
|
+
return yield* Effect.txRetry
|
|
123
123
|
}
|
|
124
124
|
return Res.isSuccess(option.value)
|
|
125
125
|
? option.value.success
|
|
126
126
|
: yield* Effect.fail(option.value.failure)
|
|
127
|
-
})
|
|
127
|
+
}).pipe(Effect.tx)
|
|
128
128
|
|
|
129
129
|
export {
|
|
130
130
|
/**
|
|
@@ -159,8 +159,7 @@ export {
|
|
|
159
159
|
* @since 4.0.0
|
|
160
160
|
* @category getters
|
|
161
161
|
*/
|
|
162
|
-
export const poll = <A, E>(self: TxDeferred<A, E>): Effect.Effect<Option<Result<A, E
|
|
163
|
-
TxRef.get(self.ref)
|
|
162
|
+
export const poll = <A, E>(self: TxDeferred<A, E>): Effect.Effect<Option<Result<A, E>>> => TxRef.get(self.ref)
|
|
164
163
|
|
|
165
164
|
/**
|
|
166
165
|
* Completes the deferred with a `Result`. Returns `true` if this was the first
|
|
@@ -203,7 +202,7 @@ export const done: {
|
|
|
203
202
|
* @since 4.0.0
|
|
204
203
|
* @category mutations
|
|
205
204
|
*/
|
|
206
|
-
<A, E>(result: Result<A, E>): (self: TxDeferred<A, E>) => Effect.Effect<boolean
|
|
205
|
+
<A, E>(result: Result<A, E>): (self: TxDeferred<A, E>) => Effect.Effect<boolean>
|
|
207
206
|
/**
|
|
208
207
|
* Completes the deferred with a `Result`. Returns `true` if this was the first
|
|
209
208
|
* completion, `false` if already completed.
|
|
@@ -224,10 +223,10 @@ export const done: {
|
|
|
224
223
|
* @since 4.0.0
|
|
225
224
|
* @category mutations
|
|
226
225
|
*/
|
|
227
|
-
<A, E>(self: TxDeferred<A, E>, result: Result<A, E>): Effect.Effect<boolean
|
|
226
|
+
<A, E>(self: TxDeferred<A, E>, result: Result<A, E>): Effect.Effect<boolean>
|
|
228
227
|
} = dual(
|
|
229
228
|
2,
|
|
230
|
-
<A, E>(self: TxDeferred<A, E>, result: Result<A, E>): Effect.Effect<boolean
|
|
229
|
+
<A, E>(self: TxDeferred<A, E>, result: Result<A, E>): Effect.Effect<boolean> =>
|
|
231
230
|
TxRef.modify(self.ref, (current) => {
|
|
232
231
|
if (O.isSome(current)) {
|
|
233
232
|
return [false, current]
|
|
@@ -277,7 +276,7 @@ export const succeed: {
|
|
|
277
276
|
* @since 4.0.0
|
|
278
277
|
* @category mutations
|
|
279
278
|
*/
|
|
280
|
-
<A>(value: A): <E>(self: TxDeferred<A, E>) => Effect.Effect<boolean
|
|
279
|
+
<A>(value: A): <E>(self: TxDeferred<A, E>) => Effect.Effect<boolean>
|
|
281
280
|
/**
|
|
282
281
|
* Completes the deferred with a success value. Returns `true` if this was the
|
|
283
282
|
* first completion, `false` if already completed.
|
|
@@ -298,11 +297,10 @@ export const succeed: {
|
|
|
298
297
|
* @since 4.0.0
|
|
299
298
|
* @category mutations
|
|
300
299
|
*/
|
|
301
|
-
<A, E>(self: TxDeferred<A, E>, value: A): Effect.Effect<boolean
|
|
300
|
+
<A, E>(self: TxDeferred<A, E>, value: A): Effect.Effect<boolean>
|
|
302
301
|
} = dual(
|
|
303
302
|
2,
|
|
304
|
-
<A, E>(self: TxDeferred<A, E>, value: A): Effect.Effect<boolean
|
|
305
|
-
done(self, Res.succeed(value))
|
|
303
|
+
<A, E>(self: TxDeferred<A, E>, value: A): Effect.Effect<boolean> => done(self, Res.succeed(value))
|
|
306
304
|
)
|
|
307
305
|
|
|
308
306
|
/**
|
|
@@ -346,7 +344,7 @@ export const fail: {
|
|
|
346
344
|
* @since 4.0.0
|
|
347
345
|
* @category mutations
|
|
348
346
|
*/
|
|
349
|
-
<E>(error: E): <A>(self: TxDeferred<A, E>) => Effect.Effect<boolean
|
|
347
|
+
<E>(error: E): <A>(self: TxDeferred<A, E>) => Effect.Effect<boolean>
|
|
350
348
|
/**
|
|
351
349
|
* Completes the deferred with a failure. Returns `true` if this was the first
|
|
352
350
|
* completion, `false` if already completed.
|
|
@@ -367,11 +365,10 @@ export const fail: {
|
|
|
367
365
|
* @since 4.0.0
|
|
368
366
|
* @category mutations
|
|
369
367
|
*/
|
|
370
|
-
<A, E>(self: TxDeferred<A, E>, error: E): Effect.Effect<boolean
|
|
368
|
+
<A, E>(self: TxDeferred<A, E>, error: E): Effect.Effect<boolean>
|
|
371
369
|
} = dual(
|
|
372
370
|
2,
|
|
373
|
-
<A, E>(self: TxDeferred<A, E>, error: E): Effect.Effect<boolean
|
|
374
|
-
done(self, Res.fail(error))
|
|
371
|
+
<A, E>(self: TxDeferred<A, E>, error: E): Effect.Effect<boolean> => done(self, Res.fail(error))
|
|
375
372
|
)
|
|
376
373
|
|
|
377
374
|
/**
|