@fncts/io 0.0.2 → 0.0.5

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 (320) hide show
  1. package/Channel/UpstreamPullRequest/api.d.ts +1 -1
  2. package/Channel/api.d.ts +2 -2
  3. package/Clock/api.d.ts +3 -1
  4. package/Clock/definition.d.ts +3 -1
  5. package/Clock/live.d.ts +2 -0
  6. package/Fiber/api/interruptFork.d.ts +1 -1
  7. package/FiberRef/constructors.d.ts +0 -53
  8. package/FiberRef/unsafe.d.ts +53 -0
  9. package/FiberRef.d.ts +1 -0
  10. package/Future/constructors.d.ts +3 -3
  11. package/IO/api/asyncIO.d.ts +6 -0
  12. package/IO/api/ensuringChildren.d.ts +7 -0
  13. package/IO/api/sequenceT.d.ts +2 -3
  14. package/IO/api/sleep.d.ts +3 -1
  15. package/IO/api/timeout.d.ts +14 -0
  16. package/IO/api.d.ts +2 -2
  17. package/IO/definition.d.ts +8 -4
  18. package/IO.d.ts +3 -0
  19. package/IOSpec.d.ts +10 -1
  20. package/InterruptStatus/constructors.d.ts +3 -3
  21. package/Latch.d.ts +3 -0
  22. package/Schedule/Decision.d.ts +1 -1
  23. package/Schedule/api.d.ts +1 -1
  24. package/Schedule.d.ts +0 -1
  25. package/Scope/Finalizer/definition.d.ts +1 -1
  26. package/Scope/ReleaseMap/definition.d.ts +1 -1
  27. package/Stream/api.d.ts +5 -22
  28. package/Stream/internal/DebounceState.d.ts +3 -3
  29. package/Stream/internal/Handoff.d.ts +9 -9
  30. package/Stream/internal/SinkEndReason.d.ts +6 -18
  31. package/TFuture/definition.d.ts +1 -1
  32. package/TSemaphore/definition.d.ts +1 -1
  33. package/_cjs/Cached.cjs +3 -3
  34. package/_cjs/Channel/ChildExecutorDecision.cjs +2 -2
  35. package/_cjs/Channel/UpstreamPullRequest/api.cjs +3 -3
  36. package/_cjs/Channel/UpstreamPullRequest/api.cjs.map +1 -1
  37. package/_cjs/Channel/UpstreamPullRequest.cjs +2 -2
  38. package/_cjs/Channel/UpstreamPullStrategy.cjs +1 -1
  39. package/_cjs/Channel/api/interruptWhen.cjs +1 -1
  40. package/_cjs/Channel/api/interruptWhen.cjs.map +1 -1
  41. package/_cjs/Channel/api/mapOutIOC.cjs +1 -1
  42. package/_cjs/Channel/api/mapOutIOC.cjs.map +1 -1
  43. package/_cjs/Channel/api/mergeAllWith.cjs +1 -1
  44. package/_cjs/Channel/api/mergeAllWith.cjs.map +1 -1
  45. package/_cjs/Channel/api/mergeWith.cjs +6 -6
  46. package/_cjs/Channel/api/mergeWith.cjs.map +1 -1
  47. package/_cjs/Channel/api.cjs +14 -14
  48. package/_cjs/Channel/api.cjs.map +1 -1
  49. package/_cjs/Channel/core-api.cjs +1 -1
  50. package/_cjs/Channel/internal/ChannelExecutor.cjs +2 -2
  51. package/_cjs/Channel/internal/ChannelExecutor.cjs.map +1 -1
  52. package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs +8 -7
  53. package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs.map +1 -1
  54. package/_cjs/Channel.cjs +3 -3
  55. package/_cjs/Clock/api.cjs.map +1 -1
  56. package/_cjs/Clock/live.cjs +1 -1
  57. package/_cjs/Clock/live.cjs.map +1 -1
  58. package/_cjs/Clock.cjs +3 -3
  59. package/_cjs/Console.cjs +3 -3
  60. package/_cjs/Fiber/FiberContext.cjs +58 -57
  61. package/_cjs/Fiber/FiberContext.cjs.map +1 -1
  62. package/_cjs/Fiber/api/interruptFork.cjs +1 -1
  63. package/_cjs/Fiber/api/interruptFork.cjs.map +1 -1
  64. package/_cjs/Fiber/constructors.cjs +2 -2
  65. package/_cjs/Fiber/constructors.cjs.map +1 -1
  66. package/_cjs/Fiber.cjs +23 -23
  67. package/_cjs/FiberRef/constructors.cjs +3 -84
  68. package/_cjs/FiberRef/constructors.cjs.map +1 -1
  69. package/_cjs/FiberRef/unsafe.cjs +94 -0
  70. package/_cjs/FiberRef/unsafe.cjs.map +1 -0
  71. package/_cjs/FiberRef.cjs +18 -5
  72. package/_cjs/FiberRef.cjs.map +1 -1
  73. package/_cjs/FiberRefs/join.cjs +2 -2
  74. package/_cjs/FiberRefs/join.cjs.map +1 -1
  75. package/_cjs/FiberRefs.cjs +3 -3
  76. package/_cjs/FiberScope.cjs +2 -2
  77. package/_cjs/FiberState/constructors.cjs +1 -1
  78. package/_cjs/FiberState.cjs +3 -3
  79. package/_cjs/FiberStatus/constructors.cjs +1 -1
  80. package/_cjs/FiberStatus.cjs +2 -2
  81. package/_cjs/Future/constructors.cjs +2 -4
  82. package/_cjs/Future/constructors.cjs.map +1 -1
  83. package/_cjs/Future.cjs +3 -3
  84. package/_cjs/Hub.cjs +2 -2
  85. package/_cjs/IO/api/asyncIO.cjs +37 -0
  86. package/_cjs/IO/api/asyncIO.cjs.map +1 -0
  87. package/_cjs/IO/api/concurrency.cjs +1 -1
  88. package/_cjs/IO/api/core-scope.cjs +1 -1
  89. package/_cjs/IO/api/ensuringChildren.cjs +24 -0
  90. package/_cjs/IO/api/ensuringChildren.cjs.map +1 -0
  91. package/_cjs/IO/api/environment.cjs +1 -1
  92. package/_cjs/IO/api/interrupt.cjs +5 -5
  93. package/_cjs/IO/api/interrupt.cjs.map +1 -1
  94. package/_cjs/IO/api/sleep.cjs.map +1 -1
  95. package/_cjs/IO/api/timeout.cjs +42 -0
  96. package/_cjs/IO/api/timeout.cjs.map +1 -0
  97. package/_cjs/IO/api.cjs +41 -40
  98. package/_cjs/IO/api.cjs.map +1 -1
  99. package/_cjs/IO/definition.cjs +9 -6
  100. package/_cjs/IO/definition.cjs.map +1 -1
  101. package/_cjs/IO/runtime.cjs +2 -2
  102. package/_cjs/IO/runtime.cjs.map +1 -1
  103. package/_cjs/IO.cjs +86 -47
  104. package/_cjs/IO.cjs.map +1 -1
  105. package/_cjs/IOEnv/services.cjs +1 -1
  106. package/_cjs/IOEnv.cjs +3 -3
  107. package/_cjs/InterruptStatus/constructors.cjs +3 -7
  108. package/_cjs/InterruptStatus/constructors.cjs.map +1 -1
  109. package/_cjs/InterruptStatus.cjs +2 -2
  110. package/_cjs/Layer/api.cjs +5 -3
  111. package/_cjs/Layer/api.cjs.map +1 -1
  112. package/_cjs/Layer.cjs +3 -3
  113. package/_cjs/Logger.cjs +3 -3
  114. package/_cjs/Queue/api.cjs +7 -7
  115. package/_cjs/Queue.cjs +5 -5
  116. package/_cjs/Random.cjs +3 -3
  117. package/_cjs/Ref/Atomic/Atomic.cjs +3 -3
  118. package/_cjs/Ref/Atomic/api.cjs +10 -6
  119. package/_cjs/Ref/Atomic/api.cjs.map +1 -1
  120. package/_cjs/Ref/Atomic.cjs +2 -2
  121. package/_cjs/Ref/Derived.cjs +2 -2
  122. package/_cjs/Ref/DerivedAll.cjs +1 -1
  123. package/_cjs/Ref/Synchronized/api.cjs +1 -1
  124. package/_cjs/Ref/Synchronized/constructors.cjs +1 -1
  125. package/_cjs/Ref/Synchronized/definition.cjs +1 -1
  126. package/_cjs/Ref/api/get.cjs +1 -1
  127. package/_cjs/Ref/api/match.cjs +1 -1
  128. package/_cjs/Ref/api/matchAll.cjs +1 -1
  129. package/_cjs/Ref/api/modify.cjs +1 -1
  130. package/_cjs/Ref/api/set.cjs +1 -1
  131. package/_cjs/Ref/api.cjs +8 -8
  132. package/_cjs/Ref/constructors.cjs +1 -1
  133. package/_cjs/Ref.cjs +9 -9
  134. package/_cjs/STM/api/core-api.cjs +1 -1
  135. package/_cjs/STM/api/core-constructors.cjs +1 -1
  136. package/_cjs/STM/api.cjs +2 -2
  137. package/_cjs/STM/driver.cjs +1 -1
  138. package/_cjs/STM/internal/Entry.cjs +1 -1
  139. package/_cjs/STM/internal/Journal.cjs +2 -2
  140. package/_cjs/STM.cjs +5 -5
  141. package/_cjs/Schedule/Decision.cjs.map +1 -1
  142. package/_cjs/Schedule/api/driver.cjs +11 -9
  143. package/_cjs/Schedule/api/driver.cjs.map +1 -1
  144. package/_cjs/Schedule/api.cjs +49 -49
  145. package/_cjs/Schedule/api.cjs.map +1 -1
  146. package/_cjs/Schedule.cjs +4 -17
  147. package/_cjs/Schedule.cjs.map +1 -1
  148. package/_cjs/Scope/Finalizer/definition.cjs +6 -4
  149. package/_cjs/Scope/Finalizer/definition.cjs.map +1 -1
  150. package/_cjs/Scope/Finalizer.cjs +1 -1
  151. package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs +1 -1
  152. package/_cjs/Scope/ReleaseMap/api.cjs +1 -1
  153. package/_cjs/Scope/ReleaseMap/constructors.cjs +1 -1
  154. package/_cjs/Scope/ReleaseMap/definition.cjs +4 -2
  155. package/_cjs/Scope/ReleaseMap/definition.cjs.map +1 -1
  156. package/_cjs/Scope/ReleaseMap.cjs +3 -3
  157. package/_cjs/Scope/api.cjs +1 -1
  158. package/_cjs/Scope.cjs +2 -2
  159. package/_cjs/ScopedRef.cjs +2 -2
  160. package/_cjs/Sink/api.cjs +1 -1
  161. package/_cjs/Sink/api.cjs.map +1 -1
  162. package/_cjs/Sink.cjs +2 -2
  163. package/_cjs/State/api.cjs +2 -2
  164. package/_cjs/State/definition.cjs +1 -1
  165. package/_cjs/State.cjs +2 -2
  166. package/_cjs/Stream/api/zipAllWith.cjs +1 -1
  167. package/_cjs/Stream/api/zipWith.cjs +1 -1
  168. package/_cjs/Stream/api.cjs +308 -308
  169. package/_cjs/Stream/api.cjs.map +1 -1
  170. package/_cjs/Stream/internal/DebounceState.cjs.map +1 -1
  171. package/_cjs/Stream/internal/Handoff.cjs.map +1 -1
  172. package/_cjs/Stream/internal/SinkEndReason.cjs +2 -37
  173. package/_cjs/Stream/internal/SinkEndReason.cjs.map +1 -1
  174. package/_cjs/Stream.cjs +2 -2
  175. package/_cjs/Supervisor/constructors.cjs +1 -1
  176. package/_cjs/Supervisor.cjs +3 -3
  177. package/_cjs/TExit/constructors.cjs +1 -1
  178. package/_cjs/TExit.cjs +2 -2
  179. package/_cjs/TFuture/definition.cjs +4 -2
  180. package/_cjs/TFuture/definition.cjs.map +1 -1
  181. package/_cjs/TFuture.cjs +3 -3
  182. package/_cjs/TRef/api.cjs +2 -2
  183. package/_cjs/TRef/constructors.cjs +3 -3
  184. package/_cjs/TRef.cjs +3 -3
  185. package/_cjs/TSemaphore/api.cjs +1 -1
  186. package/_cjs/TSemaphore/definition.cjs +4 -2
  187. package/_cjs/TSemaphore/definition.cjs.map +1 -1
  188. package/_cjs/TSemaphore.cjs +3 -3
  189. package/_cjs/collection/immutable/Conc.cjs +3 -3
  190. package/_mjs/Channel/UpstreamPullRequest/api.mjs +1 -2
  191. package/_mjs/Channel/UpstreamPullRequest/api.mjs.map +1 -1
  192. package/_mjs/Channel/api/interruptWhen.mjs +1 -1
  193. package/_mjs/Channel/api/interruptWhen.mjs.map +1 -1
  194. package/_mjs/Channel/api/mapOutIOC.mjs +1 -1
  195. package/_mjs/Channel/api/mapOutIOC.mjs.map +1 -1
  196. package/_mjs/Channel/api/mergeAllWith.mjs +1 -1
  197. package/_mjs/Channel/api/mergeAllWith.mjs.map +1 -1
  198. package/_mjs/Channel/api/mergeWith.mjs +6 -6
  199. package/_mjs/Channel/api/mergeWith.mjs.map +1 -1
  200. package/_mjs/Channel/api.mjs +14 -14
  201. package/_mjs/Channel/api.mjs.map +1 -1
  202. package/_mjs/Channel/internal/ChannelExecutor.mjs +2 -2
  203. package/_mjs/Channel/internal/ChannelExecutor.mjs.map +1 -1
  204. package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs +8 -7
  205. package/_mjs/Channel/internal/SingleProducerAsyncInput.mjs.map +1 -1
  206. package/_mjs/Clock/api.mjs.map +1 -1
  207. package/_mjs/Clock/live.mjs +1 -1
  208. package/_mjs/Clock/live.mjs.map +1 -1
  209. package/_mjs/Fiber/FiberContext.mjs +58 -57
  210. package/_mjs/Fiber/FiberContext.mjs.map +1 -1
  211. package/_mjs/Fiber/api/interruptFork.mjs +1 -1
  212. package/_mjs/Fiber/api/interruptFork.mjs.map +1 -1
  213. package/_mjs/Fiber/constructors.mjs +1 -1
  214. package/_mjs/Fiber/constructors.mjs.map +1 -1
  215. package/_mjs/FiberRef/constructors.mjs +3 -66
  216. package/_mjs/FiberRef/constructors.mjs.map +1 -1
  217. package/_mjs/FiberRef/unsafe.mjs +66 -0
  218. package/_mjs/FiberRef/unsafe.mjs.map +1 -0
  219. package/_mjs/FiberRef.mjs +2 -1
  220. package/_mjs/FiberRef.mjs.map +1 -1
  221. package/_mjs/FiberRefs/join.mjs +2 -2
  222. package/_mjs/FiberRefs/join.mjs.map +1 -1
  223. package/_mjs/Future/constructors.mjs +3 -4
  224. package/_mjs/Future/constructors.mjs.map +1 -1
  225. package/_mjs/IO/api/asyncIO.mjs +20 -0
  226. package/_mjs/IO/api/asyncIO.mjs.map +1 -0
  227. package/_mjs/IO/api/concurrency.mjs +1 -1
  228. package/_mjs/IO/api/ensuringChildren.mjs +11 -0
  229. package/_mjs/IO/api/ensuringChildren.mjs.map +1 -0
  230. package/_mjs/IO/api/environment.mjs +1 -1
  231. package/_mjs/IO/api/interrupt.mjs +4 -4
  232. package/_mjs/IO/api/interrupt.mjs.map +1 -1
  233. package/_mjs/IO/api/sleep.mjs.map +1 -1
  234. package/_mjs/IO/api/timeout.mjs +23 -0
  235. package/_mjs/IO/api/timeout.mjs.map +1 -0
  236. package/_mjs/IO/api.mjs +41 -40
  237. package/_mjs/IO/api.mjs.map +1 -1
  238. package/_mjs/IO/definition.mjs +6 -4
  239. package/_mjs/IO/definition.mjs.map +1 -1
  240. package/_mjs/IO/runtime.mjs +2 -2
  241. package/_mjs/IO/runtime.mjs.map +1 -1
  242. package/_mjs/IO.mjs +3 -0
  243. package/_mjs/IO.mjs.map +1 -1
  244. package/_mjs/IOEnv/services.mjs +1 -1
  245. package/_mjs/InterruptStatus/constructors.mjs +3 -3
  246. package/_mjs/InterruptStatus/constructors.mjs.map +1 -1
  247. package/_mjs/Layer/api.mjs +4 -3
  248. package/_mjs/Layer/api.mjs.map +1 -1
  249. package/_mjs/Ref/Atomic/api.mjs +10 -6
  250. package/_mjs/Ref/Atomic/api.mjs.map +1 -1
  251. package/_mjs/Schedule/Decision.mjs.map +1 -1
  252. package/_mjs/Schedule/api/driver.mjs +10 -9
  253. package/_mjs/Schedule/api/driver.mjs.map +1 -1
  254. package/_mjs/Schedule/api.mjs +49 -49
  255. package/_mjs/Schedule/api.mjs.map +1 -1
  256. package/_mjs/Schedule.mjs +0 -1
  257. package/_mjs/Schedule.mjs.map +1 -1
  258. package/_mjs/Scope/Finalizer/definition.mjs +5 -4
  259. package/_mjs/Scope/Finalizer/definition.mjs.map +1 -1
  260. package/_mjs/Scope/ReleaseMap/definition.mjs +3 -2
  261. package/_mjs/Scope/ReleaseMap/definition.mjs.map +1 -1
  262. package/_mjs/Sink/api.mjs +1 -1
  263. package/_mjs/Sink/api.mjs.map +1 -1
  264. package/_mjs/Stream/api.mjs +308 -302
  265. package/_mjs/Stream/api.mjs.map +1 -1
  266. package/_mjs/Stream/internal/DebounceState.mjs.map +1 -1
  267. package/_mjs/Stream/internal/Handoff.mjs.map +1 -1
  268. package/_mjs/Stream/internal/SinkEndReason.mjs +1 -30
  269. package/_mjs/Stream/internal/SinkEndReason.mjs.map +1 -1
  270. package/_mjs/TFuture/definition.mjs +3 -2
  271. package/_mjs/TFuture/definition.mjs.map +1 -1
  272. package/_mjs/TSemaphore/definition.mjs +3 -2
  273. package/_mjs/TSemaphore/definition.mjs.map +1 -1
  274. package/_src/Channel/UpstreamPullRequest/api.ts +2 -3
  275. package/_src/Channel/api.ts +3 -3
  276. package/_src/Channel/internal/ChannelExecutor.ts +2 -2
  277. package/_src/Channel/internal/SingleProducerAsyncInput.ts +1 -0
  278. package/_src/Clock/api.ts +1 -1
  279. package/_src/Clock/definition.ts +1 -1
  280. package/_src/Clock/live.ts +2 -2
  281. package/_src/Fiber/FiberContext.ts +3 -2
  282. package/_src/Fiber/api/interruptFork.ts +1 -1
  283. package/_src/Fiber/constructors.ts +1 -1
  284. package/_src/FiberRef/constructors.ts +1 -78
  285. package/_src/FiberRef/unsafe.ts +79 -0
  286. package/_src/FiberRef.ts +1 -0
  287. package/_src/FiberRefs/join.ts +2 -2
  288. package/_src/Future/constructors.ts +1 -1
  289. package/_src/IO/api/asyncIO.ts +16 -0
  290. package/_src/IO/api/ensuringChildren.ts +11 -0
  291. package/_src/IO/api/interrupt.ts +2 -1
  292. package/_src/IO/api/sequenceT.ts +1 -1
  293. package/_src/IO/api/sleep.ts +1 -1
  294. package/_src/IO/api/timeout.ts +19 -0
  295. package/_src/IO/api.ts +6 -4
  296. package/_src/IO/definition.ts +8 -4
  297. package/_src/IO.ts +3 -0
  298. package/_src/InterruptStatus/constructors.ts +2 -0
  299. package/_src/Layer/api.ts +1 -1
  300. package/_src/Ref/Atomic/api.ts +4 -0
  301. package/_src/Schedule/Decision.ts +0 -2
  302. package/_src/Schedule/api/driver.ts +1 -1
  303. package/_src/Schedule/api.ts +0 -3
  304. package/_src/Schedule.ts +0 -1
  305. package/_src/Scope/Finalizer/definition.ts +1 -1
  306. package/_src/Scope/ReleaseMap/definition.ts +1 -1
  307. package/_src/Stream/api.ts +199 -134
  308. package/_src/Stream/internal/DebounceState.ts +2 -2
  309. package/_src/Stream/internal/Handoff.ts +9 -9
  310. package/_src/Stream/internal/SinkEndReason.ts +7 -25
  311. package/_src/TFuture/definition.ts +2 -2
  312. package/_src/TSemaphore/definition.ts +1 -1
  313. package/package.json +3 -3
  314. package/runTests.d.ts +1 -0
  315. package/Schedule/Interval.d.ts +0 -71
  316. package/_cjs/Schedule/Interval.cjs +0 -154
  317. package/_cjs/Schedule/Interval.cjs.map +0 -1
  318. package/_mjs/Schedule/Interval.mjs +0 -114
  319. package/_mjs/Schedule/Interval.mjs.map +0 -1
  320. package/_src/Schedule/Interval.ts +0 -103
