@clayroach/effect 3.19.14-source-capture.6 → 3.19.14-source-capture.8

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 (371) hide show
  1. package/dist/cjs/Utils.js +1 -1
  2. package/dist/cjs/Utils.js.map +1 -1
  3. package/dist/cjs/internal/clock.js +1 -1
  4. package/dist/cjs/internal/clock.js.map +1 -1
  5. package/dist/esm/Utils.js +1 -1
  6. package/dist/esm/Utils.js.map +1 -1
  7. package/dist/esm/internal/clock.js +1 -1
  8. package/dist/esm/internal/clock.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/Arbitrary.ts +0 -1101
  11. package/src/Array.ts +0 -3589
  12. package/src/BigDecimal.ts +0 -1349
  13. package/src/BigInt.ts +0 -643
  14. package/src/Boolean.ts +0 -287
  15. package/src/Brand.ts +0 -360
  16. package/src/Cache.ts +0 -281
  17. package/src/Cause.ts +0 -1555
  18. package/src/Channel.ts +0 -2355
  19. package/src/ChildExecutorDecision.ts +0 -146
  20. package/src/Chunk.ts +0 -1495
  21. package/src/Clock.ts +0 -111
  22. package/src/Config.ts +0 -542
  23. package/src/ConfigError.ts +0 -270
  24. package/src/ConfigProvider.ts +0 -333
  25. package/src/ConfigProviderPathPatch.ts +0 -100
  26. package/src/Console.ts +0 -226
  27. package/src/Context.ts +0 -585
  28. package/src/Cron.ts +0 -706
  29. package/src/Data.ts +0 -596
  30. package/src/DateTime.ts +0 -1686
  31. package/src/DefaultServices.ts +0 -34
  32. package/src/Deferred.ts +0 -301
  33. package/src/Differ.ts +0 -450
  34. package/src/Duration.ts +0 -1000
  35. package/src/Effect.ts +0 -14839
  36. package/src/Effectable.ts +0 -107
  37. package/src/Either.ts +0 -1040
  38. package/src/Encoding.ts +0 -195
  39. package/src/Equal.ts +0 -98
  40. package/src/Equivalence.ts +0 -235
  41. package/src/ExecutionPlan.ts +0 -308
  42. package/src/ExecutionStrategy.ts +0 -119
  43. package/src/Exit.ts +0 -467
  44. package/src/FastCheck.ts +0 -9
  45. package/src/Fiber.ts +0 -744
  46. package/src/FiberHandle.ts +0 -540
  47. package/src/FiberId.ts +0 -195
  48. package/src/FiberMap.ts +0 -656
  49. package/src/FiberRef.ts +0 -431
  50. package/src/FiberRefs.ts +0 -204
  51. package/src/FiberRefsPatch.ts +0 -105
  52. package/src/FiberSet.ts +0 -491
  53. package/src/FiberStatus.ts +0 -108
  54. package/src/Function.ts +0 -1222
  55. package/src/GlobalValue.ts +0 -53
  56. package/src/Graph.ts +0 -3732
  57. package/src/GroupBy.ts +0 -103
  58. package/src/HKT.ts +0 -45
  59. package/src/Hash.ts +0 -195
  60. package/src/HashMap.ts +0 -519
  61. package/src/HashRing.ts +0 -317
  62. package/src/HashSet.ts +0 -2346
  63. package/src/Inspectable.ts +0 -287
  64. package/src/Iterable.ts +0 -1119
  65. package/src/JSONSchema.ts +0 -1044
  66. package/src/KeyedPool.ts +0 -167
  67. package/src/Layer.ts +0 -1251
  68. package/src/LayerMap.ts +0 -436
  69. package/src/List.ts +0 -977
  70. package/src/LogLevel.ts +0 -285
  71. package/src/LogSpan.ts +0 -25
  72. package/src/Logger.ts +0 -702
  73. package/src/Mailbox.ts +0 -268
  74. package/src/ManagedRuntime.ts +0 -180
  75. package/src/Match.ts +0 -1477
  76. package/src/MergeDecision.ts +0 -95
  77. package/src/MergeState.ts +0 -172
  78. package/src/MergeStrategy.ts +0 -107
  79. package/src/Metric.ts +0 -780
  80. package/src/MetricBoundaries.ts +0 -69
  81. package/src/MetricHook.ts +0 -151
  82. package/src/MetricKey.ts +0 -224
  83. package/src/MetricKeyType.ts +0 -262
  84. package/src/MetricLabel.ts +0 -47
  85. package/src/MetricPair.ts +0 -71
  86. package/src/MetricPolling.ts +0 -148
  87. package/src/MetricRegistry.ts +0 -48
  88. package/src/MetricState.ts +0 -257
  89. package/src/Micro.ts +0 -4405
  90. package/src/ModuleVersion.ts +0 -18
  91. package/src/MutableHashMap.ts +0 -411
  92. package/src/MutableHashSet.ts +0 -706
  93. package/src/MutableList.ts +0 -297
  94. package/src/MutableQueue.ts +0 -227
  95. package/src/MutableRef.ts +0 -202
  96. package/src/NonEmptyIterable.ts +0 -32
  97. package/src/Number.ts +0 -1071
  98. package/src/Option.ts +0 -2170
  99. package/src/Order.ts +0 -373
  100. package/src/Ordering.ts +0 -111
  101. package/src/ParseResult.ts +0 -2031
  102. package/src/PartitionedSemaphore.ts +0 -200
  103. package/src/Pipeable.ts +0 -566
  104. package/src/Pool.ts +0 -204
  105. package/src/Predicate.ts +0 -1405
  106. package/src/Pretty.ts +0 -205
  107. package/src/PrimaryKey.ts +0 -23
  108. package/src/PubSub.ts +0 -182
  109. package/src/Queue.ts +0 -644
  110. package/src/Random.ts +0 -204
  111. package/src/RateLimiter.ts +0 -138
  112. package/src/RcMap.ts +0 -141
  113. package/src/RcRef.ts +0 -122
  114. package/src/Readable.ts +0 -93
  115. package/src/Record.ts +0 -1274
  116. package/src/RedBlackTree.ts +0 -421
  117. package/src/Redacted.ts +0 -144
  118. package/src/Ref.ts +0 -180
  119. package/src/RegExp.ts +0 -38
  120. package/src/Reloadable.ts +0 -127
  121. package/src/Request.ts +0 -347
  122. package/src/RequestBlock.ts +0 -118
  123. package/src/RequestResolver.ts +0 -366
  124. package/src/Resource.ts +0 -119
  125. package/src/Runtime.ts +0 -383
  126. package/src/RuntimeFlags.ts +0 -368
  127. package/src/RuntimeFlagsPatch.ts +0 -183
  128. package/src/STM.ts +0 -2045
  129. package/src/Schedule.ts +0 -2219
  130. package/src/ScheduleDecision.ts +0 -62
  131. package/src/ScheduleInterval.ts +0 -151
  132. package/src/ScheduleIntervals.ts +0 -122
  133. package/src/Scheduler.ts +0 -353
  134. package/src/Schema.ts +0 -10914
  135. package/src/SchemaAST.ts +0 -3043
  136. package/src/Scope.ts +0 -204
  137. package/src/ScopedCache.ts +0 -151
  138. package/src/ScopedRef.ts +0 -117
  139. package/src/Secret.ts +0 -88
  140. package/src/SingleProducerAsyncInput.ts +0 -67
  141. package/src/Sink.ts +0 -1461
  142. package/src/SortedMap.ts +0 -287
  143. package/src/SortedSet.ts +0 -390
  144. package/src/Stream.ts +0 -6468
  145. package/src/StreamEmit.ts +0 -136
  146. package/src/StreamHaltStrategy.ts +0 -123
  147. package/src/Streamable.ts +0 -45
  148. package/src/String.ts +0 -778
  149. package/src/Struct.ts +0 -243
  150. package/src/Subscribable.ts +0 -100
  151. package/src/SubscriptionRef.ts +0 -298
  152. package/src/Supervisor.ts +0 -240
  153. package/src/Symbol.ts +0 -29
  154. package/src/SynchronizedRef.ts +0 -270
  155. package/src/TArray.ts +0 -495
  156. package/src/TDeferred.ts +0 -100
  157. package/src/TMap.ts +0 -515
  158. package/src/TPriorityQueue.ts +0 -223
  159. package/src/TPubSub.ts +0 -200
  160. package/src/TQueue.ts +0 -432
  161. package/src/TRandom.ts +0 -129
  162. package/src/TReentrantLock.ts +0 -224
  163. package/src/TRef.ts +0 -178
  164. package/src/TSemaphore.ts +0 -129
  165. package/src/TSet.ts +0 -365
  166. package/src/TSubscriptionRef.ts +0 -192
  167. package/src/Take.ts +0 -258
  168. package/src/TestAnnotation.ts +0 -158
  169. package/src/TestAnnotationMap.ts +0 -119
  170. package/src/TestAnnotations.ts +0 -117
  171. package/src/TestClock.ts +0 -556
  172. package/src/TestConfig.ts +0 -47
  173. package/src/TestContext.ts +0 -36
  174. package/src/TestLive.ts +0 -53
  175. package/src/TestServices.ts +0 -390
  176. package/src/TestSized.ts +0 -55
  177. package/src/Tracer.ts +0 -198
  178. package/src/Trie.ts +0 -840
  179. package/src/Tuple.ts +0 -305
  180. package/src/Types.ts +0 -353
  181. package/src/Unify.ts +0 -113
  182. package/src/UpstreamPullRequest.ts +0 -117
  183. package/src/UpstreamPullStrategy.ts +0 -121
  184. package/src/Utils.ts +0 -809
  185. package/src/index.ts +0 -1561
  186. package/src/internal/array.ts +0 -8
  187. package/src/internal/blockedRequests.ts +0 -520
  188. package/src/internal/cache.ts +0 -733
  189. package/src/internal/cause.ts +0 -1050
  190. package/src/internal/channel/channelExecutor.ts +0 -1200
  191. package/src/internal/channel/channelState.ts +0 -134
  192. package/src/internal/channel/childExecutorDecision.ts +0 -96
  193. package/src/internal/channel/continuation.ts +0 -200
  194. package/src/internal/channel/mergeDecision.ts +0 -113
  195. package/src/internal/channel/mergeState.ts +0 -120
  196. package/src/internal/channel/mergeStrategy.ts +0 -72
  197. package/src/internal/channel/singleProducerAsyncInput.ts +0 -259
  198. package/src/internal/channel/subexecutor.ts +0 -229
  199. package/src/internal/channel/upstreamPullRequest.ts +0 -84
  200. package/src/internal/channel/upstreamPullStrategy.ts +0 -87
  201. package/src/internal/channel.ts +0 -2603
  202. package/src/internal/clock.ts +0 -95
  203. package/src/internal/completedRequestMap.ts +0 -9
  204. package/src/internal/concurrency.ts +0 -54
  205. package/src/internal/config.ts +0 -716
  206. package/src/internal/configError.ts +0 -304
  207. package/src/internal/configProvider/pathPatch.ts +0 -97
  208. package/src/internal/configProvider.ts +0 -799
  209. package/src/internal/console.ts +0 -153
  210. package/src/internal/context.ts +0 -337
  211. package/src/internal/core-effect.ts +0 -2293
  212. package/src/internal/core-stream.ts +0 -998
  213. package/src/internal/core.ts +0 -3273
  214. package/src/internal/data.ts +0 -36
  215. package/src/internal/dataSource.ts +0 -327
  216. package/src/internal/dateTime.ts +0 -1277
  217. package/src/internal/defaultServices/console.ts +0 -100
  218. package/src/internal/defaultServices.ts +0 -163
  219. package/src/internal/deferred.ts +0 -46
  220. package/src/internal/differ/chunkPatch.ts +0 -211
  221. package/src/internal/differ/contextPatch.ts +0 -232
  222. package/src/internal/differ/hashMapPatch.ts +0 -220
  223. package/src/internal/differ/hashSetPatch.ts +0 -176
  224. package/src/internal/differ/orPatch.ts +0 -311
  225. package/src/internal/differ/readonlyArrayPatch.ts +0 -210
  226. package/src/internal/differ.ts +0 -200
  227. package/src/internal/doNotation.ts +0 -80
  228. package/src/internal/effect/circular.ts +0 -905
  229. package/src/internal/effectable.ts +0 -131
  230. package/src/internal/either.ts +0 -110
  231. package/src/internal/encoding/base64.ts +0 -286
  232. package/src/internal/encoding/base64Url.ts +0 -29
  233. package/src/internal/encoding/common.ts +0 -51
  234. package/src/internal/encoding/hex.ts +0 -315
  235. package/src/internal/errors.ts +0 -7
  236. package/src/internal/executionPlan.ts +0 -114
  237. package/src/internal/executionStrategy.ts +0 -74
  238. package/src/internal/fiber.ts +0 -388
  239. package/src/internal/fiberId.ts +0 -267
  240. package/src/internal/fiberMessage.ts +0 -82
  241. package/src/internal/fiberRefs/patch.ts +0 -144
  242. package/src/internal/fiberRefs.ts +0 -297
  243. package/src/internal/fiberRuntime.ts +0 -3915
  244. package/src/internal/fiberScope.ts +0 -71
  245. package/src/internal/fiberStatus.ts +0 -119
  246. package/src/internal/groupBy.ts +0 -530
  247. package/src/internal/hashMap/array.ts +0 -49
  248. package/src/internal/hashMap/bitwise.ts +0 -32
  249. package/src/internal/hashMap/config.ts +0 -14
  250. package/src/internal/hashMap/keySet.ts +0 -8
  251. package/src/internal/hashMap/node.ts +0 -391
  252. package/src/internal/hashMap.ts +0 -586
  253. package/src/internal/hashSet.ts +0 -323
  254. package/src/internal/keyedPool.ts +0 -244
  255. package/src/internal/layer/circular.ts +0 -228
  256. package/src/internal/layer.ts +0 -1487
  257. package/src/internal/logSpan.ts +0 -20
  258. package/src/internal/logger-circular.ts +0 -24
  259. package/src/internal/logger.ts +0 -485
  260. package/src/internal/mailbox.ts +0 -561
  261. package/src/internal/managedRuntime/circular.ts +0 -6
  262. package/src/internal/managedRuntime.ts +0 -134
  263. package/src/internal/matcher.ts +0 -652
  264. package/src/internal/metric/boundaries.ts +0 -75
  265. package/src/internal/metric/hook.ts +0 -483
  266. package/src/internal/metric/key.ts +0 -167
  267. package/src/internal/metric/keyType.ts +0 -238
  268. package/src/internal/metric/label.ts +0 -41
  269. package/src/internal/metric/pair.ts +0 -48
  270. package/src/internal/metric/polling.ts +0 -149
  271. package/src/internal/metric/registry.ts +0 -187
  272. package/src/internal/metric/state.ts +0 -290
  273. package/src/internal/metric.ts +0 -577
  274. package/src/internal/opCodes/cause.ts +0 -35
  275. package/src/internal/opCodes/channel.ts +0 -83
  276. package/src/internal/opCodes/channelChildExecutorDecision.ts +0 -17
  277. package/src/internal/opCodes/channelMergeDecision.ts +0 -11
  278. package/src/internal/opCodes/channelMergeState.ts +0 -17
  279. package/src/internal/opCodes/channelMergeStrategy.ts +0 -11
  280. package/src/internal/opCodes/channelState.ts +0 -23
  281. package/src/internal/opCodes/channelUpstreamPullRequest.ts +0 -11
  282. package/src/internal/opCodes/channelUpstreamPullStrategy.ts +0 -11
  283. package/src/internal/opCodes/config.ts +0 -65
  284. package/src/internal/opCodes/configError.ts +0 -35
  285. package/src/internal/opCodes/continuation.ts +0 -11
  286. package/src/internal/opCodes/deferred.ts +0 -11
  287. package/src/internal/opCodes/effect.ts +0 -89
  288. package/src/internal/opCodes/layer.ts +0 -59
  289. package/src/internal/opCodes/streamHaltStrategy.ts +0 -23
  290. package/src/internal/option.ts +0 -80
  291. package/src/internal/pool.ts +0 -432
  292. package/src/internal/pubsub.ts +0 -1762
  293. package/src/internal/query.ts +0 -204
  294. package/src/internal/queue.ts +0 -766
  295. package/src/internal/random.ts +0 -161
  296. package/src/internal/rateLimiter.ts +0 -93
  297. package/src/internal/rcMap.ts +0 -285
  298. package/src/internal/rcRef.ts +0 -192
  299. package/src/internal/redBlackTree/iterator.ts +0 -200
  300. package/src/internal/redBlackTree/node.ts +0 -68
  301. package/src/internal/redBlackTree.ts +0 -1245
  302. package/src/internal/redacted.ts +0 -73
  303. package/src/internal/ref.ts +0 -171
  304. package/src/internal/reloadable.ts +0 -140
  305. package/src/internal/request.ts +0 -177
  306. package/src/internal/resource.ts +0 -76
  307. package/src/internal/ringBuffer.ts +0 -68
  308. package/src/internal/runtime.ts +0 -558
  309. package/src/internal/runtimeFlags.ts +0 -188
  310. package/src/internal/runtimeFlagsPatch.ts +0 -103
  311. package/src/internal/schedule/decision.ts +0 -47
  312. package/src/internal/schedule/interval.ts +0 -101
  313. package/src/internal/schedule/intervals.ts +0 -180
  314. package/src/internal/schedule.ts +0 -2199
  315. package/src/internal/schema/errors.ts +0 -191
  316. package/src/internal/schema/schemaId.ts +0 -106
  317. package/src/internal/schema/util.ts +0 -50
  318. package/src/internal/scopedCache.ts +0 -644
  319. package/src/internal/scopedRef.ts +0 -118
  320. package/src/internal/secret.ts +0 -89
  321. package/src/internal/singleShotGen.ts +0 -35
  322. package/src/internal/sink.ts +0 -2120
  323. package/src/internal/stack.ts +0 -10
  324. package/src/internal/stm/core.ts +0 -817
  325. package/src/internal/stm/entry.ts +0 -59
  326. package/src/internal/stm/journal.ts +0 -123
  327. package/src/internal/stm/opCodes/stm.ts +0 -71
  328. package/src/internal/stm/opCodes/stmState.ts +0 -17
  329. package/src/internal/stm/opCodes/strategy.ts +0 -17
  330. package/src/internal/stm/opCodes/tExit.ts +0 -29
  331. package/src/internal/stm/opCodes/tryCommit.ts +0 -11
  332. package/src/internal/stm/stm.ts +0 -1453
  333. package/src/internal/stm/stmState.ts +0 -136
  334. package/src/internal/stm/tArray.ts +0 -550
  335. package/src/internal/stm/tDeferred.ts +0 -81
  336. package/src/internal/stm/tExit.ts +0 -190
  337. package/src/internal/stm/tMap.ts +0 -824
  338. package/src/internal/stm/tPriorityQueue.ts +0 -267
  339. package/src/internal/stm/tPubSub.ts +0 -551
  340. package/src/internal/stm/tQueue.ts +0 -393
  341. package/src/internal/stm/tRandom.ts +0 -140
  342. package/src/internal/stm/tReentrantLock.ts +0 -352
  343. package/src/internal/stm/tRef.ts +0 -195
  344. package/src/internal/stm/tSemaphore.ts +0 -113
  345. package/src/internal/stm/tSet.ts +0 -259
  346. package/src/internal/stm/tSubscriptionRef.ts +0 -286
  347. package/src/internal/stm/tryCommit.ts +0 -34
  348. package/src/internal/stm/txnId.ts +0 -14
  349. package/src/internal/stm/versioned.ts +0 -4
  350. package/src/internal/stream/debounceState.ts +0 -57
  351. package/src/internal/stream/emit.ts +0 -123
  352. package/src/internal/stream/haltStrategy.ts +0 -94
  353. package/src/internal/stream/handoff.ts +0 -187
  354. package/src/internal/stream/handoffSignal.ts +0 -59
  355. package/src/internal/stream/pull.ts +0 -34
  356. package/src/internal/stream/sinkEndReason.ts +0 -30
  357. package/src/internal/stream/zipAllState.ts +0 -88
  358. package/src/internal/stream/zipChunksState.ts +0 -56
  359. package/src/internal/stream.ts +0 -8801
  360. package/src/internal/string-utils.ts +0 -107
  361. package/src/internal/subscriptionRef.ts +0 -138
  362. package/src/internal/supervisor/patch.ts +0 -190
  363. package/src/internal/supervisor.ts +0 -303
  364. package/src/internal/synchronizedRef.ts +0 -114
  365. package/src/internal/take.ts +0 -199
  366. package/src/internal/testing/sleep.ts +0 -27
  367. package/src/internal/testing/suspendedWarningData.ts +0 -85
  368. package/src/internal/testing/warningData.ts +0 -94
  369. package/src/internal/tracer.ts +0 -293
  370. package/src/internal/trie.ts +0 -722
  371. package/src/internal/version.ts +0 -7
