effect 4.0.0-beta.17 → 4.0.0-beta.19

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.
Files changed (164) hide show
  1. package/dist/Array.d.ts +127 -299
  2. package/dist/Array.d.ts.map +1 -1
  3. package/dist/Array.js +102 -62
  4. package/dist/Array.js.map +1 -1
  5. package/dist/Cache.d.ts.map +1 -1
  6. package/dist/Cache.js +5 -4
  7. package/dist/Cache.js.map +1 -1
  8. package/dist/Channel.d.ts +97 -11
  9. package/dist/Channel.d.ts.map +1 -1
  10. package/dist/Channel.js +72 -29
  11. package/dist/Channel.js.map +1 -1
  12. package/dist/Chunk.d.ts +54 -247
  13. package/dist/Chunk.d.ts.map +1 -1
  14. package/dist/Chunk.js +36 -67
  15. package/dist/Chunk.js.map +1 -1
  16. package/dist/Effect.d.ts +337 -437
  17. package/dist/Effect.d.ts.map +1 -1
  18. package/dist/Effect.js +118 -134
  19. package/dist/Effect.js.map +1 -1
  20. package/dist/Filter.d.ts +0 -33
  21. package/dist/Filter.d.ts.map +1 -1
  22. package/dist/Filter.js +0 -13
  23. package/dist/Filter.js.map +1 -1
  24. package/dist/HashMap.d.ts +15 -14
  25. package/dist/HashMap.d.ts.map +1 -1
  26. package/dist/HashMap.js +4 -4
  27. package/dist/HashMap.js.map +1 -1
  28. package/dist/Iterable.d.ts +40 -39
  29. package/dist/Iterable.d.ts.map +1 -1
  30. package/dist/Iterable.js +94 -22
  31. package/dist/Iterable.js.map +1 -1
  32. package/dist/Option.d.ts +22 -15
  33. package/dist/Option.d.ts.map +1 -1
  34. package/dist/Option.js +14 -7
  35. package/dist/Option.js.map +1 -1
  36. package/dist/Pull.d.ts.map +1 -1
  37. package/dist/Pull.js +1 -1
  38. package/dist/Pull.js.map +1 -1
  39. package/dist/Record.d.ts +24 -120
  40. package/dist/Record.d.ts.map +1 -1
  41. package/dist/Record.js +21 -41
  42. package/dist/Record.js.map +1 -1
  43. package/dist/Sink.d.ts +11 -11
  44. package/dist/Sink.d.ts.map +1 -1
  45. package/dist/Sink.js +53 -6
  46. package/dist/Sink.js.map +1 -1
  47. package/dist/Stream.d.ts +198 -386
  48. package/dist/Stream.d.ts.map +1 -1
  49. package/dist/Stream.js +103 -59
  50. package/dist/Stream.js.map +1 -1
  51. package/dist/Trie.d.ts +18 -17
  52. package/dist/Trie.d.ts.map +1 -1
  53. package/dist/Trie.js +5 -5
  54. package/dist/Trie.js.map +1 -1
  55. package/dist/TxChunk.d.ts +37 -37
  56. package/dist/TxChunk.d.ts.map +1 -1
  57. package/dist/TxChunk.js +3 -3
  58. package/dist/TxChunk.js.map +1 -1
  59. package/dist/TxDeferred.d.ts +328 -0
  60. package/dist/TxDeferred.d.ts.map +1 -0
  61. package/dist/TxDeferred.js +196 -0
  62. package/dist/TxDeferred.js.map +1 -0
  63. package/dist/TxHashMap.d.ts +84 -83
  64. package/dist/TxHashMap.d.ts.map +1 -1
  65. package/dist/TxHashMap.js +24 -24
  66. package/dist/TxHashMap.js.map +1 -1
  67. package/dist/TxHashSet.d.ts +35 -35
  68. package/dist/TxHashSet.d.ts.map +1 -1
  69. package/dist/TxHashSet.js +14 -14
  70. package/dist/TxHashSet.js.map +1 -1
  71. package/dist/TxPriorityQueue.d.ts +609 -0
  72. package/dist/TxPriorityQueue.d.ts.map +1 -0
  73. package/dist/TxPriorityQueue.js +415 -0
  74. package/dist/TxPriorityQueue.js.map +1 -0
  75. package/dist/TxPubSub.d.ts +585 -0
  76. package/dist/TxPubSub.d.ts.map +1 -0
  77. package/dist/TxPubSub.js +521 -0
  78. package/dist/TxPubSub.js.map +1 -0
  79. package/dist/TxQueue.d.ts +32 -32
  80. package/dist/TxQueue.d.ts.map +1 -1
  81. package/dist/TxQueue.js +26 -26
  82. package/dist/TxQueue.js.map +1 -1
  83. package/dist/TxReentrantLock.d.ts +523 -0
  84. package/dist/TxReentrantLock.d.ts.map +1 -0
  85. package/dist/TxReentrantLock.js +504 -0
  86. package/dist/TxReentrantLock.js.map +1 -0
  87. package/dist/TxRef.d.ts +34 -34
  88. package/dist/TxRef.d.ts.map +1 -1
  89. package/dist/TxRef.js +21 -14
  90. package/dist/TxRef.js.map +1 -1
  91. package/dist/TxSemaphore.d.ts +8 -8
  92. package/dist/TxSemaphore.d.ts.map +1 -1
  93. package/dist/TxSemaphore.js +7 -7
  94. package/dist/TxSemaphore.js.map +1 -1
  95. package/dist/TxSubscriptionRef.d.ts +508 -0
  96. package/dist/TxSubscriptionRef.d.ts.map +1 -0
  97. package/dist/TxSubscriptionRef.js +293 -0
  98. package/dist/TxSubscriptionRef.js.map +1 -0
  99. package/dist/index.d.ts +40 -0
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +40 -0
  102. package/dist/index.js.map +1 -1
  103. package/dist/internal/effect.js +99 -42
  104. package/dist/internal/effect.js.map +1 -1
  105. package/dist/internal/hashMap.js +3 -2
  106. package/dist/internal/hashMap.js.map +1 -1
  107. package/dist/internal/trie.js +5 -4
  108. package/dist/internal/trie.js.map +1 -1
  109. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  110. package/dist/unstable/ai/Tool.js +0 -9
  111. package/dist/unstable/ai/Tool.js.map +1 -1
  112. package/dist/unstable/cli/Command.d.ts +1 -1
  113. package/dist/unstable/cli/Command.d.ts.map +1 -1
  114. package/dist/unstable/cli/Command.js +1 -1
  115. package/dist/unstable/cli/Command.js.map +1 -1
  116. package/dist/unstable/cluster/K8sHttpClient.js +4 -4
  117. package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
  118. package/dist/unstable/cluster/Sharding.js +1 -1
  119. package/dist/unstable/cluster/Sharding.js.map +1 -1
  120. package/dist/unstable/encoding/Sse.js +1 -1
  121. package/dist/unstable/encoding/Sse.js.map +1 -1
  122. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  123. package/dist/unstable/rpc/RpcServer.js +1 -2
  124. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  125. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  126. package/dist/unstable/socket/Socket.js +3 -3
  127. package/dist/unstable/socket/Socket.js.map +1 -1
  128. package/package.json +1 -1
  129. package/src/Array.ts +190 -342
  130. package/src/Cache.ts +6 -5
  131. package/src/Channel.ts +506 -102
  132. package/src/Chunk.ts +81 -268
  133. package/src/Effect.ts +437 -518
  134. package/src/Filter.ts +0 -57
  135. package/src/HashMap.ts +15 -14
  136. package/src/Iterable.ts +105 -50
  137. package/src/Option.ts +30 -20
  138. package/src/Pull.ts +1 -1
  139. package/src/Record.ts +43 -152
  140. package/src/Sink.ts +75 -23
  141. package/src/Stream.ts +442 -502
  142. package/src/Trie.ts +18 -17
  143. package/src/TxChunk.ts +72 -53
  144. package/src/TxDeferred.ts +394 -0
  145. package/src/TxHashMap.ts +332 -285
  146. package/src/TxHashSet.ts +111 -116
  147. package/src/TxPriorityQueue.ts +767 -0
  148. package/src/TxPubSub.ts +789 -0
  149. package/src/TxQueue.ts +241 -251
  150. package/src/TxReentrantLock.ts +753 -0
  151. package/src/TxRef.ts +50 -38
  152. package/src/TxSemaphore.ts +29 -32
  153. package/src/TxSubscriptionRef.ts +639 -0
  154. package/src/index.ts +45 -0
  155. package/src/internal/effect.ts +368 -163
  156. package/src/internal/hashMap.ts +7 -5
  157. package/src/internal/trie.ts +16 -9
  158. package/src/unstable/ai/Tool.ts +0 -9
  159. package/src/unstable/cli/Command.ts +6 -4
  160. package/src/unstable/cluster/K8sHttpClient.ts +4 -4
  161. package/src/unstable/cluster/Sharding.ts +1 -1
  162. package/src/unstable/encoding/Sse.ts +1 -1
  163. package/src/unstable/rpc/RpcServer.ts +1 -7
  164. package/src/unstable/socket/Socket.ts +9 -11