@@ -1,8 +1,4 @@
1
- import type { LogSpan } from "@fncts/io/LogSpan";
2
-
3
1
  import { identity } from "@fncts/base/data/function";
4
- import { Patch } from "@fncts/base/data/Patch";
5
- import { FiberRefInternal } from "@fncts/io/FiberRef/definition";
6
2
 
7
3
  function makeWith<Value, Patch>(
8
4
  ref: Lazy<FiberRef.WithPatch<Value, Patch>>,
@@ -13,49 +9,6 @@ function makeWith<Value, Patch>(
13
9
  );
14
10
  }
15
11
 
16
- /**
17
- * @tsplus static fncts.io.FiberRefOps unsafeMakePatch
18
- */
19
- export function unsafeMakePatch<Value, Patch>(
20
- initial: Value,
21
- diff: (oldValue: Value, newValue: Value) => Patch,
22
- combine: (first: Patch, second: Patch) => Patch,
23
- patch: (patch: Patch) => (oldValue: Value) => Value,
24
- fork: Patch,
25
- ): FiberRef.WithPatch<Value, Patch> {
26
- return new FiberRefInternal(initial, diff, combine, patch, fork);
27
- }
28
-
29
- /**
30
- * @tsplus static fncts.io.FiberRefOps unsafeMakeEnvironment
31
- */
32
- export function unsafeMakeEnvironment<A>(initial: Environment<A>): FiberRef.WithPatch<Environment<A>, Patch<A, A>> {
33
- return FiberRef.unsafeMakePatch(
34
- initial,
35
- Patch.diff,
36
- (first, second) => first.compose(second),
37
- (patch) => (value) => patch(value),
38
- Patch.empty(),
39
- );
40
- }
41
-
42
- /**
43
- * @tsplus static fncts.io.FiberRefOps unsafeMake
44
- */
45
- export function unsafeMake<A>(
46
- initial: A,
47
- fork: (a: A) => A = identity,
48
- join: (a0: A, a1: A) => A = (_, a) => a,
49
- ): FiberRef.WithPatch<A, (_: A) => A> {
50
- return FiberRef.unsafeMakePatch(
51
- initial,
52
- (_, newValue) => () => newValue,
53
- (first, second) => (value) => second(first(value)),
54
- (patch) => (value) => join(value, patch(value)),
55
- fork,
56
- );
57
- }
58
-
59
12
  /**
60
13
  * @tsplus static fncts.io.FiberRefOps make
61
14
  */