package/src/STM.ts DELETED
@@ -1,2045 +0,0 @@
1
- /**
2
- * @since 2.0.0
3
- */
4
- import * as Cause from "./Cause.js"
5
- import * as Chunk from "./Chunk.js"
6
- import type * as Context from "./Context.js"
7
- import type * as Effect from "./Effect.js"
8
- import type * as Either from "./Either.js"
9
- import type * as FiberId from "./FiberId.js"
10
- import type { LazyArg } from "./Function.js"
11
- import type { TypeLambda } from "./HKT.js"
12
- import * as core from "./internal/stm/core.js"
13
- import * as stm from "./internal/stm/stm.js"
14
- import type * as Option from "./Option.js"
15
- import type { Pipeable } from "./Pipeable.js"
16
- import type { Predicate, Refinement } from "./Predicate.js"
17
- import type { Covariant, MergeRecord, NoExcessProperties, NoInfer } from "./Types.js"
18
- import type * as Unify from "./Unify.js"
19
- import type { YieldWrap } from "./Utils.js"
20
-
21
- /**
22
- * @since 2.0.0
23
- * @category symbols
24
- */
25
- export const STMTypeId: unique symbol = core.STMTypeId
26
-
27
- /**
28
- * @since 2.0.0
29
- * @category symbols
30
- */
31
- export type STMTypeId = typeof STMTypeId
32
-
33
- /**
34
- * `STM<A, E, R>` represents an effect that can be performed transactionally,
35
- * resulting in a failure `E` or a value `A` that may require an environment
36
- * `R` to execute.
37
- *
38
- * Software Transactional Memory is a technique which allows composition of
39
- * arbitrary atomic operations. It is the software analog of transactions in
40
- * database systems.
41
- *
42
- * The API is lifted directly from the Haskell package Control.Concurrent.STM
43
- * although the implementation does not resemble the Haskell one at all.
44
- *
45
- * See http://hackage.haskell.org/package/stm-2.5.0.0/docs/Control-Concurrent-STM.html
46
- *
47
- * STM in Haskell was introduced in:
48
- *
49
- * Composable memory transactions, by Tim Harris, Simon Marlow, Simon Peyton
50
- * Jones, and Maurice Herlihy, in ACM Conference on Principles and Practice of
51
- * Parallel Programming 2005.
52
- *
53
- * See https://www.microsoft.com/en-us/research/publication/composable-memory-transactions/
54
- *
55
- * See also:
56
- * Lock Free Data Structures using STMs in Haskell, by Anthony Discolo, Tim
57
- * Harris, Simon Marlow, Simon Peyton Jones, Satnam Singh) FLOPS 2006: Eighth
58
- * International Symposium on Functional and Logic Programming, Fuji Susono,
59
- * JAPAN, April 2006
60
- *
61
- * https://www.microsoft.com/en-us/research/publication/lock-free-data-structures-using-stms-in-haskell/
62
- *
63
- * The implemtation is based on the ZIO STM module, while JS environments have
64
- * no race conditions from multiple threads STM provides greater benefits for
65
- * synchronization of Fibers and transactional data-types can be quite useful.
66
- *
67
- * @since 2.0.0
68
- * @category models
69
- */
70
- export interface STM<out A, out E = never, out R = never>
71
- extends Effect.Effect<A, E, R>, STM.Variance<A, E, R>, Pipeable
72
- {
73
- [Unify.typeSymbol]?: unknown
74
- [Unify.unifySymbol]?: STMUnify<this>
75
- [Unify.ignoreSymbol]?: STMUnifyIgnore
76
- [Symbol.iterator](): Effect.EffectGenerator<STM<A, E, R>>
77
- }
78
-
79
- /**
80
- * @since 2.0.0
81
- * @category models
82
- */
83
- export interface STMUnify<A extends { [Unify.typeSymbol]?: any }> extends Effect.EffectUnify<A> {
84
- STM?: () => A[Unify.typeSymbol] extends STM<infer A0, infer E0, infer R0> | infer _ ? STM<A0, E0, R0> : never
85
- }
86
-
87
- /**
88
- * @category models
89
- * @since 2.0.0
90
- */
91
- export interface STMUnifyIgnore extends Effect.EffectUnifyIgnore {
92
- Effect?: true
93
- }
94
-
95
- /**
96
- * @category type lambdas
97
- * @since 2.0.0
98
- */
99
- export interface STMTypeLambda extends TypeLambda {
100
- readonly type: STM<this["Target"], this["Out1"], this["Out2"]>
101
- }
102
-
103
- /**
104
- * @since 2.0.0
105
- * @category models
106
- */
107
- declare module "./Context.js" {
108
- interface Tag<Id, Value> extends STM<Value, never, Id> {}
109
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
110
- interface Reference<Id, Value> extends STM<Value> {}
111
- }
112
-
113
- /**
114
- * @since 2.0.0
115
- * @category models
116
- */
117
- declare module "./Either.js" {
118
- interface Left<E, A> extends STM<A, E> {
119
- readonly _tag: "Left"
120
- }
121
- interface Right<E, A> extends STM<A, E> {
122
- readonly _tag: "Right"
123
- }
124
- }
125
-
126
- /**
127
- * @since 2.0.0
128
- * @category models
129
- */
130
- declare module "./Option.js" {
131
- interface None<A> extends STM<A, Cause.NoSuchElementException> {
132
- readonly _tag: "None"
133
- }
134
- interface Some<A> extends STM<A, Cause.NoSuchElementException> {
135
- readonly _tag: "Some"
136
- }
137
- }
138
-
139
- /**
140
- * @since 2.0.0
141
- */
142
- export declare namespace STM {
143
- /**
144
- * @since 2.0.0
145
- * @category models
146
- */
147
- export interface Variance<out A, out E, out R> {
148
- readonly [STMTypeId]: {
149
- readonly _A: Covariant<A>
150
- readonly _E: Covariant<E>
151
- readonly _R: Covariant<R>
152
- }
153
- }
154
- }
155
-
156
- /**
157
- * Returns `true` if the provided value is an `STM`, `false` otherwise.
158
- *
159
- * @since 2.0.0
160
- * @category refinements
161
- */
162
- export const isSTM: (u: unknown) => u is STM<unknown, unknown, unknown> = core.isSTM
163
-
164
- /**
165
- * Treats the specified `acquire` transaction as the acquisition of a
166
- * resource. The `acquire` transaction will be executed interruptibly. If it
167
- * is a success and is committed the specified `release` workflow will be
168
- * executed uninterruptibly as soon as the `use` workflow completes execution.
169
- *
170
- * @since 2.0.0
171
- * @category constructors
172
- */
173
- export const acquireUseRelease: {
174
- <A, A2, E2, R2, A3, E3, R3>(
175
- use: (resource: A) => STM<A2, E2, R2>,
176
- release: (resource: A) => STM<A3, E3, R3>
177
- ): <E, R>(acquire: STM<A, E, R>) => Effect.Effect<A2, E2 | E3 | E, R2 | R3 | R>
178
- <A, E, R, A2, E2, R2, A3, E3, R3>(
179
- acquire: STM<A, E, R>,
180
- use: (resource: A) => STM<A2, E2, R2>,
181
- release: (resource: A) => STM<A3, E3, R3>
182
- ): Effect.Effect<A2, E | E2 | E3, R | R2 | R3>
183
- } = stm.acquireUseRelease
184
-
185
- /**
186
- * @since 2.0.0
187
- * @category utils
188
- */
189
- export declare namespace All {
190
- type STMAny = STM<any, any, any>
191
-
192
- type ReturnTuple<T extends ReadonlyArray<STM<any, any, any>>, Discard extends boolean> = STM<
193
- Discard extends true ? void
194
- : T[number] extends never ? []
195
- : { -readonly [K in keyof T]: [T[K]] extends [STM<infer A, infer _E, infer _R>] ? A : never },
196
- T[number] extends never ? never
197
- : [T[number]] extends [{ [STMTypeId]: { _E: (_: never) => infer E } }] ? E
198
- : never,
199
- T[number] extends never ? never
200
- : [T[number]] extends [{ [STMTypeId]: { _R: (_: never) => infer R } }] ? R
201
- : never
202
- > extends infer X ? X : never
203
-
204
- type ReturnIterable<T extends Iterable<STMAny>, Discard extends boolean> = [T] extends
205
- [Iterable<STM.Variance<infer A, infer E, infer R>>] ? STM<Discard extends true ? void : Array<A>, E, R> : never
206
-
207
- type ReturnObject<T extends Record<string, STMAny>, Discard extends boolean> = STM<
208
- Discard extends true ? void
209
- : { -readonly [K in keyof T]: [T[K]] extends [STM.Variance<infer A, infer _E, infer _R>] ? A : never },
210
- keyof T extends never ? never
211
- : [T[keyof T]] extends [{ [STMTypeId]: { _E: (_: never) => infer E } }] ? E
212
- : never,
213
- keyof T extends never ? never
214
- : [T[keyof T]] extends [{ [STMTypeId]: { _R: (_: never) => infer R } }] ? R
215
- : never
216
- >
217
-
218
- /**
219
- * @since 2.0.0
220
- * @category utils
221
- */
222
- export type Options = {
223
- readonly discard?: boolean | undefined
224
- }
225
- type IsDiscard<A> = [Extract<A, { readonly discard: true }>] extends [never] ? false : true
226
- type Narrow<A> = (A extends [] ? [] : never) | A
227
-
228
- /**
229
- * @since 2.0.0
230
- * @category utils
231
- */
232
- export interface Signature {
233
- <
234
- Arg extends ReadonlyArray<STMAny> | Iterable<STMAny> | Record<string, STMAny>,
235
- O extends NoExcessProperties<Options, O>
236
- >(
237
- arg: Narrow<Arg>,
238
- options?: O
239
- ): [Arg] extends [ReadonlyArray<STMAny>] ? ReturnTuple<Arg, IsDiscard<O>>
240
- : [Arg] extends [Iterable<STMAny>] ? ReturnIterable<Arg, IsDiscard<O>>
241
- : [Arg] extends [Record<string, STMAny>] ? ReturnObject<Arg, IsDiscard<O>>
242
- : never
243
- }
244
- }
245
-
246
- /**
247
- * Runs all the provided transactional effects in sequence respecting the
248
- * structure provided in input.
249
- *
250
- * Supports multiple arguments, a single argument tuple / array or record /
251
- * struct.
252
- *
253
- * @since 2.0.0
254
- * @category constructors
255
- */
256
- export const all: All.Signature = stm.all
257
-
258
- /**
259
- * Maps the success value of this effect to the specified constant value.
260
- *
261
- * @since 2.0.0
262
- * @category mapping
263
- */
264
- export const as: {
265
- <A2>(value: A2): <A, E, R>(self: STM<A, E, R>) => STM<A2, E, R>
266
- <A, E, R, A2>(self: STM<A, E, R>, value: A2): STM<A2, E, R>
267
- } = stm.as
268
-
269
- /**
270
- * Maps the success value of this effect to an optional value.
271
- *
272
- * @since 2.0.0
273
- * @category mapping
274
- */
275
- export const asSome: <A, E, R>(self: STM<A, E, R>) => STM<Option.Option<A>, E, R> = stm.asSome
276
-
277
- /**
278
- * Maps the error value of this effect to an optional value.
279
- *
280
- * @since 2.0.0
281
- * @category mapping
282
- */
283
- export const asSomeError: <A, E, R>(self: STM<A, E, R>) => STM<A, Option.Option<E>, R> = stm.asSomeError
284
-
285
- /**
286
- * This function maps the success value of an `STM` to `void`. If the original
287
- * `STM` succeeds, the returned `STM` will also succeed. If the original `STM`
288
- * fails, the returned `STM` will fail with the same error.
289
- *
290
- * @since 2.0.0
291
- * @category mapping
292
- */
293
- export const asVoid: <A, E, R>(self: STM<A, E, R>) => STM<void, E, R> = stm.asVoid
294
-
295
- /**
296
- * Creates an `STM` value from a partial (but pure) function.
297
- *
298
- * @since 2.0.0
299
- * @category constructors
300
- */
301
- export const attempt: <A>(evaluate: LazyArg<A>) => STM<A, unknown> = stm.attempt
302
-
303
- /**
304
- * Recovers from all errors.
305
- *
306
- * @since 2.0.0
307
- * @category error handling
308
- */
309
- export const catchAll: {
310
- <E, B, E1, R1>(f: (e: E) => STM<B, E1, R1>): <A, R>(self: STM<A, E, R>) => STM<B | A, E1, R1 | R>
311
- <A, E, R, B, E1, R1>(self: STM<A, E, R>, f: (e: E) => STM<B, E1, R1>): STM<A | B, E1, R | R1>
312
- } = core.catchAll
313
-
314
- /**
315
- * Recovers from some or all of the error cases.
316
- *
317
- * @since 2.0.0
318
- * @category error handling
319
- */
320
- export const catchSome: {
321
- <E, A2, E2, R2>(
322
- pf: (error: E) => Option.Option<STM<A2, E2, R2>>
323
- ): <A, R>(self: STM<A, E, R>) => STM<A2 | A, E | E2, R2 | R>
324
- <A, E, R, A2, E2, R2>(
325
- self: STM<A, E, R>,
326
- pf: (error: E) => Option.Option<STM<A2, E2, R2>>
327
- ): STM<A | A2, E | E2, R | R2>
328
- } = stm.catchSome
329
-
330
- /**
331
- * Recovers from the specified tagged error.
332
- *
333
- * @since 2.0.0
334
- * @category error handling
335
- */
336
- export const catchTag: {
337
- <K extends E["_tag"] & string, E extends { _tag: string }, A1, E1, R1>(
338
- k: K,
339
- f: (e: Extract<E, { _tag: K }>) => STM<A1, E1, R1>
340
- ): <A, R>(self: STM<A, E, R>) => STM<A1 | A, E1 | Exclude<E, { _tag: K }>, R1 | R>
341
- <A, E extends { _tag: string }, R, K extends E["_tag"] & string, A1, E1, R1>(
342
- self: STM<A, E, R>,
343
- k: K,
344
- f: (e: Extract<E, { _tag: K }>) => STM<A1, E1, R1>
345
- ): STM<A | A1, E1 | Exclude<E, { _tag: K }>, R | R1>
346
- } = stm.catchTag
347
-
348
- /**
349
- * Recovers from multiple tagged errors.
350
- *
351
- * @since 2.0.0
352
- * @category error handling
353
- */
354
- export const catchTags: {
355
- <
356
- E extends { _tag: string },
357
- Cases extends { [K in E["_tag"]]+?: ((error: Extract<E, { _tag: K }>) => STM<any, any, any>) }
358
- >(
359
- cases: Cases
360
- ): <A, R>(
361
- self: STM<A, E, R>
362
- ) => STM<
363
- | A
364
- | { [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => STM<infer A, any, any> ? A : never }[keyof Cases],
365
- | Exclude<E, { _tag: keyof Cases }>
366
- | { [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => STM<any, infer E, any> ? E : never }[keyof Cases],
367
- | R
368
- | { [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => STM<any, any, infer R> ? R : never }[keyof Cases]
369
- >
370
- <
371
- R,
372
- E extends { _tag: string },
373
- A,
374
- Cases extends { [K in E["_tag"]]+?: ((error: Extract<E, { _tag: K }>) => STM<any, any, any>) }
375
- >(
376
- self: STM<A, E, R>,
377
- cases: Cases
378
- ): STM<
379
- | A
380
- | { [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => STM<infer A, any, any> ? A : never }[keyof Cases],
381
- | Exclude<E, { _tag: keyof Cases }>
382
- | { [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => STM<any, infer E, any> ? E : never }[keyof Cases],
383
- | R
384
- | { [K in keyof Cases]: Cases[K] extends (...args: Array<any>) => STM<any, any, infer R> ? R : never }[keyof Cases]
385
- >
386
- } = stm.catchTags
387
-
388
- /**
389
- * Checks the condition, and if it's true, returns unit, otherwise, retries.
390
- *
391
- * @since 2.0.0
392
- * @category constructors
393
- */
394
- export const check: (predicate: LazyArg<boolean>) => STM<void> = stm.check
395
-
396
- /**
397
- * Simultaneously filters and maps the value produced by this effect.
398
- *
399
- * @since 2.0.0
400
- * @category mutations
401
- */
402
- export const collect: {
403
- <A, A2>(pf: (a: A) => Option.Option<A2>): <E, R>(self: STM<A, E, R>) => STM<A2, E, R>
404
- <A, E, R, A2>(self: STM<A, E, R>, pf: (a: A) => Option.Option<A2>): STM<A2, E, R>
405
- } = stm.collect
406
-
407
- /**
408
- * Simultaneously filters and maps the value produced by this effect.
409
- *
410
- * @since 2.0.0
411
- * @category mutations
412
- */
413
- export const collectSTM: {
414
- <A, A2, E2, R2>(pf: (a: A) => Option.Option<STM<A2, E2, R2>>): <E, R>(self: STM<A, E, R>) => STM<A2, E2 | E, R2 | R>
415
- <A, E, R, A2, E2, R2>(self: STM<A, E, R>, pf: (a: A) => Option.Option<STM<A2, E2, R2>>): STM<A2, E | E2, R | R2>
416
- } = stm.collectSTM
417
-
418
- /**
419
- * Commits this transaction atomically.
420
- *
421
- * @since 2.0.0
422
- * @category destructors
423
- */
424
- export const commit: <A, E, R>(self: STM<A, E, R>) => Effect.Effect<A, E, R> = core.commit
425
-
426
- /**
427
- * Commits this transaction atomically, regardless of whether the transaction
428
- * is a success or a failure.
429
- *
430
- * @since 2.0.0
431
- * @category destructors
432
- */
433
- export const commitEither: <A, E, R>(self: STM<A, E, R>) => Effect.Effect<A, E, R> = stm.commitEither
434
-
435
- /**
436
- * Similar to Either.cond, evaluate the predicate, return the given A as
437
- * success if predicate returns true, and the given E as error otherwise
438
- *
439
- * @since 2.0.0
440
- * @category constructors
441
- */
442
- export const cond: <A, E>(predicate: LazyArg<boolean>, error: LazyArg<E>, result: LazyArg<A>) => STM<A, E> = stm.cond
443
-
444
- /**
445
- * Retrieves the environment inside an stm.
446
- *
447
- * @since 2.0.0
448
- * @category constructors
449
- */
450
- export const context: <R>() => STM<Context.Context<R>, never, R> = core.context
451
-
452
- /**
453
- * Accesses the environment of the transaction to perform a transaction.
454
- *
455
- * @since 2.0.0
456
- * @category constructors
457
- */
458
- export const contextWith: <R0, R>(f: (environment: Context.Context<R0>) => R) => STM<R, never, R0> = core.contextWith
459
-
460
- /**
461
- * Accesses the environment of the transaction to perform a transaction.
462
- *
463
- * @since 2.0.0
464
- * @category constructors
465
- */
466
- export const contextWithSTM: <R0, A, E, R>(
467
- f: (environment: Context.Context<R0>) => STM<A, E, R>
468
- ) => STM<A, E, R0 | R> = core.contextWithSTM
469
-
470
- /**
471
- * Transforms the environment being provided to this effect with the specified
472
- * function.
473
- *
474
- * @since 2.0.0
475
- * @category context
476
- */
477
- export const mapInputContext: {
478
- <R0, R>(f: (context: Context.Context<R0>) => Context.Context<R>): <A, E>(self: STM<A, E, R>) => STM<A, E, R0>
479
- <A, E, R0, R>(self: STM<A, E, R>, f: (context: Context.Context<R0>) => Context.Context<R>): STM<A, E, R0>
480
- } = core.mapInputContext
481
-
482
- /**
483
- * Fails the transactional effect with the specified defect.
484
- *
485
- * @since 2.0.0
486
- * @category constructors
487
- */
488
- export const die: (defect: unknown) => STM<never> = core.die
489
-
490
- /**
491
- * Kills the fiber running the effect with a `Cause.RuntimeException` that
492
- * contains the specified message.
493
- *
494
- * @since 2.0.0
495
- * @category constructors
496
- */
497
- export const dieMessage: (message: string) => STM<never> = core.dieMessage
498
-
499
- /**
500
- * Fails the transactional effect with the specified lazily evaluated defect.
501
- *
502
- * @since 2.0.0
503
- * @category constructors
504
- */
505
- export const dieSync: (evaluate: LazyArg<unknown>) => STM<never> = core.dieSync
506
-
507
- /**
508
- * Converts the failure channel into an `Either`.
509
- *
510
- * @since 2.0.0
511
- * @category mutations
512
- */
513
- export const either: <A, E, R>(self: STM<A, E, R>) => STM<Either.Either<A, E>, never, R> = stm.either
514
-
515
- /**
516
- * Executes the specified finalization transaction whether or not this effect
517
- * succeeds. Note that as with all STM transactions, if the full transaction
518
- * fails, everything will be rolled back.
519
- *
520
- * @since 2.0.0
521
- * @category finalization
522
- */
523
- export const ensuring: {
524
- <R1, B>(finalizer: STM<B, never, R1>): <A, E, R>(self: STM<A, E, R>) => STM<A, E, R1 | R>
525
- <A, E, R, R1, B>(self: STM<A, E, R>, finalizer: STM<B, never, R1>): STM<A, E, R | R1>
526
- } = core.ensuring
527
-
528
- /**
529
- * Returns an effect that ignores errors and runs repeatedly until it
530
- * eventually succeeds.
531
- *
532
- * @since 2.0.0
533
- * @category mutations
534
- */
535
- export const eventually: <A, E, R>(self: STM<A, E, R>) => STM<A, E, R> = stm.eventually
536
-
537
- /**
538
- * Determines whether all elements of the `Iterable<A>` satisfy the effectual
539
- * predicate.
540
- *
541
- * @since 2.0.0
542
- * @category constructors
543
- */
544
- export const every: {
545
- <A, R, E>(predicate: (a: NoInfer<A>) => STM<boolean, E, R>): (iterable: Iterable<A>) => STM<boolean, E, R>
546
- <A, R, E>(iterable: Iterable<A>, predicate: (a: A) => STM<boolean, E, R>): STM<boolean, E, R>
547
- } = stm.every
548
-
549
- /**
550
- * Determines whether any element of the `Iterable[A]` satisfies the effectual
551
- * predicate `f`.
552
- *
553
- * @since 2.0.0
554
- * @category constructors
555
- */
556
- export const exists: {
557
- <A, R, E>(predicate: (a: NoInfer<A>) => STM<boolean, E, R>): (iterable: Iterable<A>) => STM<boolean, E, R>
558
- <A, R, E>(iterable: Iterable<A>, predicate: (a: A) => STM<boolean, E, R>): STM<boolean, E, R>
559
- } = stm.exists
560
-
561
- /**
562
- * Fails the transactional effect with the specified error.
563
- *
564
- * @since 2.0.0
565
- * @category constructors
566
- */
567
- export const fail: <E>(error: E) => STM<never, E> = core.fail
568
-
569
- /**
570
- * Fails the transactional effect with the specified lazily evaluated error.
571
- *
572
- * @since 2.0.0
573
- * @category constructors
574
- */
575
- export const failSync: <E>(evaluate: LazyArg<E>) => STM<never, E> = core.failSync
576
-
577
- /**
578
- * Returns the fiber id of the fiber committing the transaction.
579
- *
580
- * @since 2.0.0
581
- * @category constructors
582
- */
583
- export const fiberId: STM<FiberId.FiberId> = stm.fiberId
584
-
585
- /**
586
- * Filters the collection using the specified effectual predicate.
587
- *
588
- * @since 2.0.0
589
- * @category constructors
590
- */
591
- export const filter: {
592
- <A, R, E>(predicate: (a: NoInfer<A>) => STM<boolean, E, R>): (iterable: Iterable<A>) => STM<Array<A>, E, R>
593
- <A, R, E>(iterable: Iterable<A>, predicate: (a: A) => STM<boolean, E, R>): STM<Array<A>, E, R>
594
- } = stm.filter
595
-
596
- /**
597
- * Filters the collection using the specified effectual predicate, removing
598
- * all elements that satisfy the predicate.
599
- *
600
- * @since 2.0.0
601
- * @category constructors
602
- */
603
- export const filterNot: {
604
- <A, R, E>(predicate: (a: NoInfer<A>) => STM<boolean, E, R>): (iterable: Iterable<A>) => STM<Array<A>, E, R>
605
- <A, R, E>(iterable: Iterable<A>, predicate: (a: A) => STM<boolean, E, R>): STM<Array<A>, E, R>
606
- } = stm.filterNot
607
-
608
- /**
609
- * Dies with specified defect if the predicate fails.
610
- *
611
- * @since 2.0.0
612
- * @category filtering
613
- */
614
- export const filterOrDie: {
615
- <A, B extends A>(
616
- refinement: Refinement<NoInfer<A>, B>,
617
- defect: LazyArg<unknown>
618
- ): <E, R>(self: STM<A, E, R>) => STM<B, E, R>
619
- <A>(predicate: Predicate<NoInfer<A>>, defect: LazyArg<unknown>): <E, R>(self: STM<A, E, R>) => STM<A, E, R>
620
- <A, E, R, B extends A>(self: STM<A, E, R>, refinement: Refinement<A, B>, defect: LazyArg<unknown>): STM<B, E, R>
621
- <A, E, R>(self: STM<A, E, R>, predicate: Predicate<A>, defect: LazyArg<unknown>): STM<A, E, R>
622
- } = stm.filterOrDie
623
-
624
- /**
625
- * Dies with a `Cause.RuntimeException` having the specified message if the
626
- * predicate fails.
627
- *
628
- * @since 2.0.0
629
- * @category filtering
630
- */
631
- export const filterOrDieMessage: {
632
- <A, B extends A>(refinement: Refinement<NoInfer<A>, B>, message: string): <E, R>(self: STM<A, E, R>) => STM<B, E, R>
633
- <A>(predicate: Predicate<NoInfer<A>>, message: string): <E, R>(self: STM<A, E, R>) => STM<A, E, R>
634
- <A, E, R, B extends A>(self: STM<A, E, R>, refinement: Refinement<A, B>, message: string): STM<B, E, R>
635
- <A, E, R>(self: STM<A, E, R>, predicate: Predicate<A>, message: string): STM<A, E, R>
636
- } = stm.filterOrDieMessage
637
-
638
- /**
639
- * Supplies `orElse` if the predicate fails.
640
- *
641
- * @since 2.0.0
642
- * @category filtering
643
- */
644
- export const filterOrElse: {
645
- <A, B extends A, C, E2, R2>(
646
- refinement: Refinement<NoInfer<A>, B>,
647
- orElse: (a: NoInfer<A>) => STM<C, E2, R2>
648
- ): <E, R>(self: STM<A, E, R>) => STM<B | C, E2 | E, R2 | R>
649
- <A, B, E2, R2>(
650
- predicate: Predicate<NoInfer<A>>,
651
- orElse: (a: NoInfer<A>) => STM<B, E2, R2>
652
- ): <E, R>(self: STM<A, E, R>) => STM<A | B, E2 | E, R2 | R>
653
- <A, E, R, B extends A, C, E2, R2>(
654
- self: STM<A, E, R>,
655
- refinement: Refinement<A, B>,
656
- orElse: (a: A) => STM<C, E2, R2>
657
- ): STM<B | C, E | E2, R | R2>
658
- <A, E, R, B, E2, R2>(
659
- self: STM<A, E, R>,
660
- predicate: Predicate<A>,
661
- orElse: (a: A) => STM<B, E2, R2>
662
- ): STM<A | B, E | E2, R | R2>
663
- } = stm.filterOrElse
664
-
665
- /**
666
- * Fails with the specified error if the predicate fails.
667
- *
668
- * @since 2.0.0
669
- * @category filtering
670
- */
671
- export const filterOrFail: {
672
- <A, B extends A, E2>(
673
- refinement: Refinement<NoInfer<A>, B>,
674
- orFailWith: (a: NoInfer<A>) => E2
675
- ): <E, R>(self: STM<A, E, R>) => STM<B, E2 | E, R>
676
- <A, E2>(
677
- predicate: Predicate<NoInfer<A>>,
678
- orFailWith: (a: NoInfer<A>) => E2
679
- ): <E, R>(self: STM<A, E, R>) => STM<A, E2 | E, R>
680
- <A, E, R, B extends A, E2>(
681
- self: STM<A, E, R>,
682
- refinement: Refinement<A, B>,
683
- orFailWith: (a: A) => E2
684
- ): STM<B, E | E2, R>
685
- <A, E, R, E2>(self: STM<A, E, R>, predicate: Predicate<A>, orFailWith: (a: A) => E2): STM<A, E | E2, R>
686
- } = stm.filterOrFail
687
-
688
- /**
689
- * Feeds the value produced by this effect to the specified function, and then
690
- * runs the returned effect as well to produce its results.
691
- *
692
- * @since 2.0.0
693
- * @category sequencing
694
- */
695
- export const flatMap: {
696
- <A, A2, E1, R1>(f: (a: A) => STM<A2, E1, R1>): <E, R>(self: STM<A, E, R>) => STM<A2, E1 | E, R1 | R>
697
- <A, E, R, A2, E1, R1>(self: STM<A, E, R>, f: (a: A) => STM<A2, E1, R1>): STM<A2, E | E1, R | R1>
698
- } = core.flatMap
699
-
700
- /**
701
- * Flattens out a nested `STM` effect.
702
- *
703
- * @since 2.0.0
704
- * @category sequencing
705
- */
706
- export const flatten: <A, E2, R2, E, R>(self: STM<STM<A, E2, R2>, E, R>) => STM<A, E2 | E, R2 | R> = stm.flatten
707
-
708
- /**
709
- * Flips the success and failure channels of this transactional effect. This
710
- * allows you to use all methods on the error channel, possibly before
711
- * flipping back.
712
- *
713
- * @since 2.0.0
714
- * @category mutations
715
- */
716
- export const flip: <A, E, R>(self: STM<A, E, R>) => STM<E, A, R> = stm.flip
717
-
718
- /**
719
- * Swaps the error/value parameters, applies the function `f` and flips the
720
- * parameters back
721
- *
722
- * @since 2.0.0
723
- * @category mutations
724
- */
725
- export const flipWith: {
726
- <E, A, R, E2, A2, R2>(f: (stm: STM<E, A, R>) => STM<E2, A2, R2>): (self: STM<A, E, R>) => STM<A | A2, E | E2, R | R2>
727
- <A, E, R, E2, A2, R2>(self: STM<A, E, R>, f: (stm: STM<E, A, R>) => STM<E2, A2, R2>): STM<A | A2, E | E2, R | R2>
728
- } = stm.flipWith
729
-
730
- /**
731
- * Folds over the `STM` effect, handling both failure and success, but not
732
- * retry.
733
- *
734
- * @since 2.0.0
735
- * @category folding
736
- */
737
- export const match: {
738
- <E, A2, A, A3>(
739
- options: { readonly onFailure: (error: E) => A2; readonly onSuccess: (value: A) => A3 }
740
- ): <R>(self: STM<A, E, R>) => STM<A2 | A3, never, R>
741
- <A, E, R, A2, A3>(
742
- self: STM<A, E, R>,
743
- options: { readonly onFailure: (error: E) => A2; readonly onSuccess: (value: A) => A3 }
744
- ): STM<A2 | A3, never, R>
745
- } = stm.match
746
-
747
- /**
748
- * Effectfully folds over the `STM` effect, handling both failure and success.
749
- *
750
- * @since 2.0.0
751
- * @category folding
752
- */
753
- export const matchSTM: {
754
- <E, A1, E1, R1, A, A2, E2, R2>(
755
- options: { readonly onFailure: (e: E) => STM<A1, E1, R1>; readonly onSuccess: (a: A) => STM<A2, E2, R2> }
756
- ): <R>(self: STM<A, E, R>) => STM<A1 | A2, E1 | E2, R1 | R2 | R>
757
- <A, E, R, A1, E1, R1, A2, E2, R2>(
758
- self: STM<A, E, R>,
759
- options: { readonly onFailure: (e: E) => STM<A1, E1, R1>; readonly onSuccess: (a: A) => STM<A2, E2, R2> }
760
- ): STM<A1 | A2, E1 | E2, R | R1 | R2>
761
- } = core.matchSTM
762
-
763
- /**
764
- * Applies the function `f` to each element of the `Iterable<A>` and returns
765
- * a transactional effect that produces a new `Chunk<A2>`.
766
- *
767
- * @since 2.0.0
768
- * @category traversing
769
- */
770
- export const forEach: {
771
- <A, A2, E, R>(
772
- f: (a: A) => STM<A2, E, R>,
773
- options?: { readonly discard?: false | undefined } | undefined
774
- ): (elements: Iterable<A>) => STM<Array<A2>, E, R>
775
- <A, A2, E, R>(
776
- f: (a: A) => STM<A2, E, R>,
777
- options: { readonly discard: true }
778
- ): (elements: Iterable<A>) => STM<void, E, R>
779
- <A, A2, E, R>(
780
- elements: Iterable<A>,
781
- f: (a: A) => STM<A2, E, R>,
782
- options?: { readonly discard?: false | undefined } | undefined
783
- ): STM<Array<A2>, E, R>
784
- <A, A2, E, R>(elements: Iterable<A>, f: (a: A) => STM<A2, E, R>, options: { readonly discard: true }): STM<void, E, R>
785
- } = stm.forEach
786
-
787
- /**
788
- * Lifts an `Either` into a `STM`.
789
- *
790
- * @since 2.0.0
791
- * @category constructors
792
- */
793
- export const fromEither: <A, E>(either: Either.Either<A, E>) => STM<A, E> = stm.fromEither
794
-
795
- /**
796
- * Lifts an `Option` into a `STM`.
797
- *
798
- * @since 2.0.0
799
- * @category constructors
800
- */
801
- export const fromOption: <A>(option: Option.Option<A>) => STM<A, Option.Option<never>> = stm.fromOption
802
-
803
- /**
804
- * @since 2.0.0
805
- * @category models
806
- */
807
- export interface Adapter {
808
- <A, E, R>(self: STM<A, E, R>): STM<A, E, R>
809
- <A, _R, _E, _A>(a: A, ab: (a: A) => STM<_A, _E, _R>): STM<_A, _E, _R>
810
- <A, B, _R, _E, _A>(a: A, ab: (a: A) => B, bc: (b: B) => STM<_A, _E, _R>): STM<_A, _E, _R>
811
- <A, B, C, _R, _E, _A>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => STM<_A, _E, _R>): STM<_A, _E, _R>
812
- <A, B, C, D, _R, _E, _A>(
813
- a: A,
814
- ab: (a: A) => B,
815
- bc: (b: B) => C,
816
- cd: (c: C) => D,
817
- de: (d: D) => STM<_A, _E, _R>
818
- ): STM<_A, _E, _R>
819
- <A, B, C, D, E, _R, _E, _A>(
820
- a: A,
821
- ab: (a: A) => B,
822
- bc: (b: B) => C,
823
- cd: (c: C) => D,
824
- de: (d: D) => E,
825
- ef: (e: E) => STM<_A, _E, _R>
826
- ): STM<_A, _E, _R>
827
- <A, B, C, D, E, F, _R, _E, _A>(
828
- a: A,
829
- ab: (a: A) => B,
830
- bc: (b: B) => C,
831
- cd: (c: C) => D,
832
- de: (d: D) => E,
833
- ef: (e: E) => F,
834
- fg: (f: F) => STM<_A, _E, _R>
835
- ): STM<_A, _E, _R>
836
- <A, B, C, D, E, F, G, _R, _E, _A>(
837
- a: A,
838
- ab: (a: A) => B,
839
- bc: (b: B) => C,
840
- cd: (c: C) => D,
841
- de: (d: D) => E,
842
- ef: (e: E) => F,
843
- fg: (f: F) => G,
844
- gh: (g: F) => STM<_A, _E, _R>
845
- ): STM<_A, _E, _R>
846
- <A, B, C, D, E, F, G, H, _R, _E, _A>(
847
- a: A,
848
- ab: (a: A) => B,
849
- bc: (b: B) => C,
850
- cd: (c: C) => D,
851
- de: (d: D) => E,
852
- ef: (e: E) => F,
853
- fg: (f: F) => G,
854
- gh: (g: G) => H,
855
- hi: (g: H) => STM<_A, _E, _R>
856
- ): STM<_A, _E, _R>
857
- <A, B, C, D, E, F, G, H, I, _R, _E, _A>(
858
- a: A,
859
- ab: (a: A) => B,
860
- bc: (b: B) => C,
861
- cd: (c: C) => D,
862
- de: (d: D) => E,
863
- ef: (e: E) => F,
864
- fg: (f: F) => G,
865
- gh: (g: G) => H,
866
- hi: (h: H) => I,
867
- ij: (i: I) => STM<_A, _E, _R>
868
- ): STM<_A, _E, _R>
869
- <A, B, C, D, E, F, G, H, I, J, _R, _E, _A>(
870
- a: A,
871
- ab: (a: A) => B,
872
- bc: (b: B) => C,
873
- cd: (c: C) => D,
874
- de: (d: D) => E,
875
- ef: (e: E) => F,
876
- fg: (f: F) => G,
877
- gh: (g: G) => H,
878
- hi: (h: H) => I,
879
- ij: (i: I) => J,
880
- jk: (j: J) => STM<_A, _E, _R>
881
- ): STM<_A, _E, _R>
882
- <A, B, C, D, E, F, G, H, I, J, K, _R, _E, _A>(
883
- a: A,
884
- ab: (a: A) => B,
885
- bc: (b: B) => C,
886
- cd: (c: C) => D,
887
- de: (d: D) => E,
888
- ef: (e: E) => F,
889
- fg: (f: F) => G,
890
- gh: (g: G) => H,
891
- hi: (h: H) => I,
892
- ij: (i: I) => J,
893
- jk: (j: J) => K,
894
- kl: (k: K) => STM<_A, _E, _R>
895
- ): STM<_A, _E, _R>
896
- <A, B, C, D, E, F, G, H, I, J, K, L, _R, _E, _A>(
897
- a: A,
898
- ab: (a: A) => B,
899
- bc: (b: B) => C,
900
- cd: (c: C) => D,
901
- de: (d: D) => E,
902
- ef: (e: E) => F,
903
- fg: (f: F) => G,
904
- gh: (g: G) => H,
905
- hi: (h: H) => I,
906
- ij: (i: I) => J,
907
- jk: (j: J) => K,
908
- kl: (k: K) => L,
909
- lm: (l: L) => STM<_A, _E, _R>
910
- ): STM<_A, _E, _R>
911
- <A, B, C, D, E, F, G, H, I, J, K, L, M, _R, _E, _A>(
912
- a: A,
913
- ab: (a: A) => B,
914
- bc: (b: B) => C,
915
- cd: (c: C) => D,
916
- de: (d: D) => E,
917
- ef: (e: E) => F,
918
- fg: (f: F) => G,
919
- gh: (g: G) => H,
920
- hi: (h: H) => I,
921
- ij: (i: I) => J,
922
- jk: (j: J) => K,
923
- kl: (k: K) => L,
924
- lm: (l: L) => M,
925
- mn: (m: M) => STM<_A, _E, _R>
926
- ): STM<_A, _E, _R>
927
- <A, B, C, D, E, F, G, H, I, J, K, L, M, N, _R, _E, _A>(
928
- a: A,
929
- ab: (a: A) => B,
930
- bc: (b: B) => C,
931
- cd: (c: C) => D,
932
- de: (d: D) => E,
933
- ef: (e: E) => F,
934
- fg: (f: F) => G,
935
- gh: (g: G) => H,
936
- hi: (h: H) => I,
937
- ij: (i: I) => J,
938
- jk: (j: J) => K,
939
- kl: (k: K) => L,
940
- lm: (l: L) => M,
941
- mn: (m: M) => N,
942
- no: (n: N) => STM<_A, _E, _R>
943
- ): STM<_A, _E, _R>
944
- <A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, _R, _E, _A>(
945
- a: A,
946
- ab: (a: A) => B,
947
- bc: (b: B) => C,
948
- cd: (c: C) => D,
949
- de: (d: D) => E,
950
- ef: (e: E) => F,
951
- fg: (f: F) => G,
952
- gh: (g: G) => H,
953
- hi: (h: H) => I,
954
- ij: (i: I) => J,
955
- jk: (j: J) => K,
956
- kl: (k: K) => L,
957
- lm: (l: L) => M,
958
- mn: (m: M) => N,
959
- no: (n: N) => O,
960
- op: (o: O) => STM<_A, _E, _R>
961
- ): STM<_A, _E, _R>
962
- <A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, _R, _E, _A>(
963
- a: A,
964
- ab: (a: A) => B,
965
- bc: (b: B) => C,
966
- cd: (c: C) => D,
967
- de: (d: D) => E,
968
- ef: (e: E) => F,
969
- fg: (f: F) => G,
970
- gh: (g: G) => H,
971
- hi: (h: H) => I,
972
- ij: (i: I) => J,
973
- jk: (j: J) => K,
974
- kl: (k: K) => L,
975
- lm: (l: L) => M,
976
- mn: (m: M) => N,
977
- no: (n: N) => O,
978
- op: (o: O) => P,
979
- pq: (p: P) => STM<_A, _E, _R>
980
- ): STM<_A, _E, _R>
981
- <A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, _R, _E, _A>(
982
- a: A,
983
- ab: (a: A) => B,
984
- bc: (b: B) => C,
985
- cd: (c: C) => D,
986
- de: (d: D) => E,
987
- ef: (e: E) => F,
988
- fg: (f: F) => G,
989
- gh: (g: G) => H,
990
- hi: (h: H) => I,
991
- ij: (i: I) => J,
992
- jk: (j: J) => K,
993
- kl: (k: K) => L,
994
- lm: (l: L) => M,
995
- mn: (m: M) => N,
996
- no: (n: N) => O,
997
- op: (o: O) => P,
998
- pq: (p: P) => Q,
999
- qr: (q: Q) => STM<_A, _E, _R>
1000
- ): STM<_A, _E, _R>
1001
- <A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, _R, _E, _A>(
1002
- a: A,
1003
- ab: (a: A) => B,
1004
- bc: (b: B) => C,
1005
- cd: (c: C) => D,
1006
- de: (d: D) => E,
1007
- ef: (e: E) => F,
1008
- fg: (f: F) => G,
1009
- gh: (g: G) => H,
1010
- hi: (h: H) => I,
1011
- ij: (i: I) => J,
1012
- jk: (j: J) => K,
1013
- kl: (k: K) => L,
1014
- lm: (l: L) => M,
1015
- mn: (m: M) => N,
1016
- no: (n: N) => O,
1017
- op: (o: O) => P,
1018
- pq: (p: P) => Q,
1019
- qr: (q: Q) => R,
1020
- rs: (r: R) => STM<_A, _E, _R>
1021
- ): STM<_A, _E, _R>
1022
- <A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, _R, _E, _A>(
1023
- a: A,
1024
- ab: (a: A) => B,
1025
- bc: (b: B) => C,
1026
- cd: (c: C) => D,
1027
- de: (d: D) => E,
1028
- ef: (e: E) => F,
1029
- fg: (f: F) => G,
1030
- gh: (g: G) => H,
1031
- hi: (h: H) => I,
1032
- ij: (i: I) => J,
1033
- jk: (j: J) => K,
1034
- kl: (k: K) => L,
1035
- lm: (l: L) => M,
1036
- mn: (m: M) => N,
1037
- no: (n: N) => O,
1038
- op: (o: O) => P,
1039
- pq: (p: P) => Q,
1040
- qr: (q: Q) => R,
1041
- rs: (r: R) => S,
1042
- st: (s: S) => STM<_A, _E, _R>
1043
- ): STM<_A, _E, _R>
1044
- <A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, _R, _E, _A>(
1045
- a: A,
1046
- ab: (a: A) => B,
1047
- bc: (b: B) => C,
1048
- cd: (c: C) => D,
1049
- de: (d: D) => E,
1050
- ef: (e: E) => F,
1051
- fg: (f: F) => G,
1052
- gh: (g: G) => H,
1053
- hi: (h: H) => I,
1054
- ij: (i: I) => J,
1055
- jk: (j: J) => K,
1056
- kl: (k: K) => L,
1057
- lm: (l: L) => M,
1058
- mn: (m: M) => N,
1059
- no: (n: N) => O,
1060
- op: (o: O) => P,
1061
- pq: (p: P) => Q,
1062
- qr: (q: Q) => R,
1063
- rs: (r: R) => S,
1064
- st: (s: S) => T,
1065
- tu: (s: T) => STM<_A, _E, _R>
1066
- ): STM<_A, _E, _R>
1067
- }
1068
-
1069
- /**
1070
- * @since 2.0.0
1071
- * @category constructors
1072
- */
1073
- export const gen: <Self, Eff extends YieldWrap<STM<any, any, any>>, AEff>(
1074
- ...args:
1075
- | [
1076
- self: Self,
1077
- body: (this: Self, resume: Adapter) => Generator<Eff, AEff, never>
1078
- ]
1079
- | [body: (resume: Adapter) => Generator<Eff, AEff, never>]
1080
- ) => STM<
1081
- AEff,
1082
- [Eff] extends [never] ? never : [Eff] extends [YieldWrap<STM<infer _A, infer E, infer _R>>] ? E : never,
1083
- [Eff] extends [never] ? never : [Eff] extends [YieldWrap<STM<infer _A, infer _E, infer R>>] ? R : never
1084
- > = stm.gen
1085
-
1086
- /**
1087
- * Returns a successful effect with the head of the list if the list is
1088
- * non-empty or fails with the error `None` if the list is empty.
1089
- *
1090
- * @since 2.0.0
1091
- * @category getters
1092
- */
1093
- export const head: <A, E, R>(self: STM<Iterable<A>, E, R>) => STM<A, Option.Option<E>, R> = stm.head
1094
-
1095
- const if_: {
1096
- <A, E1, R1, A2, E2, R2>(options: {
1097
- readonly onTrue: STM<A, E1, R1>
1098
- readonly onFalse: STM<A2, E2, R2> /**
1099
- * Flattens out a nested `STM` effect.
1100
- *
1101
- * @since 2.0.0
1102
- * @category sequencing
1103
- */
1104
- }): <E = never, R = never>(self: boolean | STM<boolean, E, R>) => STM<A | A2, E1 | E2 | E, R1 | R2 | R>
1105
- <A, E1, R1, A2, E2, R2, E = never, R = never>(
1106
- self: boolean,
1107
- options: { readonly onTrue: STM<A, E1, R1>; readonly onFalse: STM<A2, E2, R2> }
1108
- ): STM<A | A2, E1 | E2 | E, R1 | R2 | R>
1109
- <E, R, A, E1, R1, A2, E2, R2>(
1110
- self: STM<boolean, E, R>,
1111
- options: { readonly onTrue: STM<A, E1, R1>; readonly onFalse: STM<A2, E2, R2> }
1112
- ): STM<A | A2, E | E1 | E2, R | R1 | R2>
1113
- } = stm.if_
1114
-
1115
- export {
1116
- /**
1117
- * Runs `onTrue` if the result of `b` is `true` and `onFalse` otherwise.
1118
- *
1119
- * @since 2.0.0
1120
- * @category mutations
1121
- */
1122
- if_ as if
1123
- }
1124
-
1125
- /**
1126
- * Returns a new effect that ignores the success or failure of this effect.
1127
- *
1128
- * @since 2.0.0
1129
- * @category mutations
1130
- */
1131
- export const ignore: <A, E, R>(self: STM<A, E, R>) => STM<void, never, R> = stm.ignore
1132
-
1133
- /**
1134
- * Interrupts the fiber running the effect.
1135
- *
1136
- * @since 2.0.0
1137
- * @category constructors
1138
- */
1139
- export const interrupt: STM<never> = core.interrupt
1140
-
1141
- /**
1142
- * Interrupts the fiber running the effect with the specified `FiberId`.
1143
- *
1144
- * @since 2.0.0
1145
- * @category constructors
1146
- */
1147
- export const interruptAs: (fiberId: FiberId.FiberId) => STM<never> = core.interruptAs
1148
-
1149
- /**
1150
- * Returns whether this transactional effect is a failure.
1151
- *
1152
- * @since 2.0.0
1153
- * @category getters
1154
- */
1155
- export const isFailure: <A, E, R>(self: STM<A, E, R>) => STM<boolean, never, R> = stm.isFailure
1156
-
1157
- /**
1158
- * Returns whether this transactional effect is a success.
1159
- *
1160
- * @since 2.0.0
1161
- * @category getters
1162
- */
1163
- export const isSuccess: <A, E, R>(self: STM<A, E, R>) => STM<boolean, never, R> = stm.isSuccess
1164
-
1165
- /**
1166
- * Iterates with the specified transactional function. The moral equivalent
1167
- * of:
1168
- *
1169
- * ```ts skip-type-checking
1170
- * const s = initial
1171
- *
1172
- * while (cont(s)) {
1173
- * s = body(s)
1174
- * }
1175
- *
1176
- * return s
1177
- * ```
1178
- *
1179
- * @since 2.0.0
1180
- * @category constructors
1181
- */
1182
- export const iterate: <Z, E, R>(
1183
- initial: Z,
1184
- options: {
1185
- readonly while: Predicate<Z>
1186
- readonly body: (z: Z) => STM<Z, E, R>
1187
- }
1188
- ) => STM<Z, E, R> = stm.iterate
1189
-
1190
- /**
1191
- * Loops with the specified transactional function, collecting the results
1192
- * into a list. The moral equivalent of:
1193
- *
1194
- * ```ts skip-type-checking
1195
- * const as = []
1196
- * let s = initial
1197
- *
1198
- * while (cont(s)) {
1199
- * as.push(body(s))
1200
- * s = inc(s)
1201
- * }
1202
- *
1203
- * return as
1204
- * ```
1205
- *
1206
- * @since 2.0.0
1207
- * @category constructors
1208
- */
1209
- export const loop: {
1210
- <Z, A, E, R>(
1211
- initial: Z,
1212
- options: {
1213
- readonly while: (z: Z) => boolean
1214
- readonly step: (z: Z) => Z
1215
- readonly body: (z: Z) => STM<A, E, R>
1216
- readonly discard?: false | undefined
1217
- }
1218
- ): STM<Array<A>, E, R>
1219
- <Z, A, E, R>(
1220
- initial: Z,
1221
- options: {
1222
- readonly while: (z: Z) => boolean
1223
- readonly step: (z: Z) => Z
1224
- readonly body: (z: Z) => STM<A, E, R>
1225
- readonly discard: true
1226
- }
1227
- ): STM<void, E, R>
1228
- } = stm.loop
1229
-
1230
- /**
1231
- * Maps the value produced by the effect.
1232
- *
1233
- * @since 2.0.0
1234
- * @category mapping
1235
- */
1236
- export const map: {
1237
- <A, B>(f: (a: A) => B): <E, R>(self: STM<A, E, R>) => STM<B, E, R>
1238
- <A, E, R, B>(self: STM<A, E, R>, f: (a: A) => B): STM<B, E, R>
1239
- } = core.map
1240
-
1241
- /**
1242
- * Maps the value produced by the effect with the specified function that may
1243
- * throw exceptions but is otherwise pure, translating any thrown exceptions
1244
- * into typed failed effects.
1245
- *
1246
- * @since 2.0.0
1247
- * @category mapping
1248
- */
1249
- export const mapAttempt: {
1250
- <A, B>(f: (a: A) => B): <E, R>(self: STM<A, E, R>) => STM<B, unknown, R>
1251
- <A, E, R, B>(self: STM<A, E, R>, f: (a: A) => B): STM<B, unknown, R>
1252
- } = stm.mapAttempt
1253
-
1254
- /**
1255
- * Returns an `STM` effect whose failure and success channels have been mapped
1256
- * by the specified pair of functions, `f` and `g`.
1257
- *
1258
- * @since 2.0.0
1259
- * @category mapping
1260
- */
1261
- export const mapBoth: {
1262
- <E, E2, A, A2>(
1263
- options: { readonly onFailure: (error: E) => E2; readonly onSuccess: (value: A) => A2 }
1264
- ): <R>(self: STM<A, E, R>) => STM<A2, E2, R>
1265
- <A, E, R, E2, A2>(
1266
- self: STM<A, E, R>,
1267
- options: { readonly onFailure: (error: E) => E2; readonly onSuccess: (value: A) => A2 }
1268
- ): STM<A2, E2, R>
1269
- } = stm.mapBoth
1270
-
1271
- /**
1272
- * Maps from one error type to another.
1273
- *
1274
- * @since 2.0.0
1275
- * @category mapping
1276
- */
1277
- export const mapError: {
1278
- <E, E2>(f: (error: E) => E2): <A, R>(self: STM<A, E, R>) => STM<A, E2, R>
1279
- <A, E, R, E2>(self: STM<A, E, R>, f: (error: E) => E2): STM<A, E2, R>
1280
- } = stm.mapError
1281
-
1282
- /**
1283
- * Returns a new effect where the error channel has been merged into the
1284
- * success channel to their common combined type.
1285
- *
1286
- * @since 2.0.0
1287
- * @category mutations
1288
- */
1289
- export const merge: <A, E, R>(self: STM<A, E, R>) => STM<E | A, never, R> = stm.merge
1290
-
1291
- /**
1292
- * Merges an `Iterable<STM>` to a single `STM`, working sequentially.
1293
- *
1294
- * @since 2.0.0
1295
- * @category constructors
1296
- */
1297
- export const mergeAll: {
1298
- <A2, A>(zero: A2, f: (a2: A2, a: A) => A2): <E, R>(iterable: Iterable<STM<A, E, R>>) => STM<A2, E, R>
1299
- <A, E, R, A2>(iterable: Iterable<STM<A, E, R>>, zero: A2, f: (a2: A2, a: A) => A2): STM<A2, E, R>
1300
- } = stm.mergeAll
1301
-
1302
- /**
1303
- * Returns a new effect where boolean value of this effect is negated.
1304
- *
1305
- * @since 2.0.0
1306
- * @category mutations
1307
- */
1308
- export const negate: <E, R>(self: STM<boolean, E, R>) => STM<boolean, E, R> = stm.negate
1309
-
1310
- /**
1311
- * Requires the option produced by this value to be `None`.
1312
- *
1313
- * @since 2.0.0
1314
- * @category mutations
1315
- */
1316
- export const none: <A, E, R>(self: STM<Option.Option<A>, E, R>) => STM<void, Option.Option<E>, R> = stm.none
1317
-
1318
- /**
1319
- * Converts the failure channel into an `Option`.
1320
- *
1321
- * @since 2.0.0
1322
- * @category mutations
1323
- */
1324
- export const option: <A, E, R>(self: STM<A, E, R>) => STM<Option.Option<A>, never, R> = stm.option
1325
-
1326
- /**
1327
- * Translates `STM` effect failure into death of the fiber, making all
1328
- * failures unchecked and not a part of the type of the effect.
1329
- *
1330
- * @since 2.0.0
1331
- * @category error handling
1332
- */
1333
- export const orDie: <A, E, R>(self: STM<A, E, R>) => STM<A, never, R> = stm.orDie
1334
-
1335
- /**
1336
- * Keeps none of the errors, and terminates the fiber running the `STM` effect
1337
- * with them, using the specified function to convert the `E` into a defect.
1338
- *
1339
- * @since 2.0.0
1340
- * @category error handling
1341
- */
1342
- export const orDieWith: {
1343
- <E>(f: (error: E) => unknown): <A, R>(self: STM<A, E, R>) => STM<A, never, R>
1344
- <A, E, R>(self: STM<A, E, R>, f: (error: E) => unknown): STM<A, never, R>
1345
- } = stm.orDieWith
1346
-
1347
- /**
1348
- * Tries this effect first, and if it fails or retries, tries the other
1349
- * effect.
1350
- *
1351
- * @since 2.0.0
1352
- * @category error handling
1353
- */
1354
- export const orElse: {
1355
- <A2, E2, R2>(that: LazyArg<STM<A2, E2, R2>>): <A, E, R>(self: STM<A, E, R>) => STM<A2 | A, E2, R2 | R>
1356
- <A, E, R, A2, E2, R2>(self: STM<A, E, R>, that: LazyArg<STM<A2, E2, R2>>): STM<A | A2, E2, R | R2>
1357
- } = stm.orElse
1358
-
1359
- /**
1360
- * Returns a transactional effect that will produce the value of this effect
1361
- * in left side, unless it fails or retries, in which case, it will produce
1362
- * the value of the specified effect in right side.
1363
- *
1364
- * @since 2.0.0
1365
- * @category error handling
1366
- */
1367
- export const orElseEither: {
1368
- <A2, E2, R2>(that: LazyArg<STM<A2, E2, R2>>): <A, E, R>(self: STM<A, E, R>) => STM<Either.Either<A2, A>, E2, R2 | R>
1369
- <A, E, R, A2, E2, R2>(self: STM<A, E, R>, that: LazyArg<STM<A2, E2, R2>>): STM<Either.Either<A2, A>, E2, R | R2>
1370
- } = stm.orElseEither
1371
-
1372
- /**
1373
- * Tries this effect first, and if it fails or retries, fails with the
1374
- * specified error.
1375
- *
1376
- * @since 2.0.0
1377
- * @category error handling
1378
- */
1379
- export const orElseFail: {
1380
- <E2>(error: LazyArg<E2>): <A, E, R>(self: STM<A, E, R>) => STM<A, E2, R>
1381
- <A, E, R, E2>(self: STM<A, E, R>, error: LazyArg<E2>): STM<A, E2, R>
1382
- } = stm.orElseFail
1383
-
1384
- /**
1385
- * Returns an effect that will produce the value of this effect, unless it
1386
- * fails with the `None` value, in which case it will produce the value of the
1387
- * specified effect.
1388
- *
1389
- * @since 2.0.0
1390
- * @category error handling
1391
- */
1392
- export const orElseOptional: {
1393
- <A2, E2, R2>(
1394
- that: LazyArg<STM<A2, Option.Option<E2>, R2>>
1395
- ): <A, E, R>(self: STM<A, Option.Option<E>, R>) => STM<A2 | A, Option.Option<E2 | E>, R2 | R>
1396
- <A, E, R, A2, E2, R2>(
1397
- self: STM<A, Option.Option<E>, R>,
1398
- that: LazyArg<STM<A2, Option.Option<E2>, R2>>
1399
- ): STM<A | A2, Option.Option<E | E2>, R | R2>
1400
- } = stm.orElseOptional
1401
-
1402
- /**
1403
- * Tries this effect first, and if it fails or retries, succeeds with the
1404
- * specified value.
1405
- *
1406
- * @since 2.0.0
1407
- * @category error handling
1408
- */
1409
- export const orElseSucceed: {
1410
- <A2>(value: LazyArg<A2>): <A, E, R>(self: STM<A, E, R>) => STM<A2 | A, never, R>
1411
- <A, E, R, A2>(self: STM<A, E, R>, value: LazyArg<A2>): STM<A | A2, never, R>
1412
- } = stm.orElseSucceed
1413
-
1414
- /**
1415
- * Tries this effect first, and if it enters retry, then it tries the other
1416
- * effect. This is an equivalent of Haskell's orElse.
1417
- *
1418
- * @since 2.0.0
1419
- * @category error handling
1420
- */
1421
- export const orTry: {
1422
- <A1, E1, R1>(that: LazyArg<STM<A1, E1, R1>>): <A, E, R>(self: STM<A, E, R>) => STM<A1 | A, E1 | E, R1 | R>
1423
- <A, E, R, A1, E1, R1>(self: STM<A, E, R>, that: LazyArg<STM<A1, E1, R1>>): STM<A | A1, E | E1, R | R1>
1424
- } = core.orTry
1425
-
1426
- /**
1427
- * Feeds elements of type `A` to a function `f` that returns an effect.
1428
- * Collects all successes and failures in a tupled fashion.
1429
- *
1430
- * @since 2.0.0
1431
- * @category traversing
1432
- */
1433
- export const partition: {
1434
- <A, A2, E, R>(
1435
- f: (a: A) => STM<A2, E, R>
1436
- ): (elements: Iterable<A>) => STM<[excluded: Array<E>, satisfying: Array<A2>], never, R>
1437
- <A, A2, E, R>(
1438
- elements: Iterable<A>,
1439
- f: (a: A) => STM<A2, E, R>
1440
- ): STM<[excluded: Array<E>, satisfying: Array<A2>], never, R>
1441
- } = stm.partition
1442
-
1443
- /**
1444
- * Provides the transaction its required environment, which eliminates its
1445
- * dependency on `R`.
1446
- *
1447
- * @since 2.0.0
1448
- * @category context
1449
- */
1450
- export const provideContext: {
1451
- <R>(env: Context.Context<R>): <A, E>(self: STM<A, E, R>) => STM<A, E>
1452
- <A, E, R>(self: STM<A, E, R>, env: Context.Context<R>): STM<A, E>
1453
- } = stm.provideContext
1454
-
1455
- /**
1456
- * Splits the context into two parts, providing one part using the
1457
- * specified layer and leaving the remainder `R0`.
1458
- *
1459
- * @since 2.0.0
1460
- * @category context
1461
- */
1462
- export const provideSomeContext: {
1463
- <R>(context: Context.Context<R>): <R1, E, A>(self: STM<A, E, R1>) => STM<A, E, Exclude<R1, R>>
1464
- <R, R1, E, A>(self: STM<A, E, R1>, context: Context.Context<R>): STM<A, E, Exclude<R1, R>>
1465
- } = stm.provideSomeContext
1466
-
1467
- /**
1468
- * Provides the effect with the single service it requires. If the transactional
1469
- * effect requires more than one service use `provideEnvironment` instead.
1470
- *
1471
- * @since 2.0.0
1472
- * @category context
1473
- */
1474
- export const provideService: {
1475
- <I, S>(tag: Context.Tag<I, S>, resource: NoInfer<S>): <A, E, R>(self: STM<A, E, R>) => STM<A, E, Exclude<R, I>>
1476
- <A, E, R, I, S>(self: STM<A, E, R>, tag: Context.Tag<I, S>, resource: NoInfer<S>): STM<A, E, Exclude<R, I>>
1477
- } = stm.provideService
1478
-
1479
- /**
1480
- * Provides the effect with the single service it requires. If the transactional
1481
- * effect requires more than one service use `provideEnvironment` instead.
1482
- *
1483
- * @since 2.0.0
1484
- * @category context
1485
- */
1486
- export const provideServiceSTM: {
1487
- <I, S, E1, R1>(
1488
- tag: Context.Tag<I, S>,
1489
- stm: STM<NoInfer<S>, E1, R1>
1490
- ): <A, E, R>(self: STM<A, E, R>) => STM<A, E1 | E, R1 | Exclude<R, I>>
1491
- <A, E, R, I, S, E1, R1>(
1492
- self: STM<A, E, R>,
1493
- tag: Context.Tag<I, S>,
1494
- stm: STM<NoInfer<S>, E1, R1>
1495
- ): STM<A, E1 | E, R1 | Exclude<R, I>>
1496
- } = stm.provideServiceSTM
1497
-
1498
- /**
1499
- * Folds an `Iterable<A>` using an effectual function f, working sequentially
1500
- * from left to right.
1501
- *
1502
- * @since 2.0.0
1503
- * @category constructors
1504
- */
1505
- export const reduce: {
1506
- <S, A, E, R>(zero: S, f: (s: S, a: A) => STM<S, E, R>): (iterable: Iterable<A>) => STM<S, E, R>
1507
- <S, A, E, R>(iterable: Iterable<A>, zero: S, f: (s: S, a: A) => STM<S, E, R>): STM<S, E, R>
1508
- } = stm.reduce
1509
-
1510
- /**
1511
- * Reduces an `Iterable<STM>` to a single `STM`, working sequentially.
1512
- *
1513
- * @since 2.0.0
1514
- * @category constructors
1515
- */
1516
- export const reduceAll: {
1517
- <A, E2, R2>(
1518
- initial: STM<A, E2, R2>,
1519
- f: (x: A, y: A) => A
1520
- ): <E, R>(iterable: Iterable<STM<A, E, R>>) => STM<A, E2 | E, R2 | R>
1521
- <A, E, R, E2, R2>(
1522
- iterable: Iterable<STM<A, E, R>>,
1523
- initial: STM<A, E2, R2>,
1524
- f: (x: A, y: A) => A
1525
- ): STM<A, E | E2, R | R2>
1526
- } = stm.reduceAll
1527
-
1528
- /**
1529
- * Folds an `Iterable<A>` using an effectual function f, working sequentially
1530
- * from right to left.
1531
- *
1532
- * @since 2.0.0
1533
- * @category constructors
1534
- */
1535
- export const reduceRight: {
1536
- <S, A, R, E>(zero: S, f: (s: S, a: A) => STM<S, E, R>): (iterable: Iterable<A>) => STM<S, E, R>
1537
- <S, A, R, E>(iterable: Iterable<A>, zero: S, f: (s: S, a: A) => STM<S, E, R>): STM<S, E, R>
1538
- } = stm.reduceRight
1539
-
1540
- /**
1541
- * Keeps some of the errors, and terminates the fiber with the rest.
1542
- *
1543
- * @since 2.0.0
1544
- * @category mutations
1545
- */
1546
- export const refineOrDie: {
1547
- <E, E2>(pf: (error: E) => Option.Option<E2>): <A, R>(self: STM<A, E, R>) => STM<A, E2, R>
1548
- <A, E, R, E2>(self: STM<A, E, R>, pf: (error: E) => Option.Option<E2>): STM<A, E2, R>
1549
- } = stm.refineOrDie
1550
-
1551
- /**
1552
- * Keeps some of the errors, and terminates the fiber with the rest, using the
1553
- * specified function to convert the `E` into a `Throwable`.
1554
- *
1555
- * @since 2.0.0
1556
- * @category mutations
1557
- */
1558
- export const refineOrDieWith: {
1559
- <E, E2>(pf: (error: E) => Option.Option<E2>, f: (error: E) => unknown): <A, R>(self: STM<A, E, R>) => STM<A, E2, R>
1560
- <A, E, R, E2>(self: STM<A, E, R>, pf: (error: E) => Option.Option<E2>, f: (error: E) => unknown): STM<A, E2, R>
1561
- } = stm.refineOrDieWith
1562
-
1563
- /**
1564
- * Fail with the returned value if the `PartialFunction` matches, otherwise
1565
- * continue with our held value.
1566
- *
1567
- * @since 2.0.0
1568
- * @category mutations
1569
- */
1570
- export const reject: {
1571
- <A, E2>(pf: (a: A) => Option.Option<E2>): <E, R>(self: STM<A, E, R>) => STM<A, E2 | E, R>
1572
- <A, E, R, E2>(self: STM<A, E, R>, pf: (a: A) => Option.Option<E2>): STM<A, E | E2, R>
1573
- } = stm.reject
1574
-
1575
- /**
1576
- * Continue with the returned computation if the specified partial function
1577
- * matches, translating the successful match into a failure, otherwise continue
1578
- * with our held value.
1579
- *
1580
- * @since 2.0.0
1581
- * @category mutations
1582
- */
1583
- export const rejectSTM: {
1584
- <A, E2, R2>(pf: (a: A) => Option.Option<STM<E2, E2, R2>>): <E, R>(self: STM<A, E, R>) => STM<A, E2 | E, R2 | R>
1585
- <A, E, R, E2, R2>(self: STM<A, E, R>, pf: (a: A) => Option.Option<STM<E2, E2, R2>>): STM<A, E | E2, R | R2>
1586
- } = stm.rejectSTM
1587
-
1588
- /**
1589
- * Repeats this `STM` effect until its result satisfies the specified
1590
- * predicate.
1591
- *
1592
- * **WARNING**: `repeatUntil` uses a busy loop to repeat the effect and will
1593
- * consume a thread until it completes (it cannot yield). This is because STM
1594
- * describes a single atomic transaction which must either complete, retry or
1595
- * fail a transaction before yielding back to the Effect runtime.
1596
- * - Use `retryUntil` instead if you don't need to maintain transaction
1597
- * state for repeats.
1598
- * - Ensure repeating the STM effect will eventually satisfy the predicate.
1599
- *
1600
- * @since 2.0.0
1601
- * @category mutations
1602
- */
1603
- export const repeatUntil: {
1604
- <A>(predicate: Predicate<A>): <E, R>(self: STM<A, E, R>) => STM<A, E, R>
1605
- <A, E, R>(self: STM<A, E, R>, predicate: Predicate<A>): STM<A, E, R>
1606
- } = stm.repeatUntil
1607
-
1608
- /**
1609
- * Repeats this `STM` effect while its result satisfies the specified
1610
- * predicate.
1611
- *
1612
- * **WARNING**: `repeatWhile` uses a busy loop to repeat the effect and will
1613
- * consume a thread until it completes (it cannot yield). This is because STM
1614
- * describes a single atomic transaction which must either complete, retry or
1615
- * fail a transaction before yielding back to the Effect runtime.
1616
- * - Use `retryWhile` instead if you don't need to maintain transaction
1617
- * state for repeats.
1618
- * - Ensure repeating the STM effect will eventually not satisfy the
1619
- * predicate.
1620
- *
1621
- * @since 2.0.0
1622
- * @category mutations
1623
- */
1624
- export const repeatWhile: {
1625
- <A>(predicate: Predicate<A>): <E, R>(self: STM<A, E, R>) => STM<A, E, R>
1626
- <A, E, R>(self: STM<A, E, R>, predicate: Predicate<A>): STM<A, E, R>
1627
- } = stm.repeatWhile
1628
-
1629
- /**
1630
- * Replicates the given effect n times. If 0 or negative numbers are given, an
1631
- * empty `Chunk` will be returned.
1632
- *
1633
- * @since 2.0.0
1634
- * @category constructors
1635
- */
1636
- export const replicate: {
1637
- (n: number): <A, E, R>(self: STM<A, E, R>) => Array<STM<A, E, R>>
1638
- <A, E, R>(self: STM<A, E, R>, n: number): Array<STM<A, E, R>>
1639
- } = stm.replicate
1640
-
1641
- /**
1642
- * Performs this transaction the specified number of times and collects the
1643
- * results.
1644
- *
1645
- * @since 2.0.0
1646
- * @category constructors
1647
- */
1648
- export const replicateSTM: {
1649
- (n: number): <A, E, R>(self: STM<A, E, R>) => STM<Array<A>, E, R>
1650
- <A, E, R>(self: STM<A, E, R>, n: number): STM<Array<A>, E, R>
1651
- } = stm.replicateSTM
1652
-
1653
- /**
1654
- * Performs this transaction the specified number of times, discarding the
1655
- * results.
1656
- *
1657
- * @since 2.0.0
1658
- * @category constructors
1659
- */
1660
- export const replicateSTMDiscard: {
1661
- (n: number): <A, E, R>(self: STM<A, E, R>) => STM<void, E, R>
1662
- <A, E, R>(self: STM<A, E, R>, n: number): STM<void, E, R>
1663
- } = stm.replicateSTMDiscard
1664
-
1665
- /**
1666
- * Abort and retry the whole transaction when any of the underlying
1667
- * transactional variables have changed.
1668
- *
1669
- * @since 2.0.0
1670
- * @category error handling
1671
- */
1672
- export const retry: STM<never> = core.retry
1673
-
1674
- /**
1675
- * Filters the value produced by this effect, retrying the transaction until
1676
- * the predicate returns `true` for the value.
1677
- *
1678
- * @since 2.0.0
1679
- * @category mutations
1680
- */
1681
- export const retryUntil: {
1682
- <A, B extends A>(refinement: Refinement<NoInfer<A>, B>): <E, R>(self: STM<A, E, R>) => STM<B, E, R>
1683
- <A>(predicate: Predicate<A>): <E, R>(self: STM<A, E, R>) => STM<A, E, R>
1684
- <A, E, R, B extends A>(self: STM<A, E, R>, refinement: Refinement<A, B>): STM<B, E, R>
1685
- <A, E, R>(self: STM<A, E, R>, predicate: Predicate<A>): STM<A, E, R>
1686
- } = stm.retryUntil
1687
-
1688
- /**
1689
- * Filters the value produced by this effect, retrying the transaction while
1690
- * the predicate returns `true` for the value.
1691
- *
1692
- * @since 2.0.0
1693
- * @category mutations
1694
- */
1695
- export const retryWhile: {
1696
- <A>(predicate: Predicate<A>): <E, R>(self: STM<A, E, R>) => STM<A, E, R>
1697
- <A, E, R>(self: STM<A, E, R>, predicate: Predicate<A>): STM<A, E, R>
1698
- } = stm.retryWhile
1699
-
1700
- /**
1701
- * Converts an option on values into an option on errors.
1702
- *
1703
- * @since 2.0.0
1704
- * @category getters
1705
- */
1706
- export const some: <A, E, R>(self: STM<Option.Option<A>, E, R>) => STM<A, Option.Option<E>, R> = stm.some
1707
-
1708
- /**
1709
- * Returns an `STM` effect that succeeds with the specified value.
1710
- *
1711
- * @since 2.0.0
1712
- * @category constructors
1713
- */
1714
- export const succeed: <A>(value: A) => STM<A> = core.succeed
1715
-
1716
- /**
1717
- * Returns an effect with the empty value.
1718
- *
1719
- * @since 2.0.0
1720
- * @category constructors
1721
- */
1722
- export const succeedNone: STM<Option.Option<never>> = stm.succeedNone
1723
-
1724
- /**
1725
- * Returns an effect with the optional value.
1726
- *
1727
- * @since 2.0.0
1728
- * @category constructors
1729
- */
1730
- export const succeedSome: <A>(value: A) => STM<Option.Option<A>> = stm.succeedSome
1731
-
1732
- /**
1733
- * Summarizes a `STM` effect by computing a provided value before and after
1734
- * execution, and then combining the values to produce a summary, together
1735
- * with the result of execution.
1736
- *
1737
- * @since 2.0.0
1738
- * @category mutations
1739
- */
1740
- export const summarized: {
1741
- <A2, E2, R2, A3>(
1742
- summary: STM<A2, E2, R2>,
1743
- f: (before: A2, after: A2) => A3
1744
- ): <A, E, R>(self: STM<A, E, R>) => STM<[A3, A], E2 | E, R2 | R>
1745
- <A, E, R, A2, E2, R2, A3>(
1746
- self: STM<A, E, R>,
1747
- summary: STM<A2, E2, R2>,
1748
- f: (before: A2, after: A2) => A3
1749
- ): STM<[A3, A], E | E2, R | R2>
1750
- } = stm.summarized
1751
-
1752
- /**
1753
- * Suspends creation of the specified transaction lazily.
1754
- *
1755
- * @since 2.0.0
1756
- * @category constructors
1757
- */
1758
- export const suspend: <A, E, R>(evaluate: LazyArg<STM<A, E, R>>) => STM<A, E, R> = stm.suspend
1759
-
1760
- /**
1761
- * Returns an `STM` effect that succeeds with the specified lazily evaluated
1762
- * value.
1763
- *
1764
- * @since 2.0.0
1765
- * @category constructors
1766
- */
1767
- export const sync: <A>(evaluate: () => A) => STM<A> = core.sync
1768
-
1769
- /**
1770
- * "Peeks" at the success of transactional effect.
1771
- *
1772
- * @since 2.0.0
1773
- * @category sequencing
1774
- */
1775
- export const tap: {
1776
- <A, X, E2, R2>(f: (a: A) => STM<X, E2, R2>): <E, R>(self: STM<A, E, R>) => STM<A, E2 | E, R2 | R>
1777
- <A, E, R, X, E2, R2>(self: STM<A, E, R>, f: (a: A) => STM<X, E2, R2>): STM<A, E | E2, R | R2>
1778
- } = stm.tap
1779
-
1780
- /**
1781
- * "Peeks" at both sides of an transactional effect.
1782
- *
1783
- * @since 2.0.0
1784
- * @category sequencing
1785
- */
1786
- export const tapBoth: {
1787
- <XE extends E, A2, E2, R2, XA extends A, A3, E3, R3, A, E>(
1788
- options: { readonly onFailure: (error: XE) => STM<A2, E2, R2>; readonly onSuccess: (value: XA) => STM<A3, E3, R3> }
1789
- ): <R>(self: STM<A, E, R>) => STM<A, E | E2 | E3, R2 | R3 | R>
1790
- <A, E, R, XE extends E, A2, E2, R2, XA extends A, A3, E3, R3>(
1791
- self: STM<A, E, R>,
1792
- options: { readonly onFailure: (error: XE) => STM<A2, E2, R2>; readonly onSuccess: (value: XA) => STM<A3, E3, R3> }
1793
- ): STM<A, E | E2 | E3, R | R2 | R3>
1794
- } = stm.tapBoth
1795
-
1796
- /**
1797
- * "Peeks" at the error of the transactional effect.
1798
- *
1799
- * @since 2.0.0
1800
- * @category sequencing
1801
- */
1802
- export const tapError: {
1803
- <E, X, E2, R2>(f: (error: NoInfer<E>) => STM<X, E2, R2>): <A, R>(self: STM<A, E, R>) => STM<A, E | E2, R2 | R>
1804
- <A, E, R, X, E2, R2>(self: STM<A, E, R>, f: (error: E) => STM<X, E2, R2>): STM<A, E | E2, R | R2>
1805
- } = stm.tapError
1806
-
1807
- const try_: {
1808
- <A, E>(options: {
1809
- readonly try: LazyArg<A>
1810
- readonly catch: (u: unknown) => E
1811
- }): STM<A, E>
1812
- <A>(try_: LazyArg<A>): STM<A, unknown>
1813
- } = stm.try_
1814
-
1815
- export {
1816
- /**
1817
- * Imports a synchronous side-effect into a pure value, translating any thrown
1818
- * exceptions into typed failed effects.
1819
- *
1820
- * @since 2.0.0
1821
- * @category constructors
1822
- */
1823
- try_ as try
1824
- }
1825
-
1826
- /**
1827
- * The moral equivalent of `if (!p) exp`
1828
- *
1829
- * @since 2.0.0
1830
- * @category mutations
1831
- */
1832
- export const unless: {
1833
- (predicate: LazyArg<boolean>): <A, E, R>(self: STM<A, E, R>) => STM<Option.Option<A>, E, R>
1834
- <A, E, R>(self: STM<A, E, R>, predicate: LazyArg<boolean>): STM<Option.Option<A>, E, R>
1835
- } = stm.unless
1836
-
1837
- /**
1838
- * The moral equivalent of `if (!p) exp` when `p` has side-effects
1839
- *
1840
- * @since 2.0.0
1841
- * @category mutations
1842
- */
1843
- export const unlessSTM: {
1844
- <E2, R2>(predicate: STM<boolean, E2, R2>): <A, E, R>(self: STM<A, E, R>) => STM<Option.Option<A>, E2 | E, R2 | R>
1845
- <A, E, R, E2, R2>(self: STM<A, E, R>, predicate: STM<boolean, E2, R2>): STM<Option.Option<A>, E | E2, R | R2>
1846
- } = stm.unlessSTM
1847
-
1848
- /**
1849
- * Converts an option on errors into an option on values.
1850
- *
1851
- * @since 2.0.0
1852
- * @category getters
1853
- */
1854
- export const unsome: <A, E, R>(self: STM<A, Option.Option<E>, R>) => STM<Option.Option<A>, E, R> = stm.unsome
1855
-
1856
- const void_: STM<void> = stm.void
1857
- export {
1858
- /**
1859
- * Returns an `STM` effect that succeeds with `void`.
1860
- *
1861
- * @since 2.0.0
1862
- * @category constructors
1863
- */
1864
- void_ as void
1865
- }
1866
-
1867
- /**
1868
- * Feeds elements of type `A` to `f` and accumulates all errors in error
1869
- * channel or successes in success channel.
1870
- *
1871
- * This combinator is lossy meaning that if there are errors all successes
1872
- * will be lost. To retain all information please use `STM.partition`.
1873
- *
1874
- * @since 2.0.0
1875
- * @category mutations
1876
- */
1877
- export const validateAll: {
1878
- <A, B, E, R>(f: (a: A) => STM<B, E, R>): (elements: Iterable<A>) => STM<Array<B>, [E, ...Array<E>], R>
1879
- <A, B, E, R>(elements: Iterable<A>, f: (a: A) => STM<B, E, R>): STM<Array<B>, [E, ...Array<E>], R>
1880
- } = stm.validateAll
1881
-
1882
- /**
1883
- * Feeds elements of type `A` to `f` until it succeeds. Returns first success
1884
- * or the accumulation of all errors.
1885
- *
1886
- * @since 2.0.0
1887
- * @category mutations
1888
- */
1889
- export const validateFirst: {
1890
- <A, B, E, R>(f: (a: A) => STM<B, E, R>): (elements: Iterable<A>) => STM<B, Array<E>, R>
1891
- <A, B, E, R>(elements: Iterable<A>, f: (a: A) => STM<B, E, R>): STM<B, Array<E>, R>
1892
- } = stm.validateFirst
1893
-
1894
- /**
1895
- * The moral equivalent of `if (p) exp`.
1896
- *
1897
- * @since 2.0.0
1898
- * @category mutations
1899
- */
1900
- export const when: {
1901
- (predicate: LazyArg<boolean>): <A, E, R>(self: STM<A, E, R>) => STM<Option.Option<A>, E, R>
1902
- <A, E, R>(self: STM<A, E, R>, predicate: LazyArg<boolean>): STM<Option.Option<A>, E, R>
1903
- } = stm.when
1904
-
1905
- /**
1906
- * The moral equivalent of `if (p) exp` when `p` has side-effects.
1907
- *
1908
- * @since 2.0.0
1909
- * @category mutations
1910
- */
1911
- export const whenSTM: {
1912
- <E2, R2>(predicate: STM<boolean, E2, R2>): <A, E, R>(self: STM<A, E, R>) => STM<Option.Option<A>, E2 | E, R2 | R>
1913
- <A, E, R, E2, R2>(self: STM<A, E, R>, predicate: STM<boolean, E2, R2>): STM<Option.Option<A>, E | E2, R | R2>
1914
- } = stm.whenSTM
1915
-
1916
- /**
1917
- * Sequentially zips this value with the specified one.
1918
- *
1919
- * @since 2.0.0
1920
- * @category zipping
1921
- */
1922
- export const zip: {
1923
- <A1, E1, R1>(that: STM<A1, E1, R1>): <A, E, R>(self: STM<A, E, R>) => STM<[A, A1], E1 | E, R1 | R>
1924
- <A, E, R, A1, E1, R1>(self: STM<A, E, R>, that: STM<A1, E1, R1>): STM<[A, A1], E | E1, R | R1>
1925
- } = core.zip
1926
-
1927
- /**
1928
- * Sequentially zips this value with the specified one, discarding the second
1929
- * element of the tuple.
1930
- *
1931
- * @since 2.0.0
1932
- * @category zipping
1933
- */
1934
- export const zipLeft: {
1935
- <A1, E1, R1>(that: STM<A1, E1, R1>): <A, E, R>(self: STM<A, E, R>) => STM<A, E1 | E, R1 | R>
1936
- <A, E, R, A1, E1, R1>(self: STM<A, E, R>, that: STM<A1, E1, R1>): STM<A, E | E1, R | R1>
1937
- } = core.zipLeft
1938
-
1939
- /**
1940
- * Sequentially zips this value with the specified one, discarding the first
1941
- * element of the tuple.
1942
- *
1943
- * @since 2.0.0
1944
- * @category zipping
1945
- */
1946
- export const zipRight: {
1947
- <A1, E1, R1>(that: STM<A1, E1, R1>): <A, E, R>(self: STM<A, E, R>) => STM<A1, E1 | E, R1 | R>
1948
- <A, E, R, A1, E1, R1>(self: STM<A, E, R>, that: STM<A1, E1, R1>): STM<A1, E | E1, R | R1>
1949
- } = core.zipRight
1950
-
1951
- /**
1952
- * Sequentially zips this value with the specified one, combining the values
1953
- * using the specified combiner function.
1954
- *
1955
- * @since 2.0.0
1956
- * @category zipping
1957
- */
1958
- export const zipWith: {
1959
- <A1, E1, R1, A, A2>(
1960
- that: STM<A1, E1, R1>,
1961
- f: (a: A, b: A1) => A2
1962
- ): <E, R>(self: STM<A, E, R>) => STM<A2, E1 | E, R1 | R>
1963
- <A, E, R, A1, E1, R1, A2>(self: STM<A, E, R>, that: STM<A1, E1, R1>, f: (a: A, b: A1) => A2): STM<A2, E | E1, R | R1>
1964
- } = core.zipWith
1965
-
1966
- /**
1967
- * This function takes an iterable of `STM` values and returns a new
1968
- * `STM` value that represents the first `STM` value in the iterable
1969
- * that succeeds. If all of the `Effect` values in the iterable fail, then
1970
- * the resulting `STM` value will fail as well.
1971
- *
1972
- * This function is sequential, meaning that the `STM` values in the
1973
- * iterable will be executed in sequence, and the first one that succeeds
1974
- * will determine the outcome of the resulting `STM` value.
1975
- *
1976
- * Returns a new `STM` value that represents the first successful
1977
- * `STM` value in the iterable, or a failed `STM` value if all of the
1978
- * `STM` values in the iterable fail.
1979
- *
1980
- * @since 2.0.0
1981
- * @category elements
1982
- */
1983
- export const firstSuccessOf = <A, E, R>(effects: Iterable<STM<A, E, R>>): STM<A, E, R> =>
1984
- suspend<A, E, R>(() => {
1985
- const list = Chunk.fromIterable(effects)
1986
- if (!Chunk.isNonEmpty(list)) {
1987
- return dieSync(() => new Cause.IllegalArgumentException(`Received an empty collection of effects`))
1988
- }
1989
- return Chunk.reduce(
1990
- Chunk.tailNonEmpty(list),
1991
- Chunk.headNonEmpty(list),
1992
- (left, right) => orElse(left, () => right)
1993
- )
1994
- })
1995
-
1996
- /**
1997
- * @category do notation
1998
- * @since 2.0.0
1999
- */
2000
- export const Do: STM<{}> = succeed({})
2001
-
2002
- /**
2003
- * @category do notation
2004
- * @since 2.0.0
2005
- */
2006
- export const bind: {
2007
- <N extends string, K, A, E2, R2>(
2008
- tag: Exclude<N, keyof K>,
2009
- f: (_: NoInfer<K>) => STM<A, E2, R2>
2010
- ): <E, R>(self: STM<K, E, R>) => STM<MergeRecord<K, { [k in N]: A }>, E2 | E, R2 | R>
2011
- <K, E, R, N extends string, A, E2, R2>(
2012
- self: STM<K, E, R>,
2013
- tag: Exclude<N, keyof K>,
2014
- f: (_: NoInfer<K>) => STM<A, E2, R2>
2015
- ): STM<MergeRecord<K, { [k in N]: A }>, E | E2, R | R2>
2016
- } = stm.bind
2017
-
2018
- const let_: {
2019
- <N extends string, K, A>(
2020
- tag: Exclude<N, keyof K>,
2021
- f: (_: NoInfer<K>) => A
2022
- ): <E, R>(self: STM<K, E, R>) => STM<MergeRecord<K, { [k in N]: A }>, E, R>
2023
- <K, E, R, N extends string, A>(
2024
- self: STM<K, E, R>,
2025
- tag: Exclude<N, keyof K>,
2026
- f: (_: NoInfer<K>) => A
2027
- ): STM<MergeRecord<K, { [k in N]: A }>, E, R>
2028
- } = stm.let_
2029
-
2030
- export {
2031
- /**
2032
- * @category do notation
2033
- * @since 2.0.0
2034
- */
2035
- let_ as let
2036
- }
2037
-
2038
- /**
2039
- * @category do notation
2040
- * @since 2.0.0
2041
- */
2042
- export const bindTo: {
2043
- <N extends string>(tag: N): <A, E, R>(self: STM<A, E, R>) => STM<Record<N, A>, E, R>
2044
- <A, E, R, N extends string>(self: STM<A, E, R>, tag: N): STM<Record<N, A>, E, R>
2045
- } = stm.bindTo