package/src/TxRef.ts CHANGED
@@ -35,12 +35,12 @@ const TypeId = "~effect/transactions/TxRef"
35
35
  * const ref: TxRef.TxRef<number> = yield* TxRef.make(0)
36
36
  *
37
37
  * // Use within a transaction
38
- * yield* Effect.atomic(Effect.gen(function*() {
38
+ * yield* Effect.transaction(Effect.gen(function*() {
39
39
  * const current = yield* TxRef.get(ref)
40
40
  * yield* TxRef.set(ref, current + 1)
41
41
  * }))
42
42
  *
43
- * const final = yield* TxRef.get(ref)
43
+ * const final = yield* Effect.transaction(TxRef.get(ref))
44
44
  * console.log(final) // 1
45
45
  * })
46
46
  * ```
@@ -64,21 +64,28 @@ export interface TxRef<in out A> extends Pipeable {
64
64
  *
65
65
  * const program = Effect.gen(function*() {
66
66
  * // Create a transactional reference with initial value
67
- * const counter = yield* TxRef.make(0)
68
- * const name = yield* TxRef.make("Alice")
67
+ * const counter = yield* Effect.transaction(TxRef.make(0))
68
+ * const name = yield* Effect.transaction(TxRef.make("Alice"))
69
69
  *
70
70
  * // Use in transactions
71
- * yield* Effect.atomic(Effect.gen(function*() {
71
+ * yield* Effect.transaction(Effect.gen(function*() {
72
72
  * yield* TxRef.set(counter, 42)
73
73
  * yield* TxRef.set(name, "Bob")
74
74
  * }))
75
75
  *
76
- * console.log(yield* TxRef.get(counter)) // 42
77
- * console.log(yield* TxRef.get(name)) // "Bob"
76
+ * console.log(yield* Effect.transaction(TxRef.get(counter))) // 42
77
+ * console.log(yield* Effect.transaction(TxRef.get(name))) // "Bob"
78
78
  * })
79
79
  * ```
80
80
  */
81
- export const make = <A>(initial: A) => Effect.sync(() => makeUnsafe(initial))
81
+ export const make = <A>(initial: A) =>
82
+ Effect.withTxState((state) =>
83
+ Effect.sync(() => {
84
+ const ref = makeUnsafe(initial)
85
+ state.journal.set(ref, { version: ref.version, value: ref.value })
86
+ return ref
87
+ })
88
+ )
82
89
 
83
90
  /**
84
91
  * Creates a new `TxRef` with the specified initial value.
@@ -121,12 +128,12 @@ export const makeUnsafe = <A>(initial: A): TxRef<A> => ({
121
128
  * const counter = yield* TxRef.make(0)
122
129
  *
123
130
  * // Modify and return both old and new value
124
- * const result = yield* Effect.atomic(
131
+ * const result = yield* Effect.transaction(
125
132
  * TxRef.modify(counter, (current) => [current * 2, current + 1])
126
133
  * )
127
134
  *
128
135
  * console.log(result) // 0 (the return value: current * 2)
129
- * console.log(yield* TxRef.get(counter)) // 1 (the new value: current + 1)
136
+ * console.log(yield* Effect.transaction(TxRef.get(counter))) // 1 (the new value: current + 1)
130
137
  * })
131
138
  * ```
132
139
  */
@@ -144,16 +151,16 @@ export const modify: {
144
151
  * const counter = yield* TxRef.make(0)
145
152
  *
146
153
  * // Modify and return both old and new value
147
- * const result = yield* Effect.atomic(
154
+ * const result = yield* Effect.transaction(
148
155
  * TxRef.modify(counter, (current) => [current * 2, current + 1])
149
156
  * )
150
157
  *
151
158
  * console.log(result) // 0 (the return value: current * 2)
152
- * console.log(yield* TxRef.get(counter)) // 1 (the new value: current + 1)
159
+ * console.log(yield* Effect.transaction(TxRef.get(counter))) // 1 (the new value: current + 1)
153
160
  * })
154
161
  * ```
155
162
  */
156
- <A, R>(f: (current: NoInfer<A>) => [returnValue: R, newValue: A]): (self: TxRef<A>) => Effect.Effect<R>
163
+ <A, R>(f: (current: NoInfer<A>) => [returnValue: R, newValue: A]): (self: TxRef<A>) => Effect.Effect<R, never, Effect.Transaction>
157
164
  /**
158
165
  * Modifies the value of the `TxRef` using the provided function.
159
166
  *
@@ -167,20 +174,23 @@ export const modify: {
167
174
  * const counter = yield* TxRef.make(0)
168
175
  *
169
176
  * // Modify and return both old and new value
170
- * const result = yield* Effect.atomic(
177
+ * const result = yield* Effect.transaction(
171
178
  * TxRef.modify(counter, (current) => [current * 2, current + 1])
172
179
  * )
173
180
  *
174
181
  * console.log(result) // 0 (the return value: current * 2)
175
- * console.log(yield* TxRef.get(counter)) // 1 (the new value: current + 1)
182
+ * console.log(yield* Effect.transaction(TxRef.get(counter))) // 1 (the new value: current + 1)
176
183
  * })
177
184
  * ```
178
185
  */
179
- <A, R>(self: TxRef<A>, f: (current: A) => [returnValue: R, newValue: A]): Effect.Effect<R>
186
+ <A, R>(self: TxRef<A>, f: (current: A) => [returnValue: R, newValue: A]): Effect.Effect<R, never, Effect.Transaction>
180
187
  } = dual(
181
188
  2,
182
- <A, R>(self: TxRef<A>, f: (current: A) => [returnValue: R, newValue: A]): Effect.Effect<R> =>
183
- Effect.atomicWith((state) =>
189
+ <A, R>(
190
+ self: TxRef<A>,
191
+ f: (current: A) => [returnValue: R, newValue: A]
192
+ ): Effect.Effect<R, never, Effect.Transaction> =>
193
+ Effect.withTxState((state) =>
184
194
  Effect.sync(() => {
185
195
  if (!state.journal.has(self)) {
186
196
  state.journal.set(self, { version: self.version, value: self.value })
@@ -206,11 +216,11 @@ export const modify: {
206
216
  * const counter = yield* TxRef.make(10)
207
217
  *
208
218
  * // Update the value using a function
209
- * yield* Effect.atomic(
219
+ * yield* Effect.transaction(
210
220
  * TxRef.update(counter, (current) => current * 2)
211
221
  * )
212
222
  *
213
- * console.log(yield* TxRef.get(counter)) // 20
223
+ * console.log(yield* Effect.transaction(TxRef.get(counter))) // 20
214
224
  * })
215
225
  * ```
216
226
  */
@@ -228,15 +238,15 @@ export const update: {
228
238
  * const counter = yield* TxRef.make(10)
229
239
  *
230
240
  * // Update the value using a function
231
- * yield* Effect.atomic(
241
+ * yield* Effect.transaction(
232
242
  * TxRef.update(counter, (current) => current * 2)
233
243
  * )
234
244
  *
235
- * console.log(yield* TxRef.get(counter)) // 20
245
+ * console.log(yield* Effect.transaction(TxRef.get(counter))) // 20
236
246
  * })
237
247
  * ```
238
248
  */
239
- <A>(f: (current: NoInfer<A>) => A): (self: TxRef<A>) => Effect.Effect<void>
249
+ <A>(f: (current: NoInfer<A>) => A): (self: TxRef<A>) => Effect.Effect<void, never, Effect.Transaction>
240
250
  /**
241
251
  * Updates the value of the `TxRef` using the provided function.
242
252
  *
@@ -250,18 +260,19 @@ export const update: {
250
260
  * const counter = yield* TxRef.make(10)
251
261
  *
252
262
  * // Update the value using a function
253
- * yield* Effect.atomic(
263
+ * yield* Effect.transaction(
254
264
  * TxRef.update(counter, (current) => current * 2)
255
265
  * )
256
266
  *
257
- * console.log(yield* TxRef.get(counter)) // 20
267
+ * console.log(yield* Effect.transaction(TxRef.get(counter))) // 20
258
268
  * })
259
269
  * ```
260
270
  */
261
- <A>(self: TxRef<A>, f: (current: A) => A): Effect.Effect<void>
271
+ <A>(self: TxRef<A>, f: (current: A) => A): Effect.Effect<void, never, Effect.Transaction>
262
272
  } = dual(
263
273
  2,
264
- <A>(self: TxRef<A>, f: (current: A) => A): Effect.Effect<void> => modify(self, (current) => [void 0, f(current)])
274
+ <A>(self: TxRef<A>, f: (current: A) => A): Effect.Effect<void, never, Effect.Transaction> =>
275
+ modify(self, (current) => [void 0, f(current)])
265
276
  )
266
277
 
267
278
  /**
@@ -277,7 +288,7 @@ export const update: {
277
288
  * const counter = yield* TxRef.make(42)
278
289
  *
279
290
  * // Read the value within a transaction
280
- * const value = yield* Effect.atomic(
291
+ * const value = yield* Effect.transaction(
281
292
  * TxRef.get(counter)
282
293
  * )
283
294
  *
@@ -285,7 +296,8 @@ export const update: {
285
296
  * })
286
297
  * ```
287
298
  */
288
- export const get = <A>(self: TxRef<A>): Effect.Effect<A> => modify(self, (current) => [current, current])
299
+ export const get = <A>(self: TxRef<A>): Effect.Effect<A, never, Effect.Transaction> =>
300
+ modify(self, (current) => [current, current])
289
301
 
290
302
  /**
291
303
  * Sets the value of the `TxRef`.
@@ -300,11 +312,11 @@ export const get = <A>(self: TxRef<A>): Effect.Effect<A> => modify(self, (curren
300
312
  * const counter = yield* TxRef.make(0)
301
313
  *
302
314
  * // Set a new value within a transaction
303
- * yield* Effect.atomic(
315
+ * yield* Effect.transaction(
304
316
  * TxRef.set(counter, 100)
305
317
  * )
306
318
  *
307
- * console.log(yield* TxRef.get(counter)) // 100
319
+ * console.log(yield* Effect.transaction(TxRef.get(counter))) // 100
308
320
  * })
309
321
  * ```
310
322
  */
@@ -322,15 +334,15 @@ export const set: {
322
334
  * const counter = yield* TxRef.make(0)
323
335
  *
324
336
  * // Set a new value within a transaction
325
- * yield* Effect.atomic(
337
+ * yield* Effect.transaction(
326
338
  * TxRef.set(counter, 100)
327
339
  * )
328
340
  *
329
- * console.log(yield* TxRef.get(counter)) // 100
341
+ * console.log(yield* Effect.transaction(TxRef.get(counter))) // 100
330
342
  * })
331
343
  * ```
332
344
  */
333
- <A>(value: A): (self: TxRef<A>) => Effect.Effect<void>
345
+ <A>(value: A): (self: TxRef<A>) => Effect.Effect<void, never, Effect.Transaction>
334
346
  /**
335
347
  * Sets the value of the `TxRef`.
336
348
  *
@@ -344,13 +356,13 @@ export const set: {
344
356
  * const counter = yield* TxRef.make(0)
345
357
  *
346
358
  * // Set a new value within a transaction
347
- * yield* Effect.atomic(
359
+ * yield* Effect.transaction(
348
360
  * TxRef.set(counter, 100)
349
361
  * )
350
362
  *
351
- * console.log(yield* TxRef.get(counter)) // 100
363
+ * console.log(yield* Effect.transaction(TxRef.get(counter))) // 100
352
364
  * })
353
365
  * ```
354
366
  */
355
- <A>(self: TxRef<A>, value: A): Effect.Effect<void>
356
- } = dual(2, <A>(self: TxRef<A>, value: A): Effect.Effect<void> => update(self, () => value))
367
+ <A>(self: TxRef<A>, value: A): Effect.Effect<void, never, Effect.Transaction>
368
+ } = dual(2, <A>(self: TxRef<A>, value: A): Effect.Effect<void, never, Effect.Transaction> => update(self, () => value))
@@ -100,7 +100,7 @@ const makeTxSemaphore = (permitsRef: TxRef.TxRef<number>, capacity: number): TxS
100
100
  * @since 4.0.0
101
101
  * @category constructors
102
102
  */
103
- export const make = (permits: number): Effect.Effect<TxSemaphore> =>
103
+ export const make = (permits: number): Effect.Effect<TxSemaphore, never, Effect.Transaction> =>
104
104
  Effect.gen(function*() {
105
105
  if (permits < 0) {
106
106
  return yield* Effect.die(new Error("Permits must be non-negative"))
@@ -140,7 +140,8 @@ export const make = (permits: number): Effect.Effect<TxSemaphore> =>
140
140
  * @since 4.0.0
141
141
  * @category combinators
142
142
  */
143
- export const available = (self: TxSemaphore): Effect.Effect<number> => TxRef.get(self.permitsRef)
143
+ export const available = (self: TxSemaphore): Effect.Effect<number, never, Effect.Transaction> =>
144
+ TxRef.get(self.permitsRef)
144
145
 
145
146
  /**
146
147
  * Gets the maximum capacity (total permits) of the semaphore.
@@ -200,16 +201,14 @@ export const capacity = (self: TxSemaphore): Effect.Effect<number> => Effect.suc
200
201
  * @since 4.0.0
201
202
  * @category combinators
202
203
  */
203
- export const acquire = (self: TxSemaphore): Effect.Effect<void> =>
204
- Effect.atomic(
205
- Effect.gen(function*() {
206
- const permits = yield* TxRef.get(self.permitsRef)
207
- if (permits <= 0) {
208
- return yield* Effect.retryTransaction
209
- }
210
- yield* TxRef.set(self.permitsRef, permits - 1)
211
- })
212
- )
204
+ export const acquire = (self: TxSemaphore): Effect.Effect<void, never, Effect.Transaction> =>
205
+ Effect.gen(function*() {
206
+ const permits = yield* TxRef.get(self.permitsRef)
207
+ if (permits <= 0) {
208
+ return yield* Effect.retryTransaction
209
+ }
210
+ yield* TxRef.set(self.permitsRef, permits - 1)
211
+ })
213
212
 
214
213
  /**
215
214
  * Acquires the specified number of permits from the semaphore. If not enough
@@ -238,19 +237,17 @@ export const acquire = (self: TxSemaphore): Effect.Effect<void> =>
238
237
  * @since 4.0.0
239
238
  * @category combinators
240
239
  */
241
- export const acquireN = (self: TxSemaphore, n: number): Effect.Effect<void> => {
240
+ export const acquireN = (self: TxSemaphore, n: number): Effect.Effect<void, never, Effect.Transaction> => {
242
241
  if (n <= 0) {
243
242
  return Effect.die(new Error("Number of permits must be positive"))
244
243
  }
245
- return Effect.atomic(
246
- Effect.gen(function*() {
247
- const permits = yield* TxRef.get(self.permitsRef)
248
- if (permits < n) {
249
- return yield* Effect.retryTransaction
250
- }
251
- yield* TxRef.set(self.permitsRef, permits - n)
252
- })
253
- )
244
+ return Effect.gen(function*() {
245
+ const permits = yield* TxRef.get(self.permitsRef)
246
+ if (permits < n) {
247
+ return yield* Effect.retryTransaction
248
+ }
249
+ yield* TxRef.set(self.permitsRef, permits - n)
250
+ })
254
251
  }
255
252
 
256
253
  /**
@@ -280,7 +277,7 @@ export const acquireN = (self: TxSemaphore, n: number): Effect.Effect<void> => {
280
277
  * @since 4.0.0
281
278
  * @category combinators
282
279
  */
283
- export const tryAcquire = (self: TxSemaphore): Effect.Effect<boolean> =>
280
+ export const tryAcquire = (self: TxSemaphore): Effect.Effect<boolean, never, Effect.Transaction> =>
284
281
  TxRef.modify(self.permitsRef, (permits: number) => {
285
282
  if (permits > 0) {
286
283
  return [true, permits - 1]
@@ -316,7 +313,7 @@ export const tryAcquire = (self: TxSemaphore): Effect.Effect<boolean> =>
316
313
  * @since 4.0.0
317
314
  * @category combinators
318
315
  */
319
- export const tryAcquireN = (self: TxSemaphore, n: number): Effect.Effect<boolean> => {
316
+ export const tryAcquireN = (self: TxSemaphore, n: number): Effect.Effect<boolean, never, Effect.Transaction> => {
320
317
  if (n <= 0) {
321
318
  return Effect.die(new Error("Number of permits must be positive"))
322
319
  }
@@ -356,7 +353,7 @@ export const tryAcquireN = (self: TxSemaphore, n: number): Effect.Effect<boolean
356
353
  * @since 4.0.0
357
354
  * @category combinators
358
355
  */
359
- export const release = (self: TxSemaphore): Effect.Effect<void> =>
356
+ export const release = (self: TxSemaphore): Effect.Effect<void, never, Effect.Transaction> =>
360
357
  TxRef.update(self.permitsRef, (permits: number) => permits >= self.capacity ? permits : permits + 1)
361
358
 
362
359
  /**
@@ -388,7 +385,7 @@ export const release = (self: TxSemaphore): Effect.Effect<void> =>
388
385
  * @since 4.0.0
389
386
  * @category combinators
390
387
  */
391
- export const releaseN = (self: TxSemaphore, n: number): Effect.Effect<void> => {
388
+ export const releaseN = (self: TxSemaphore, n: number): Effect.Effect<void, never, Effect.Transaction> => {
392
389
  if (n <= 0) {
393
390
  return Effect.die(new Error("Number of permits must be positive"))
394
391
  }
@@ -441,9 +438,9 @@ export const withPermit = <A, E, R>(
441
438
  effect: Effect.Effect<A, E, R>
442
439
  ): Effect.Effect<A, E, R> =>
443
440
  Effect.acquireUseRelease(
444
- acquire(self),
441
+ Effect.transaction(acquire(self)),
445
442
  () => effect,
446
- () => release(self)
443
+ () => Effect.transaction(release(self))
447
444
  )
448
445
 
449
446
  /**
@@ -491,9 +488,9 @@ export const withPermits = <A, E, R>(
491
488
  effect: Effect.Effect<A, E, R>
492
489
  ): Effect.Effect<A, E, R> =>
493
490
  Effect.acquireUseRelease(
494
- acquireN(self, n),
491
+ Effect.transaction(acquireN(self, n)),
495
492
  () => effect,
496
- () => releaseN(self, n)
493
+ () => Effect.transaction(releaseN(self, n))
497
494
  )
498
495
 
499
496
  /**
@@ -537,8 +534,8 @@ export const withPermits = <A, E, R>(
537
534
  */
538
535
  export const withPermitScoped = (self: TxSemaphore): Effect.Effect<void, never, Scope.Scope> =>
539
536
  Effect.acquireRelease(
540
- acquire(self),
541
- () => release(self)
537
+ Effect.transaction(acquire(self)),
538
+ () => Effect.transaction(release(self))
542
539
  )
543
540
 
544
541
  /**