@@ -64,35 +17,5 @@ export function make<A>(
64
17
  fork: (a: A) => A = identity,
65
18
  join: (a: A, a1: A) => A = (_, a) => a,
66
19
  ): IO<Has<Scope>, never, FiberRef<A>> {
67
- return makeWith(unsafeMake(initial, fork, join));
20
+ return makeWith(FiberRef.unsafeMake(initial, fork, join));
68
21
  }
69
-
70
- /**
71
- * @tsplus static fncts.io.FiberRefOps forkScopeOverride
72
- */
73
- export const forkScopeOverride = FiberRef.unsafeMake<Maybe<FiberScope>>(Nothing());
74
-
75
- /**
76
- * @tsplus static fncts.io.FiberRefOps currentEnvironment
77
- */
78
- export const currentEnvironment = FiberRef.unsafeMakeEnvironment<unknown>(Environment.empty);
79
-
80
- /**
81
- * @tsplus static fncts.io.FiberRefOps fiberName
82
- */
83
- export const fiberName = FiberRef.unsafeMake<Maybe<string>>(Nothing());
84
-
85
- /**
86
- * @tsplus static fncts.io.FiberRefOps currentLogLevel
87
- */
88
- export const currentLogLevel = FiberRef.unsafeMake<LogLevel>(LogLevel.Info);
89
-
90
- /**
91
- * @tsplus static fncts.io.FiberRefOps currentLogSpan
92
- */
93
- export const currentLogSpan = FiberRef.unsafeMake<List<LogSpan>>(Nil());
94
-
95
- /**
96
- * @tsplus static fncts.io.FiberRefOps currentLogAnnotations
97
- */
98
- export const currentLogAnnotations = FiberRef.unsafeMake<HashMap<string, string>>(HashMap.makeDefault());
@@ -0,0 +1,79 @@
1
+ import type { LogSpan } from "../LogSpan.js";
2
+
3
+ import { identity } from "@fncts/base/data/function";
4
+ import { Patch } from "@fncts/base/data/Patch";
5
+
6
+ import { FiberRefInternal } from "./definition.js";
7
+
8
+ /**
9
+ * @tsplus static fncts.io.FiberRefOps unsafeMakePatch
10
+ */
11
+ export function unsafeMakePatch<Value, Patch>(
12
+ initial: Value,
13
+ diff: (oldValue: Value, newValue: Value) => Patch,
14
+ combine: (first: Patch, second: Patch) => Patch,
15
+ patch: (patch: Patch) => (oldValue: Value) => Value,
16
+ fork: Patch,
17
+ ): FiberRef.WithPatch<Value, Patch> {
18
+ return new FiberRefInternal(initial, diff, combine, patch, fork);
19
+ }
20
+
21
+ /**
22
+ * @tsplus static fncts.io.FiberRefOps unsafeMakeEnvironment
23
+ */
24
+ export function unsafeMakeEnvironment<A>(initial: Environment<A>): FiberRef.WithPatch<Environment<A>, Patch<A, A>> {
25
+ return FiberRef.unsafeMakePatch(
26
+ initial,
27
+ Patch.diff,
28
+ (first, second) => first.compose(second),
29
+ (patch) => (value) => patch(value),
30
+ Patch.empty(),
31
+ );
32
+ }
33
+
34
+ /**
35
+ * @tsplus static fncts.io.FiberRefOps unsafeMake
36
+ */
37
+ export function unsafeMake<A>(
38
+ initial: A,
39
+ fork: (a: A) => A = identity,
40
+ join: (a0: A, a1: A) => A = (_, a) => a,
41
+ ): FiberRef.WithPatch<A, (_: A) => A> {
42
+ return FiberRef.unsafeMakePatch(
43
+ initial,
44
+ (_, newValue) => () => newValue,
45
+ (first, second) => (value) => second(first(value)),
46
+ (patch) => (value) => join(value, patch(value)),
47
+ fork,
48
+ );
49
+ }
50
+
51
+ /**
52
+ * @tsplus static fncts.io.FiberRefOps forkScopeOverride
53
+ */
54
+ export const forkScopeOverride = FiberRef.unsafeMake<Maybe<FiberScope>>(Nothing(), () => Nothing());
55
+
56
+ /**
57
+ * @tsplus static fncts.io.FiberRefOps currentEnvironment
58
+ */
59
+ export const currentEnvironment = FiberRef.unsafeMakeEnvironment<unknown>(Environment.empty);
60
+
61
+ /**
62
+ * @tsplus static fncts.io.FiberRefOps fiberName
63
+ */
64
+ export const fiberName = FiberRef.unsafeMake<Maybe<string>>(Nothing());
65
+
66
+ /**
67
+ * @tsplus static fncts.io.FiberRefOps currentLogLevel
68
+ */
69
+ export const currentLogLevel = FiberRef.unsafeMake<LogLevel>(LogLevel.Info);
70
+
71
+ /**
72
+ * @tsplus static fncts.io.FiberRefOps currentLogSpan
73
+ */
74
+ export const currentLogSpan = FiberRef.unsafeMake<List<LogSpan>>(Nil());
75
+
76
+ /**
77
+ * @tsplus static fncts.io.FiberRefOps currentLogAnnotations
78
+ */
79
+ export const currentLogAnnotations = FiberRef.unsafeMake<HashMap<string, string>>(HashMap.makeDefault());
package/_src/FiberRef.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  export * from "./FiberRef/api.js";
3
3
  export * from "./FiberRef/constructors.js";
4
4
  export * from "./FiberRef/definition.js";
5
+ export * from "./FiberRef/unsafe.js";
5
6
  // codegen:end
6
7
 
7
8
  // codegen:start { preset: barrel, include: ./FiberRef/api/*.ts }
@@ -40,8 +40,8 @@ export function join(self: FiberRefs, fiberId: FiberId.Runtime, that: FiberRefs)
40
40
  }
41
41
 
42
42
  function compareFiberId(left: FiberId.Runtime, right: FiberId.Runtime): number {
43
- const compare = Number.Ord.compare_(left.startTime, right.startTime);
44
- return compare === 0 ? Number.Ord.compare_(left.id, right.id) : compare;
43
+ const compare = Number.Ord.compare(left.startTime, right.startTime);
44
+ return compare === 0 ? Number.Ord.compare(left.id, right.id) : compare;
45
45
  }
46
46
 
47
47
  /**
@@ -1,4 +1,4 @@
1
- import { Pending } from "@fncts/io/Future/definition";
1
+ import { Future, Pending } from "@fncts/io/Future/definition";
2
2
 
3
3
  /**
4
4
  * Makes a new future to be completed by the fiber creating the future.
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @tsplus static fncts.io.IOOps asyncIO
3
+ */
4
+ export function asyncIO<R, E, A>(register: (k: (_: IO<R, E, A>) => void) => IO<R, E, void>): IO<R, E, A> {
5
+ return Do((Δ) => {
6
+ const f = Δ(Future.make<E, A>());
7
+ const r = Δ(IO.runtime<R>());
8
+ const a = Δ(
9
+ IO.uninterruptibleMask(({ restore }) => {
10
+ const io = register((k) => r.unsafeRunAsync(k.fulfill(f)));
11
+ return restore(io.catchAllCause((cause) => f.failCause(cause))).fork > restore(f.await);
12
+ }),
13
+ );
14
+ return a;
15
+ });
16
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @tsplus fluent fncts.io.IO ensuringChildren
3
+ */
4
+ export function ensuringChildren<R, E, A, R1>(
5
+ self: IO<R, E, A>,
6
+ children: (_: Conc<Fiber.Runtime<any, any>>) => IO<R1, never, void>,
7
+ ): IO<R & R1, E, A> {
8
+ return Supervisor.track.flatMap((supervisor) =>
9
+ self.supervised(supervisor).ensuring(supervisor.value.flatMap(children)),
10
+ );
11
+ }
@@ -100,7 +100,8 @@ export function onInterrupt_<R, E, A, R1>(
100
100
  ): IO<R & R1, E, A> {
101
101
  return uninterruptibleMask(({ restore }) =>
102
102
  restore(ma).matchCauseIO(
103
- (cause) => (cause.interrupted ? cleanup(cause.interruptors) : IO.failCauseNow(cause)),
103
+ (cause) =>
104
+ cause.interrupted ? cleanup(cause.interruptors).apSecond(IO.failCauseNow(cause)) : IO.failCauseNow(cause),
104
105
  IO.succeedNow,
105
106
  ),
106
107
  );
@@ -7,6 +7,6 @@ import { identity, unsafeCoerce } from "@fncts/base/data/function";
7
7
  */
8
8
  export function sequenceT<T extends ReadonlyNonEmptyArray<IO<any, any, any>>>(
9
9
  ...ios: T
10
- ): IO<_R<T[number]>, _E<T[number]>, { [K in keyof T]: _A<T[K]> }> {
10
+ ): IO<HKT._R<T[number]>, HKT._E<T[number]>, { [K in keyof T]: HKT._A<T[K]> }> {
11
11
  return unsafeCoerce(IO.foreach(ios, identity));
12
12
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @tsplus static fncts.io.IOOps sleep
3
3
  */
4
- export function sleep(duration: number, __tsplusTrace?: string): UIO<void> {
4
+ export function sleep(duration: Lazy<Duration>, __tsplusTrace?: string): UIO<void> {
5
5
  return Clock.sleep(duration);
6
6
  }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @tsplus fluent fncts.io.IO timeoutTo
3
+ */
4
+ export function timeoutTo<R, E, A, B, B1>(
5
+ self: IO<R, E, A>,
6
+ duration: Lazy<Duration>,
7
+ b: Lazy<B>,
8
+ f: (a: A) => B1,
9
+ __tsplusTrace?: string,
10
+ ): IO<R, E, B | B1> {
11
+ return self.map(f).raceFirst(IO.sleep(duration).interruptible.as(b));
12
+ }
13
+
14
+ /**
15
+ * @tsplus fluent fncts.io.IO timeout
16
+ */
17
+ export function timeout<R, E, A>(self: IO<R, E, A>, duration: Lazy<Duration>): IO<R, E, Maybe<A>> {
18
+ return self.timeoutTo(duration, Nothing(), Maybe.just);
19
+ }
package/_src/IO/api.ts CHANGED
@@ -761,12 +761,14 @@ export function foldLeft_<A, B, R, E>(
761
761
  /**
762
762
  * Combines an array of `IO`s using a `Monoid`
763
763
  *
764
- * @constrained
765
764
  * @tsplus static fncts.io.IOOps foldMap
766
765
  */
767
- export function foldMap_<M>(M: P.Monoid<M>) {
768
- return <R, E, A>(as: Iterable<IO<R, E, A>>, f: (a: A) => M): IO<R, E, M> =>
769
- IO.foldLeft(as, M.nat, (m, a) => a.map((a) => M.combine_(m, f(a))));
766
+ export function foldMap_<R, E, A, M>(
767
+ as: Iterable<IO<R, E, A>>,
768
+ f: (a: A) => M,
769
+ /** @tsplus auto */ M: P.Monoid<M>,
770
+ ): IO<R, E, M> {
771
+ return IO.foldLeft(as, M.nat, (m, a) => a.map((a) => M.combine(m, f(a))));
770
772
  }
771
773
 
772
774
  function foldRightLoop<A, B, R, E>(
@@ -4,15 +4,19 @@ import type { FiberContext } from "@fncts/io/Fiber/FiberContext";
4
4
  export const IOTypeId = Symbol.for("fncts.io.IO");
5
5
  export type IOTypeId = typeof IOTypeId;
6
6
 
7
+ export interface IOF extends IO<any, any, any> {}
8
+
7
9
  /**
8
10
  * @tsplus type fncts.io.IO
9
11
  * @tsplus companion fncts.io.IOOps
10
12
  */
11
13
  export abstract class IO<R, E, A> {
12
14
  readonly _typeId: IOTypeId = IOTypeId;
13
- readonly _R!: (_: R) => void;
14
- readonly _E!: () => E;
15
- readonly _A!: () => A;
15
+ readonly [HKT.F]!: IOF;
16
+ readonly [HKT.R]!: (_: R) => void;
17
+ readonly [HKT.E]!: () => E;
18
+ readonly [HKT.A]!: () => A;
19
+ readonly [HKT.T]!: IO<HKT._R<this>, HKT._E<this>, HKT._A<this>>;
16
20
  }
17
21
 
18
22
  /**
@@ -407,7 +411,7 @@ export type Instruction =
407
411
  | SetRuntimeConfig;
408
412
 
409
413
  /**
410
- * @optimize identity
414
+ * @tsplus macro identity
411
415
  */
412
416
  export function concrete(_: IO<any, any, any>): Instruction {
413
417
  // @ts-expect-error
package/_src/IO.ts CHANGED
@@ -11,6 +11,7 @@ export * from "./IO/api/acquireReleaseInterruptible.js";
11
11
  export * from "./IO/api/acquireReleaseInterruptibleExit.js";
12
12
  export * from "./IO/api/addFinalizer.js";
13
13
  export * from "./IO/api/addFinalizerExit.js";
14
+ export * from "./IO/api/asyncIO.js";
14
15
  export * from "./IO/api/bracket.js";
15
16
  export * from "./IO/api/bracketExit.js";
16
17
  export * from "./IO/api/clockWith.js";
@@ -18,6 +19,7 @@ export * from "./IO/api/concurrency.js";
18
19
  export * from "./IO/api/concurrentFinalizers.js";
19
20
  export * from "./IO/api/consoleWith.js";
20
21
  export * from "./IO/api/core-scope.js";
22
+ export * from "./IO/api/ensuringChildren.js";
21
23
  export * from "./IO/api/environment.js";
22
24
  export * from "./IO/api/foreachC.js";
23
25
  export * from "./IO/api/foreachExec.js";
@@ -43,6 +45,7 @@ export * from "./IO/api/scopeWith.js";
43
45
  export * from "./IO/api/sequenceT.js";
44
46
  export * from "./IO/api/sleep.js";
45
47
  export * from "./IO/api/stateful.js";
48
+ export * from "./IO/api/timeout.js";
46
49
  export * from "./IO/api/withChildren.js";
47
50
  export * from "./IO/api/withFinalizer.js";
48
51
  export * from "./IO/api/withFinalizerExit.js";
@@ -1,3 +1,5 @@
1
+ import { InterruptStatus } from "./definition.js";
2
+
1
3
  /**
2
4
  * @tsplus static fncts.InterruptStatusOps interruptible
3
5
  */
package/_src/Layer/api.ts CHANGED
@@ -282,7 +282,7 @@ function retryUpdate<S, RIn, E, X>(
282
282
  .flatMap(([state, _, decision]) =>
283
283
  decision._tag === DecisionTag.Done
284
284
  ? IO.failNow(e)
285
- : Clock.sleep(decision.interval.startMilliseconds - now).as({ state }),
285
+ : Clock.sleep(Duration.fromInterval(now, decision.interval.startMilliseconds)).as({ state }),
286
286
  ),
287
287
  ),
288
288
  tag,
@@ -29,6 +29,7 @@ export function getAndUpdateJust<A>(self: Atomic<A>, f: (a: A) => Maybe<A>) {
29
29
  return IO.succeed(() => {
30
30
  const v = self.unsafeGet;
31
31
  const o = f(v);
32
+ Maybe.concrete(o);
32
33
  if (o._tag === "Just") {
33
34
  self.unsafeSet(o.value);
34
35
  }
@@ -56,6 +57,7 @@ export function modifyJust<A, B>(self: Atomic<A>, def: B, f: (a: A) => Maybe<rea
56
57
  const v = self.unsafeGet;
57
58
  const o = f(v);
58
59
 
60
+ Maybe.concrete(o);
59
61
  if (o._tag === "Just") {
60
62
  self.unsafeSet(o.value[1]);
61
63
  return o.value[0];
@@ -91,6 +93,7 @@ export function updateJust<A>(self: Atomic<A>, f: (a: A) => Maybe<A>) {
91
93
  return IO.succeed(() => {
92
94
  const o = f(self.unsafeGet);
93
95
 
96
+ Maybe.concrete(o);
94
97
  if (o._tag === "Just") {
95
98
  self.unsafeSet(o.value);
96
99
  }
@@ -104,6 +107,7 @@ export function updateJustAndGet<A>(self: Atomic<A>, f: (a: A) => Maybe<A>) {
104
107
  return IO.succeed(() => {
105
108
  const o = f(self.unsafeGet);
106
109
 
110
+ Maybe.concrete(o);
107
111
  if (o._tag === "Just") {
108
112
  self.unsafeSet(o.value);
109
113
  }
@@ -1,5 +1,3 @@
1
- import type { Interval } from "./Interval.js";
2
-
3
1
  export const enum DecisionTag {
4
2
  Continue = "Continue",
5
3
  Done = "Done",
@@ -19,7 +19,7 @@ export function driver<State, Env, In, Out>(
19
19
  (interval) =>
20
20
  ref
21
21
  .set([Just(out), state1])
22
- .apSecond(Clock.sleep(interval.startMilliseconds - now))
22
+ .apSecond(Clock.sleep(Duration.fromInterval(now, interval.startMilliseconds)))
23
23
  .as(out),
24
24
  ),
25
25
  );
@@ -1,7 +1,4 @@
1
- import { Driver } from "@fncts/io/Schedule/Driver";
2
-
3
1
  import { Decision, DecisionTag } from "./Decision.js";
4
- import { Interval } from "./Interval.js";
5
2
 
6
3
  /**
7
4
  * @tsplus static fncts.io.ScheduleOps __call
package/_src/Schedule.ts CHANGED
@@ -3,5 +3,4 @@ export * from "./Schedule/api.js";
3
3
  export * from "./Schedule/Decision.js";
4
4
  export * from "./Schedule/definition.js";
5
5
  export * from "./Schedule/Driver.js";
6
- export * from "./Schedule/Interval.js";
7
6
  // codegen:end
@@ -1,5 +1,5 @@
1
1
  interface FinalizerN extends HKT {
2
- readonly type: Finalizer;
2
+ readonly [HKT.T]: Finalizer;
3
3
  }
4
4
 
5
5
  /**
@@ -15,7 +15,7 @@ export class Running {
15
15
  export type State = Exited | Running;
16
16
 
17
17
  interface ReleaseMapN extends HKT {
18
- readonly type: ReleaseMap;
18
+ readonly [HKT.T]: ReleaseMap;
19
19
  }
20
20
 
21
21
  /**