From 5a2314b70ec79c2c02b51cef45a5ddec8327daa1 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 5 Apr 2024 20:52:34 +1300 Subject: [PATCH] replace use of `unit` terminology with `void` (#2476) --- .changeset/six-ears-beam.md | 29 +++ packages/cli/src/internal/cliApp.ts | 2 +- packages/cli/src/internal/options.ts | 2 +- packages/cli/src/internal/primitive.ts | 8 +- packages/cli/test/services/MockConsole.ts | 34 ++-- packages/cli/test/services/MockTerminal.ts | 4 +- packages/effect/src/Channel.ts | 17 +- packages/effect/src/Effect.ts | 15 +- packages/effect/src/Exit.ts | 19 +- packages/effect/src/Fiber.ts | 17 +- packages/effect/src/FiberMap.ts | 2 +- packages/effect/src/Option.ts | 13 +- packages/effect/src/STM.ts | 19 +- packages/effect/src/Schedule.ts | 2 +- packages/effect/src/Stream.ts | 19 +- packages/effect/src/TestClock.ts | 6 +- packages/effect/src/internal/cache.ts | 6 +- packages/effect/src/internal/channel.ts | 18 +- .../src/internal/channel/channelExecutor.ts | 30 +-- .../src/internal/channel/channelState.ts | 2 +- .../channel/singleProducerAsyncInput.ts | 2 +- packages/effect/src/internal/clock.ts | 4 +- packages/effect/src/internal/core-effect.ts | 18 +- packages/effect/src/internal/core-stream.ts | 7 +- packages/effect/src/internal/core.ts | 29 +-- packages/effect/src/internal/dataSource.ts | 6 +- .../effect/src/internal/effect/circular.ts | 4 +- packages/effect/src/internal/fiber.ts | 13 +- packages/effect/src/internal/fiberRuntime.ts | 74 ++++---- packages/effect/src/internal/groupBy.ts | 6 +- packages/effect/src/internal/layer.ts | 10 +- .../effect/src/internal/managedRuntime.ts | 2 +- packages/effect/src/internal/pool.ts | 22 +-- packages/effect/src/internal/pubsub.ts | 12 +- packages/effect/src/internal/query.ts | 4 +- packages/effect/src/internal/queue.ts | 10 +- packages/effect/src/internal/rateLimiter.ts | 2 +- packages/effect/src/internal/reloadable.ts | 2 +- packages/effect/src/internal/runtime.ts | 6 +- packages/effect/src/internal/schedule.ts | 6 +- packages/effect/src/internal/scopedCache.ts | 14 +- packages/effect/src/internal/scopedRef.ts | 8 +- packages/effect/src/internal/sink.ts | 16 +- packages/effect/src/internal/stm/stm.ts | 18 +- packages/effect/src/internal/stm/stm/tExit.ts | 7 +- packages/effect/src/internal/stm/tMap.ts | 4 +- packages/effect/src/internal/stm/tPubSub.ts | 4 +- packages/effect/src/internal/stm/tQueue.ts | 4 +- packages/effect/src/internal/stream.ts | 173 +++++++++--------- packages/effect/src/internal/supervisor.ts | 2 +- packages/effect/src/internal/take.ts | 2 +- .../test/Channel/error-handling.test.ts | 2 +- .../effect/test/Channel/finalization.test.ts | 4 +- .../effect/test/Channel/interruption.test.ts | 2 +- packages/effect/test/Channel/merging.test.ts | 2 +- packages/effect/test/Channel/reading.test.ts | 30 +-- packages/effect/test/Channel/scoping.test.ts | 4 +- .../effect/test/Channel/stack-safety.test.ts | 2 +- packages/effect/test/Effect/async.test.ts | 2 +- .../effect/test/Effect/concurrency.test.ts | 6 +- .../effect/test/Effect/environment.test.ts | 2 +- .../effect/test/Effect/error-handling.test.ts | 12 +- packages/effect/test/Effect/filtering.test.ts | 2 +- .../effect/test/Effect/finalization.test.ts | 56 +++--- packages/effect/test/Effect/forking.test.ts | 2 +- .../effect/test/Effect/interruption.test.ts | 38 ++-- .../test/Effect/provide-runtime.test.ts | 4 +- .../effect/test/Effect/stack-safety.test.ts | 2 +- packages/effect/test/Effect/timeout.test.ts | 6 +- .../effect/test/Effect/traversing.test.ts | 12 +- packages/effect/test/Fiber.test.ts | 8 +- packages/effect/test/FiberMap.test.ts | 4 +- packages/effect/test/FiberRef.test.ts | 10 +- packages/effect/test/FiberRefs.test.ts | 2 +- packages/effect/test/FiberSet.test.ts | 4 +- packages/effect/test/KeyedPool.test.ts | 2 +- packages/effect/test/Layer.test.ts | 16 +- packages/effect/test/ManagedRuntime.test.ts | 8 +- packages/effect/test/Metric.test.ts | 8 +- packages/effect/test/Option.test.ts | 2 +- packages/effect/test/RateLimiter.test.ts | 20 +- packages/effect/test/STM.test.ts | 6 +- packages/effect/test/Schedule.test.ts | 2 +- packages/effect/test/Scope.test.ts | 2 +- packages/effect/test/ScopedCache.test.ts | 80 ++++---- packages/effect/test/Sink/foreign.test.ts | 2 +- packages/effect/test/Stream/async.test.ts | 22 +-- .../effect/test/Stream/conditionals.test.ts | 2 +- .../effect/test/Stream/error-handling.test.ts | 4 +- packages/effect/test/Stream/repeating.test.ts | 2 +- packages/effect/test/Stream/scoping.test.ts | 6 +- .../effect/test/Stream/sequencing.test.ts | 10 +- packages/effect/test/Stream/tapping.test.ts | 2 +- .../effect/test/Stream/throttling.test.ts | 2 +- packages/effect/test/TMap.test.ts | 4 +- .../test/utils/cache/ObservableResource.ts | 2 +- .../test/utils/cache/WatchableLookup.ts | 2 +- packages/effect/test/utils/coordination.ts | 4 +- packages/effect/test/utils/latch.ts | 4 +- packages/experimental/src/DevTools/Client.ts | 2 +- packages/experimental/src/Machine.ts | 12 +- packages/experimental/src/Persistence.ts | 2 +- packages/experimental/src/TimeToLive.ts | 4 +- packages/opentelemetry/src/NodeSdk.ts | 4 +- packages/opentelemetry/src/WebSdk.ts | 4 +- .../platform-browser/src/internal/runtime.ts | 2 +- .../src/internal/workerRunner.ts | 2 +- .../platform-bun/src/internal/http/server.ts | 4 +- packages/platform-bun/src/internal/worker.ts | 2 +- .../platform-bun/src/internal/workerRunner.ts | 2 +- .../platform-node-shared/src/NodeSocket.ts | 6 +- .../src/internal/commandExecutor.ts | 10 +- .../src/internal/fileSystem.ts | 4 +- .../src/internal/runtime.ts | 2 +- .../platform-node-shared/src/internal/sink.ts | 2 +- .../src/internal/stream.ts | 20 +- .../src/internal/terminal.ts | 2 +- .../platform-node/src/internal/http/client.ts | 2 +- .../platform-node/src/internal/http/server.ts | 18 +- packages/platform-node/src/internal/worker.ts | 2 +- .../src/internal/workerRunner.ts | 2 +- packages/platform/src/Http/App.ts | 4 +- packages/platform/src/Http/Router.ts | 40 ++-- packages/platform/src/Socket.ts | 12 +- packages/platform/src/Transferable.ts | 2 +- packages/platform/src/internal/fileSystem.ts | 4 +- .../platform/src/internal/http/middleware.ts | 2 +- .../platform/src/internal/http/multipart.ts | 8 +- packages/platform/src/internal/http/router.ts | 38 ++-- packages/platform/src/internal/worker.ts | 10 +- .../platform/src/internal/workerRunner.ts | 4 +- packages/schema/src/ParseResult.ts | 24 +-- packages/schema/test/Schema/parseJson.test.ts | 4 +- packages/typeclass/src/Covariant.ts | 2 +- packages/typeclass/src/Of.ts | 11 +- packages/typeclass/test/Covariant.test.ts | 8 +- packages/typeclass/test/Of.test.ts | 2 +- 137 files changed, 772 insertions(+), 700 deletions(-) create mode 100644 .changeset/six-ears-beam.md diff --git a/.changeset/six-ears-beam.md b/.changeset/six-ears-beam.md new file mode 100644 index 0000000000..bd67a6e2b5 --- /dev/null +++ b/.changeset/six-ears-beam.md @@ -0,0 +1,29 @@ +--- +"@effect/platform-node-shared": minor +"@effect/platform-browser": minor +"@effect/opentelemetry": minor +"@effect/platform-node": minor +"@effect/experimental": minor +"@effect/platform-bun": minor +"@effect/typeclass": minor +"@effect/platform": minor +"effect": minor +"@effect/schema": minor +"@effect/cli": minor +"@effect/printer": minor +"@effect/printer-ansi": minor +"@effect/rpc": minor +"@effect/rpc-http": minor +"@effect/vitest": minor +--- + +replace use of `unit` terminology with `void` + +For all the data types. + +```ts +Effect.unit; // => Effect.void +Stream.unit; // => Stream.void + +// etc +``` diff --git a/packages/cli/src/internal/cliApp.ts b/packages/cli/src/internal/cliApp.ts index 2fa658d527..53d901ffdb 100644 --- a/packages/cli/src/internal/cliApp.ts +++ b/packages/cli/src/internal/cliApp.ts @@ -252,7 +252,7 @@ const handleBuiltInOption = ( ) return shouldRunCommand ? Console.log().pipe(Effect.zipRight(run(self, finalArgs, execute))) - : Effect.unit + : Effect.void })) ), Effect.catchAll((e) => { diff --git a/packages/cli/src/internal/options.ts b/packages/cli/src/internal/options.ts index 3e3fe82db7..f6756fbd83 100644 --- a/packages/cli/src/internal/options.ts +++ b/packages/cli/src/internal/options.ts @@ -1158,7 +1158,7 @@ const parseInternal = ( > => { switch (self._tag) { case "Empty": { - return Effect.unit + return Effect.void } case "Single": { const singleNames = ReadonlyArray.filterMap(getNames(self), (name) => HashMap.get(args, name)) diff --git a/packages/cli/src/internal/primitive.ts b/packages/cli/src/internal/primitive.ts index ced88c7b25..2599734634 100644 --- a/packages/cli/src/internal/primitive.ts +++ b/packages/cli/src/internal/primitive.ts @@ -483,7 +483,7 @@ const validatePathExistence = ( if (shouldPathExist === "yes" && !pathExists) { return Effect.fail(`Path '${path}' must exist`) } - return Effect.unit + return Effect.void } const validatePathType = ( @@ -499,7 +499,7 @@ const validatePathType = ( ) return Effect.fail(`Expected path '${path}' to be a regular file`).pipe( Effect.unlessEffect(checkIsFile), - Effect.asUnit + Effect.asVoid ) } case "directory": { @@ -509,11 +509,11 @@ const validatePathType = ( ) return Effect.fail(`Expected path '${path}' to be a directory`).pipe( Effect.unlessEffect(checkIsDirectory), - Effect.asUnit + Effect.asVoid ) } case "either": { - return Effect.unit + return Effect.void } } } diff --git a/packages/cli/test/services/MockConsole.ts b/packages/cli/test/services/MockConsole.ts index 6254a75d7f..37b7d874e4 100644 --- a/packages/cli/test/services/MockConsole.ts +++ b/packages/cli/test/services/MockConsole.ts @@ -42,23 +42,23 @@ export const make = Effect.gen(function*(_) { getLines, log, unsafe: globalThis.console, - assert: () => Effect.unit, - clear: Effect.unit, - count: () => Effect.unit, - countReset: () => Effect.unit, - debug: () => Effect.unit, - dir: () => Effect.unit, - dirxml: () => Effect.unit, - error: () => Effect.unit, - group: () => Effect.unit, - groupEnd: Effect.unit, - info: () => Effect.unit, - table: () => Effect.unit, - time: () => Effect.unit, - timeEnd: () => Effect.unit, - timeLog: () => Effect.unit, - trace: () => Effect.unit, - warn: () => Effect.unit + assert: () => Effect.void, + clear: Effect.void, + count: () => Effect.void, + countReset: () => Effect.void, + debug: () => Effect.void, + dir: () => Effect.void, + dirxml: () => Effect.void, + error: () => Effect.void, + group: () => Effect.void, + groupEnd: Effect.void, + info: () => Effect.void, + table: () => Effect.void, + time: () => Effect.void, + timeEnd: () => Effect.void, + timeLog: () => Effect.void, + trace: () => Effect.void, + warn: () => Effect.void }) }) diff --git a/packages/cli/test/services/MockTerminal.ts b/packages/cli/test/services/MockTerminal.ts index 104f385909..3a162bb6e1 100644 --- a/packages/cli/test/services/MockTerminal.ts +++ b/packages/cli/test/services/MockTerminal.ts @@ -47,7 +47,7 @@ export const make = Effect.gen(function*(_) { const inputText: MockTerminal["inputText"] = (text: string) => { const inputs = ReadonlyArray.map(text.split(""), (key) => toUserInput(key)) - return Queue.offerAll(queue, inputs).pipe(Effect.asUnit) + return Queue.offerAll(queue, inputs).pipe(Effect.asVoid) } const inputKey: MockTerminal["inputKey"] = ( @@ -55,7 +55,7 @@ export const make = Effect.gen(function*(_) { modifiers?: Partial ) => { const input = toUserInput(key, modifiers) - return Queue.offer(queue, input).pipe(Effect.asUnit) + return Queue.offer(queue, input).pipe(Effect.asVoid) } const display: MockTerminal["display"] = (input) => Console.log(input) diff --git a/packages/effect/src/Channel.ts b/packages/effect/src/Channel.ts index 16091f0b0e..8137552c60 100644 --- a/packages/effect/src/Channel.ts +++ b/packages/effect/src/Channel.ts @@ -236,9 +236,9 @@ export const as: { * @since 2.0.0 * @category mapping */ -export const asUnit: ( +export const asVoid: ( self: Channel -) => Channel = channel.asUnit +) => Channel = channel.asVoid /** * Creates a channel backed by a buffer. When the buffer is empty, the channel @@ -2049,11 +2049,14 @@ export const toStream: ( self: Channel, unknown, OutErr, unknown, OutDone, unknown, Env> ) => Stream.Stream = stream.channelToStream -/** - * @since 2.0.0 - * @category constructors - */ -export const unit: Channel = core.unit +const void_: Channel = core.void +export { + /** + * @since 2.0.0 + * @category constructors + */ + void_ as void +} /** * Makes a channel from an effect that returns a channel in case of success. diff --git a/packages/effect/src/Effect.ts b/packages/effect/src/Effect.ts index 983172e17e..0b0df2b5e1 100644 --- a/packages/effect/src/Effect.ts +++ b/packages/effect/src/Effect.ts @@ -1466,11 +1466,14 @@ export const suspend: (effect: LazyArg>) => Effect(evaluate: LazyArg) => Effect = core.sync -/** - * @since 2.0.0 - * @category constructors - */ -export const unit: Effect = core.unit +const _void: Effect = core.void +export { + /** + * @since 2.0.0 + * @category constructors + */ + _void as void +} /** * @since 2.0.0 @@ -2103,7 +2106,7 @@ export const asSomeError: (self: Effect) => Effect(self: Effect) => Effect = core.asUnit +export const asVoid: (self: Effect) => Effect = core.asVoid /** * Returns an effect that swaps the error/success cases. This allows you to diff --git a/packages/effect/src/Exit.ts b/packages/effect/src/Exit.ts index f8c0772308..fb5e028b2c 100644 --- a/packages/effect/src/Exit.ts +++ b/packages/effect/src/Exit.ts @@ -127,7 +127,7 @@ export const as: { * @since 2.0.0 * @category mapping */ -export const asUnit: (self: Exit) => Exit = core.exitAsUnit +export const asVoid: (self: Exit) => Exit = core.exitAsVoid /** * Returns a `Some>` if the specified exit is a `Failure`, `None` @@ -357,13 +357,16 @@ export const matchEffect: { */ export const succeed: (value: A) => Exit = core.exitSucceed -/** - * Represents an `Exit` which succeeds with `undefined`. - * - * @since 2.0.0 - * @category constructors - */ -export const unit: Exit = core.exitUnit +const void_: Exit = core.exitVoid +export { + /** + * Represents an `Exit` which succeeds with `undefined`. + * + * @since 2.0.0 + * @category constructors + */ + void_ as void +} /** * Sequentially zips the this result with the specified result or else returns diff --git a/packages/effect/src/Fiber.ts b/packages/effect/src/Fiber.ts index 4aae066b15..d7df138b35 100644 --- a/packages/effect/src/Fiber.ts +++ b/packages/effect/src/Fiber.ts @@ -602,13 +602,16 @@ export const status: (self: RuntimeFiber) => Effect.Effect(value: A) => Fiber = internal.succeed -/** - * A fiber that has already succeeded with unit. - * - * @since 2.0.0 - * @category constructors - */ -export const unit: Fiber = internal.unit +const void_: Fiber = internal.void +export { + /** + * A fiber that has already succeeded with unit. + * + * @since 2.0.0 + * @category constructors + */ + void_ as void +} /** * Zips this fiber and the specified fiber together, producing a tuple of diff --git a/packages/effect/src/FiberMap.ts b/packages/effect/src/FiberMap.ts index db8cdac57c..353c8580cc 100644 --- a/packages/effect/src/FiberMap.ts +++ b/packages/effect/src/FiberMap.ts @@ -280,7 +280,7 @@ export const remove: { Effect.suspend(() => { const fiber = MutableHashMap.get(self.backing, key) if (fiber._tag === "None") { - return Effect.unit + return Effect.void } MutableHashMap.remove(self.backing, key) return Fiber.interrupt(fiber.value) diff --git a/packages/effect/src/Option.ts b/packages/effect/src/Option.ts index 0361fccf08..2a8dd586c4 100644 --- a/packages/effect/src/Option.ts +++ b/packages/effect/src/Option.ts @@ -629,12 +629,15 @@ export const as: { * @category mapping * @since 2.0.0 */ -export const asUnit: <_>(self: Option<_>) => Option = as(undefined) +export const asVoid: <_>(self: Option<_>) => Option = as(undefined) -/** - * @since 2.0.0 - */ -export const unit: Option = some(undefined) +const void_: Option = some(undefined) +export { + /** + * @since 2.0.0 + */ + void_ as void +} /** * Applies a function to the value of an `Option` and flattens the result, if the input is `Some`. diff --git a/packages/effect/src/STM.ts b/packages/effect/src/STM.ts index 05aca0137e..328fa04c59 100644 --- a/packages/effect/src/STM.ts +++ b/packages/effect/src/STM.ts @@ -295,7 +295,7 @@ export const asSomeError: (self: STM) => STM(self: STM) => STM = stm.asUnit +export const asVoid: (self: STM) => STM = stm.asVoid /** * Creates an `STM` value from a partial (but pure) function. @@ -1860,13 +1860,16 @@ export const unlessSTM: { */ export const unsome: (self: STM, R>) => STM, E, R> = stm.unsome -/** - * Returns an `STM` effect that succeeds with `Unit`. - * - * @since 2.0.0 - * @category constructors - */ -export const unit: STM = stm.unit +const void_: STM = stm.void +export { + /** + * Returns an `STM` effect that succeeds with `void`. + * + * @since 2.0.0 + * @category constructors + */ + void_ as void +} /** * Feeds elements of type `A` to `f` and accumulates all errors in error diff --git a/packages/effect/src/Schedule.ts b/packages/effect/src/Schedule.ts index 9e478fe67d..9a54b42644 100644 --- a/packages/effect/src/Schedule.ts +++ b/packages/effect/src/Schedule.ts @@ -218,7 +218,7 @@ export const as: { * @since 2.0.0 * @category constructors */ -export const asUnit: (self: Schedule) => Schedule = internal.asUnit +export const asVoid: (self: Schedule) => Schedule = internal.asVoid /** * Returns a new schedule that has both the inputs and outputs of this and the diff --git a/packages/effect/src/Stream.ts b/packages/effect/src/Stream.ts index 5b8e41fc0f..906f63c786 100644 --- a/packages/effect/src/Stream.ts +++ b/packages/effect/src/Stream.ts @@ -3707,7 +3707,7 @@ export const throttleEffect: { } = internal.throttleEffect /** - * A stream that emits Unit values spaced by the specified duration. + * A stream that emits void values spaced by the specified duration. * * @since 2.0.0 * @category constructors @@ -3915,13 +3915,16 @@ export const unfoldEffect: ( f: (s: S) => Effect.Effect, E, R> ) => Stream = internal.unfoldEffect -/** - * A stream that contains a single `Unit` value. - * - * @since 2.0.0 - * @category constructors - */ -export const unit: Stream = internal.unit +const void_: Stream = internal.void +export { + /** + * A stream that contains a single `void` value. + * + * @since 2.0.0 + * @category constructors + */ + void_ as void +} /** * Creates a stream produced from an `Effect`. diff --git a/packages/effect/src/TestClock.ts b/packages/effect/src/TestClock.ts index 775ef5e440..238107a61d 100644 --- a/packages/effect/src/TestClock.ts +++ b/packages/effect/src/TestClock.ts @@ -209,7 +209,7 @@ export class TestClockImpl implements TestClock { core.flatMap((shouldAwait) => shouldAwait ? pipe(this.warningStart(), core.zipRight(core.deferredAwait(deferred))) : - pipe(core.deferredSucceed(deferred, void 0), core.asUnit) + pipe(core.deferredSucceed(deferred, void 0), core.asVoid) ) )) } @@ -250,7 +250,7 @@ export class TestClockImpl implements TestClock { } /** * Captures a "snapshot" of the identifier and status of all fibers in this - * test other than the current fiber. Fails with the `Unit` value if any of + * test other than the current fiber. Fails with the `void` value if any of * these fibers are not done or suspended. Note that because we cannot * synchronize on the status of multiple fibers at the same time this * snapshot may not be fully consistent. @@ -409,7 +409,7 @@ export class TestClockImpl implements TestClock { core.flatMap((option) => { switch (option._tag) { case "None": { - return core.unit + return core.void } case "Some": { const [end, deferred] = option.value diff --git a/packages/effect/src/internal/cache.ts b/packages/effect/src/internal/cache.ts index a54c7feabf..a062dfbd1b 100644 --- a/packages/effect/src/internal/cache.ts +++ b/packages/effect/src/internal/cache.ts @@ -443,7 +443,7 @@ class CacheImpl implements Cache.Cache implements Cache.Cache implements Cache.Cache) => Effect.Effect - >(() => Effect.unit) + >(() => Effect.void) ), (ref) => pipe( @@ -78,7 +78,7 @@ export const as = dual< ): Channel.Channel => map(self, () => value)) /** @internal */ -export const asUnit = ( +export const asVoid = ( self: Channel.Channel ): Channel.Channel => map(self, constVoid) @@ -931,8 +931,8 @@ export const mapOutEffectPar = dual< onLeft: (outDone) => { const lock = withPermits(n) return Effect.zipRight( - Effect.interruptible(lock(Effect.unit)), - Effect.asUnit(Queue.offer( + Effect.interruptible(lock(Effect.void)), + Effect.asVoid(Queue.offer( queue, Effect.succeed(Either.left(outDone)) )) @@ -942,7 +942,7 @@ export const mapOutEffectPar = dual< Effect.gen(function*($) { const deferred = yield* $(Deferred.make()) const latch = yield* $(Deferred.make()) - yield* $(Effect.asUnit(Queue.offer( + yield* $(Effect.asVoid(Queue.offer( queue, Effect.map(Deferred.await(deferred), Either.right) ))) @@ -1189,7 +1189,7 @@ export const mergeAllWith = ( pipe( Queue.offer(queue, Effect.failCause(cause)), Effect.zipRight(Deferred.succeed(errorSignal, void 0)), - Effect.asUnit + Effect.asVoid ) ) ) @@ -1204,7 +1204,7 @@ export const mergeAllWith = ( onLeft: (outDone) => Effect.raceWith( Effect.interruptible(Deferred.await(errorSignal)), - Effect.interruptible(withPermits(concurrencyN)(Effect.unit)), + Effect.interruptible(withPermits(concurrencyN)(Effect.void)), { onSelfDone: (_, permitAcquisition) => Effect.as(Fiber.interrupt(permitAcquisition), false), onOtherDone: (_, failureAwait) => @@ -2211,7 +2211,7 @@ export const toPull = ( Effect.sync(() => new executor.ChannelExecutor(self, void 0, identity)), (exec, exit) => { const finalize = exec.close(exit) - return finalize === undefined ? Effect.unit : finalize + return finalize === undefined ? Effect.void : finalize } ), (exec) => Effect.suspend(() => interpretToPull(exec.run() as ChannelState.ChannelState, exec)) @@ -2363,7 +2363,7 @@ const writeChunkWriter = ( chunk: Chunk.Chunk ): Channel.Channel => { return idx === len - ? core.unit + ? core.void : pipe( core.write(pipe(chunk, Chunk.unsafeGet(idx))), core.flatMap(() => writeChunkWriter(idx + 1, len, chunk)) diff --git a/packages/effect/src/internal/channel/channelExecutor.ts b/packages/effect/src/internal/channel/channelExecutor.ts index 1b57232dc6..9ef5a828bb 100644 --- a/packages/effect/src/internal/channel/channelExecutor.ts +++ b/packages/effect/src/internal/channel/channelExecutor.ts @@ -162,7 +162,7 @@ export class ChannelExecutor< Effect.flatMap(Fiber.interrupt(fiber), () => Effect.suspend(() => { const effect = this.restorePipe(exit, inputExecutor) - return effect !== undefined ? effect : Effect.unit + return effect !== undefined ? effect : Effect.void })) ) ) @@ -188,7 +188,7 @@ export class ChannelExecutor< (effect) => Effect.sync(() => { const prevLastClose = this._closeLastSubstream === undefined - ? Effect.unit + ? Effect.void : this._closeLastSubstream this._closeLastSubstream = pipe(prevLastClose, Effect.zipRight(effect)) }) @@ -217,7 +217,7 @@ export class ChannelExecutor< this._emitted = this._currentChannel.out this._currentChannel = (this._activeSubexecutor !== undefined ? undefined : - core.unit) as core.Primitive | undefined + core.void) as core.Primitive | undefined result = ChannelState.Emit() break } @@ -252,13 +252,13 @@ export class ChannelExecutor< const state = this.doneHalt(cause) return state !== undefined && ChannelState.isFromEffect(state) ? state.effect : - Effect.unit + Effect.void }, onSuccess: (value) => { const state = this.doneSucceed(value) return state !== undefined && ChannelState.isFromEffect(state) ? state.effect : - Effect.unit + Effect.void } }) ) as ChannelState.ChannelState | undefined @@ -279,7 +279,7 @@ export class ChannelExecutor< this.addFinalizer((exit) => { const effect = this.restorePipe(exit, previousInput) - return effect !== undefined ? effect : Effect.unit + return effect !== undefined ? effect : Effect.void }) this._currentChannel = this._currentChannel.right() as core.Primitive @@ -382,7 +382,7 @@ export class ChannelExecutor< } next = this._doneStack.pop() as Continuation.Primitive | undefined } - const effect = (finalizers.length === 0 ? Effect.unit : runFinalizers(finalizers, exit)) as Effect.Effect< + const effect = (finalizers.length === 0 ? Effect.void : runFinalizers(finalizers, exit)) as Effect.Effect< unknown, never, Env @@ -414,7 +414,7 @@ export class ChannelExecutor< const effect = currInput.close(exit) return effect } - return Effect.unit + return Effect.void } close(exit: Exit.Exit): Effect.Effect | undefined { @@ -608,7 +608,7 @@ export class ChannelExecutor< }) this._activeSubexecutor = undefined return state === undefined ? - Effect.unit : + Effect.void : ChannelState.effect(state) } @@ -622,7 +622,7 @@ export class ChannelExecutor< Effect.forEach((closeFunc) => pipe( Effect.sync(() => closeFunc(subexecutorDone)), - Effect.flatMap((closeEffect) => closeEffect !== undefined ? closeEffect : Effect.unit) + Effect.flatMap((closeEffect) => closeEffect !== undefined ? closeEffect : Effect.void) ), { discard: true }) ) ) @@ -802,7 +802,7 @@ export class ChannelExecutor< return ChannelState.Read( subexecutor.upstreamExecutor, (effect) => { - const closeLastSubstream = this._closeLastSubstream === undefined ? Effect.unit : this._closeLastSubstream + const closeLastSubstream = this._closeLastSubstream === undefined ? Effect.void : this._closeLastSubstream this._closeLastSubstream = undefined return pipe( this._executeCloseLastSubstream(closeLastSubstream), @@ -999,7 +999,7 @@ export class ChannelExecutor< } const ifNotNull = (effect: Effect.Effect | undefined): Effect.Effect => - effect !== undefined ? effect : Effect.unit + effect !== undefined ? effect : Effect.void const runFinalizers = ( finalizers: Array>, @@ -1007,7 +1007,7 @@ const runFinalizers = ( ): Effect.Effect => { return pipe( Effect.forEach(finalizers, (fin) => Effect.exit(fin(exit))), - Effect.map((exits) => pipe(Exit.all(exits), Option.getOrElse(() => Exit.unit))), + Effect.map((exits) => pipe(Exit.all(exits), Option.getOrElse(() => Exit.void))), Effect.flatMap((exit) => Effect.suspend(() => exit as Exit.Exit)) ) } @@ -1075,7 +1075,7 @@ export const readUpstream = ( Effect.catchAllCause((cause) => Effect.suspend(() => { const doneEffect = current.onDone(Exit.failCause(cause)) as Effect.Effect - return doneEffect === undefined ? Effect.unit : doneEffect + return doneEffect === undefined ? Effect.void : doneEffect }) ), Effect.matchCauseEffect({ onFailure, onSuccess: () => read() }) @@ -1120,7 +1120,7 @@ export const runScoped = ( (exec, exit) => { const finalize = exec.close(exit) if (finalize === undefined) { - return Effect.unit + return Effect.void } return Effect.tapErrorCause( finalize, diff --git a/packages/effect/src/internal/channel/channelState.ts b/packages/effect/src/internal/channel/channelState.ts index ddc72f2a4d..20c425bc55 100644 --- a/packages/effect/src/internal/channel/channelState.ts +++ b/packages/effect/src/internal/channel/channelState.ts @@ -127,7 +127,7 @@ export const isRead = (self: ChannelState): self is Read => (self as /** @internal */ export const effect = (self: ChannelState): Effect.Effect => - isFromEffect(self) ? self.effect as Effect.Effect : Effect.unit + isFromEffect(self) ? self.effect as Effect.Effect : Effect.void /** @internal */ export const effectOrUndefinedIgnored = (self: ChannelState): Effect.Effect | undefined => diff --git a/packages/effect/src/internal/channel/singleProducerAsyncInput.ts b/packages/effect/src/internal/channel/singleProducerAsyncInput.ts index 260c54c938..17d1196091 100644 --- a/packages/effect/src/internal/channel/singleProducerAsyncInput.ts +++ b/packages/effect/src/internal/channel/singleProducerAsyncInput.ts @@ -100,7 +100,7 @@ class SingleProducerAsyncInputImpl Ref.modify(this.ref, (state) => state._tag === OP_STATE_EMPTY ? [Deferred.await(state.notifyProducer), state as State] : - [Effect.unit, state]) + [Effect.void, state]) ) } diff --git a/packages/effect/src/internal/clock.ts b/packages/effect/src/internal/clock.ts index 80cd809b1c..a4ff48147e 100644 --- a/packages/effect/src/internal/clock.ts +++ b/packages/effect/src/internal/clock.ts @@ -85,8 +85,8 @@ class ClockImpl implements Clock.Clock { sleep(duration: Duration.Duration): Effect.Effect { return core.async((resume) => { - const canceler = globalClockScheduler.unsafeSchedule(() => resume(core.unit), duration) - return core.asUnit(core.sync(canceler)) + const canceler = globalClockScheduler.unsafeSchedule(() => resume(core.void), duration) + return core.asVoid(core.sync(canceler)) }) } } diff --git a/packages/effect/src/internal/core-effect.ts b/packages/effect/src/internal/core-effect.ts index 1799cd649a..1b87889703 100644 --- a/packages/effect/src/internal/core-effect.ts +++ b/packages/effect/src/internal/core-effect.ts @@ -343,7 +343,7 @@ export const allowInterrupt: Effect.Effect = descriptorWith( (descriptor) => HashSet.size(descriptor.interruptors) > 0 ? core.interrupt - : core.unit + : core.void ) /* @internal */ @@ -842,7 +842,7 @@ export const ignore = (self: Effect.Effect): Effect.Effect(self: Effect.Effect): Effect.Effect => core.matchCauseEffect(self, { onFailure: (cause) => logDebug(cause, "An error was silently ignored because it is not anticipated to be useful"), - onSuccess: () => core.unit + onSuccess: () => core.void }) /* @internal */ @@ -916,7 +916,7 @@ export const logWithLevel = (level?: LogLevel.LogLevel) => } return core.withFiberRuntime((fiberState) => { fiberState.log(message, cause, levelOption) - return core.unit + return core.void }) } @@ -1050,7 +1050,7 @@ const loopDiscard = ( body(initial), () => loopDiscard(inc(initial), cont, inc, body) ) - : core.unit + : core.void ) /* @internal */ @@ -1146,7 +1146,7 @@ export const none = ( core.flatMap(self, (option) => { switch (option._tag) { case "None": - return core.unit + return core.void case "Some": return core.fail(new core.NoSuchElementException()) } @@ -1158,7 +1158,7 @@ export const once = ( ): Effect.Effect> => core.map( Ref.make(true), - (ref) => core.asUnit(core.whenEffect(self, Ref.getAndSet(ref, false))) + (ref) => core.asVoid(core.whenEffect(self, Ref.getAndSet(ref, false))) ) /* @internal */ @@ -1596,7 +1596,7 @@ export const tapErrorTag = dual< if (Predicate.isTagged(e, k)) { return f(e as any) } - return core.unit as any + return core.void as any })) /* @internal */ @@ -1779,7 +1779,7 @@ export const updateFiberRefs = ( ): Effect.Effect => core.withFiberRuntime((state) => { state.setFiberRefs(f(state.id(), state.getFiberRefs())) - return core.unit + return core.void }) /* @internal */ @@ -2048,7 +2048,7 @@ export const unsafeMakeSpan = ( options?: { readonly attributes?: Record | undefined readonly links?: ReadonlyArray | undefined - readonly parent?: Tracer.ParentSpan | undefined + readonly parent?: Tracer.AnySpan | undefined readonly root?: boolean | undefined readonly context?: Context.Context | undefined } diff --git a/packages/effect/src/internal/core-stream.ts b/packages/effect/src/internal/core-stream.ts index 30f076e7c4..ebec63ff5c 100644 --- a/packages/effect/src/internal/core-stream.ts +++ b/packages/effect/src/internal/core-stream.ts @@ -981,8 +981,11 @@ export const sync = ( return op } -/** @internal */ -export const unit: Channel.Channel = succeedNow(void 0) +const void_: Channel.Channel = succeedNow(void 0) +export { + /** @internal */ + void_ as void +} /** @internal */ export const write = ( diff --git a/packages/effect/src/internal/core.ts b/packages/effect/src/internal/core.ts index 9961a596bc..24855c0194 100644 --- a/packages/effect/src/internal/core.ts +++ b/packages/effect/src/internal/core.ts @@ -430,7 +430,7 @@ export const as: { ) /* @internal */ -export const asUnit = (self: Effect.Effect): Effect.Effect => as(self, void 0) +export const asVoid = (self: Effect.Effect): Effect.Effect => as(self, void 0) /* @internal */ export const custom: { @@ -515,7 +515,7 @@ export const async = ( if (controllerRef) { controllerRef.abort() } - return cancelerRef ?? unit + return cancelerRef ?? void_ }) : effect }) @@ -1063,7 +1063,7 @@ export const onError: { self: Effect.Effect, cleanup: (cause: Cause.Cause) => Effect.Effect ): Effect.Effect => - onExit(self, (exit) => exitIsSuccess(exit) ? unit : cleanup(exit.effect_instruction_i0))) + onExit(self, (exit) => exitIsSuccess(exit) ? void_ : cleanup(exit.effect_instruction_i0))) /* @internal */ export const onExit: { @@ -1112,9 +1112,9 @@ export const onInterrupt: { exitMatch({ onFailure: (cause) => internalCause.isInterruptedOnly(cause) - ? asUnit(cleanup(internalCause.interruptors(cause))) - : unit, - onSuccess: () => unit + ? asVoid(cleanup(internalCause.interruptors(cause))) + : void_, + onSuccess: () => void_ }) )) @@ -1300,8 +1300,11 @@ export const uninterruptibleMask = ( return effect }) -/* @internal */ -export const unit: Effect.Effect = succeed(void 0) +const void_: Effect.Effect = succeed(void 0) +export { + /* @internal */ + void_ as void +} /* @internal */ export const updateRuntimeFlags = (patch: RuntimeFlagsPatch.RuntimeFlagsPatch): Effect.Effect => { @@ -1666,7 +1669,7 @@ export const fiberRefSet = dual< export const fiberRefDelete = (self: FiberRef.FiberRef): Effect.Effect => withFiberRuntime((state) => { state.unsafeDeleteFiberRef(self) - return unit + return void_ }) /* @internal */ @@ -2065,7 +2068,7 @@ export const CloseableScopeTypeId: Scope.CloseableScopeTypeId = Symbol.for( export const scopeAddFinalizer = ( self: Scope.Scope, finalizer: Effect.Effect -): Effect.Effect => self.addFinalizer(() => asUnit(finalizer)) +): Effect.Effect => self.addFinalizer(() => asVoid(finalizer)) /* @internal */ export const scopeAddFinalizerExit = ( @@ -2308,7 +2311,7 @@ export const exitAs = dual< }) /** @internal */ -export const exitAsUnit = (self: Exit.Exit): Exit.Exit => exitAs(self, void 0) +export const exitAsVoid = (self: Exit.Exit): Exit.Exit => exitAs(self, void 0) /** @internal */ export const exitCauseOption = (self: Exit.Exit): Option.Option> => { @@ -2576,7 +2579,7 @@ export const exitSucceed = (value: A): Exit.Exit => { } /** @internal */ -export const exitUnit: Exit.Exit = exitSucceed(void 0) +export const exitVoid: Exit.Exit = exitSucceed(void 0) /** @internal */ export const exitZip = dual< @@ -2964,7 +2967,7 @@ const NoopSpanProto: Tracer.Span = { _tag: "Ended", startTime: BigInt(0), endTime: BigInt(0), - exit: exitUnit + exit: exitVoid }, attributes: new Map(), links: [], diff --git a/packages/effect/src/internal/dataSource.ts b/packages/effect/src/internal/dataSource.ts index 188b37c89d..23f5209343 100644 --- a/packages/effect/src/internal/dataSource.ts +++ b/packages/effect/src/internal/dataSource.ts @@ -32,18 +32,18 @@ export const makeBatched = , R>( return core.forEachSequentialDiscard(requests, (block) => { const filtered = block.filter((_) => !_.state.completed).map((_) => _.request) if (filtered.length === 0) { - return core.unit + return core.void } return invokeWithInterrupt(run(filtered), block) }) } else if (requests.length === 1) { const filtered = requests[0].filter((_) => !_.state.completed).map((_) => _.request) if (filtered.length === 0) { - return core.unit + return core.void } return run(filtered) } - return core.unit + return core.void } ) diff --git a/packages/effect/src/internal/effect/circular.ts b/packages/effect/src/internal/effect/circular.ts index ced3c79bfd..1bfcb66712 100644 --- a/packages/effect/src/internal/effect/circular.ts +++ b/packages/effect/src/internal/effect/circular.ts @@ -289,8 +289,8 @@ export const forkIn = dual< child.addFinalizer(() => core.fiberIdWith((fiberId) => Equal.equals(fiberId, fiber.id()) ? - core.unit : - core.asUnit(core.interruptFiber(fiber)) + core.void : + core.asVoid(core.interruptFiber(fiber)) ) ) ) diff --git a/packages/effect/src/internal/fiber.ts b/packages/effect/src/internal/fiber.ts index 1b9364cbf3..5f4e1a88a2 100644 --- a/packages/effect/src/internal/fiber.ts +++ b/packages/effect/src/internal/fiber.ts @@ -81,9 +81,9 @@ export const done = (exit: Exit.Exit): Fiber.Fiber => ({ id: () => FiberId.none, await: core.succeed(exit), children: core.succeed([]), - inheritAll: core.unit, + inheritAll: core.void, poll: core.succeed(Option.some(exit)), - interruptAsFork: () => core.unit + interruptAsFork: () => core.void }) /** @internal */ @@ -254,7 +254,7 @@ export const orElse = dual< pipe( core.interruptAsFiber(self, id), core.zipRight(pipe(that, core.interruptAsFiber(id))), - core.asUnit + core.asVoid ) })) @@ -334,8 +334,11 @@ export const status = (self: Fiber.RuntimeFiber): Effect.Effect(value: A): Fiber.Fiber => done(Exit.succeed(value)) -/** @internal */ -export const unit: Fiber.Fiber = succeed(void 0) +const void_: Fiber.Fiber = succeed(void 0) +export { + /** @internal */ + void_ as void +} /** @internal */ export const currentFiberURI = "effect/FiberCurrent" diff --git a/packages/effect/src/internal/fiberRuntime.ts b/packages/effect/src/internal/fiberRuntime.ts index fb2906dde6..44d461966e 100644 --- a/packages/effect/src/internal/fiberRuntime.ts +++ b/packages/effect/src/internal/fiberRuntime.ts @@ -184,7 +184,7 @@ const contOpSuccess = { self.pushStack(cont) return cont.effect_instruction_i1() } else { - return core.unit + return core.void } } } @@ -743,7 +743,7 @@ export class FiberRuntime implements Fiber.RuntimeFi const body = () => { const next = it.next() if (!next.done) { - return core.asUnit(next.value.await) + return core.asVoid(next.value.await) } else { return core.sync(() => { isDone = true @@ -895,10 +895,10 @@ export class FiberRuntime implements Fiber.RuntimeFi if (op._op === OpCodes.OP_YIELD) { if (_runtimeFlags.cooperativeYielding(this._runtimeFlags)) { this.tell(FiberMessage.yieldNow()) - this.tell(FiberMessage.resume(core.exitUnit)) + this.tell(FiberMessage.resume(core.exitVoid)) effect = null } else { - effect = core.exitUnit + effect = core.exitVoid } } else if (op._op === OpCodes.OP_ASYNC) { // Terminate this evaluation, async resumption will continue evaluation: @@ -1209,7 +1209,7 @@ export class FiberRuntime implements Fiber.RuntimeFi this.pushStack(new core.RevertFlags(revertFlags, op)) return op.effect_instruction_i1(oldRuntimeFlags) } else { - return core.exitUnit + return core.exitVoid } } } @@ -1254,7 +1254,7 @@ export class FiberRuntime implements Fiber.RuntimeFi this.pushStack(op) return body() } else { - return core.exitUnit + return core.exitVoid } } @@ -1477,7 +1477,7 @@ export const batchedLogger = dual< let buffer: Array = [] const flush = core.suspend(() => { if (buffer.length === 0) { - return core.unit + return core.void } const arr = buffer buffer = [] @@ -1597,7 +1597,7 @@ export const exists: { core.matchEffect( forEach( elements, - (a, i) => core.if_(f(a, i), { onTrue: () => core.fail(_existsParFound), onFalse: () => core.unit }), + (a, i) => core.if_(f(a, i), { onTrue: () => core.fail(_existsParFound), onFalse: () => core.void }), options ), { @@ -1735,7 +1735,7 @@ const allValidate = ( core.fail(reconcile.value(errors)) : core.fail(errors) } else if (options?.discard) { - return core.unit + return core.void } return reconcile._tag === "Some" ? core.succeed(reconcile.value(successes)) : @@ -1996,7 +1996,7 @@ export const forEachConcurrentDiscard = ( let todos = Array.from(self).reverse() let target = todos.length if (target === 0) { - return core.unit + return core.void } let counter = 0 let interrupted = false @@ -2018,7 +2018,7 @@ export const forEachConcurrentDiscard = ( .sort((a, b) => a.index < b.index ? -1 : a.index === b.index ? 0 : 1) .map(({ exit }) => exit) if (exits.length === 0) { - exits.push(core.exitUnit) + exits.push(core.exitVoid) } return exits } @@ -2108,7 +2108,7 @@ export const forEachConcurrentDiscard = ( if (results.length === target) { resume(core.succeed(Option.getOrElse( core.exitCollectAll(collectExits(), { parallel: true }), - () => core.exitUnit + () => core.exitVoid ))) } else if (residual.length + results.length === target) { const requests = residual.map((blocked) => blocked.effect_instruction_i0).reduce(_RequestBlock.par) @@ -2118,7 +2118,7 @@ export const forEachConcurrentDiscard = ( [ Option.getOrElse( core.exitCollectAll(collectExits(), { parallel: true }), - () => core.exitUnit + () => core.exitVoid ), ...residual.map((blocked) => blocked.effect_instruction_i1) ], @@ -2139,7 +2139,7 @@ export const forEachConcurrentDiscard = ( } }) ) - return core.asUnit( + return core.asVoid( core.onExit( core.flatten(restore(internalFiber.join(processingFiber))), core.exitMatch({ @@ -2413,7 +2413,7 @@ export const validateAll = dual< }), ([es, bs]) => es.length === 0 - ? options?.discard ? core.unit : core.succeed(bs) + ? options?.discard ? core.void : core.succeed(bs) : core.fail(es) ) ) @@ -2455,7 +2455,7 @@ export const raceAll: >( core.tap((fibers) => pipe( fibers, - RA.reduce(core.unit, (effect, fiber) => + RA.reduce(core.void, (effect, fiber) => pipe( effect, core.zipRight( @@ -2463,7 +2463,7 @@ export const raceAll: >( internalFiber._await(fiber), core.flatMap(raceAllArbiter(fibers, fiber, done, fails)), fork, - core.asUnit + core.asVoid ) ) )) @@ -2476,7 +2476,7 @@ export const raceAll: >( pipe( fibers, RA.reduce( - core.unit, + core.void, (effect, fiber) => pipe(effect, core.zipLeft(core.interruptFiber(fiber))) ) ) @@ -2506,8 +2506,8 @@ const raceAllArbiter = ( Ref.modify(fails, (fails) => [ fails === 0 ? - pipe(core.deferredFailCause(deferred, cause), core.asUnit) : - core.unit, + pipe(core.deferredFailCause(deferred, cause), core.asVoid) : + core.void, fails - 1 ] as const), core.flatten @@ -2520,14 +2520,14 @@ const raceAllArbiter = ( pipe( Chunk.fromIterable(fibers), RA.reduce( - core.unit, + core.void, (effect, fiber) => fiber === winner ? effect : pipe(effect, core.zipLeft(core.interruptFiber(fiber))) ) ) : - core.unit + core.void ) ) }) @@ -2798,7 +2798,7 @@ export const validateAllParDiscard = dual< partition(elements, f), ([es, _]) => es.length === 0 - ? core.unit + ? core.void : core.fail(es) )) @@ -2971,7 +2971,7 @@ export const withRuntimeFlagsScoped = ( update: RuntimeFlagsPatch.RuntimeFlagsPatch ): Effect.Effect => { if (update === RuntimeFlagsPatch.empty) { - return core.unit + return core.void } return pipe( core.runtimeFlags, @@ -2981,7 +2981,7 @@ export const withRuntimeFlagsScoped = ( return pipe( core.updateRuntimeFlags(update), core.zipRight(addFinalizer(() => core.updateRuntimeFlags(revertRuntimeFlags))), - core.asUnit + core.asVoid ) }), core.uninterruptible @@ -3039,12 +3039,12 @@ const ScopeImplProto: Omit = { close(this: ScopeImpl, exit) { return core.suspend(() => { if (this.state._tag === "Closed") { - return core.unit + return core.void } const finalizers = Array.from(this.state.finalizers.values()).reverse() this.state = { _tag: "Closed", exit } if (finalizers.length === 0) { - return core.unit + return core.void } return executionStrategy.isSequential(this.strategy) ? pipe( @@ -3052,8 +3052,8 @@ const ScopeImplProto: Omit = { core.flatMap((results) => pipe( core.exitCollectAll(results), - Option.map(core.exitAsUnit), - Option.getOrElse(() => core.exitUnit) + Option.map(core.exitAsVoid), + Option.getOrElse(() => core.exitVoid) ) ) ) : @@ -3063,8 +3063,8 @@ const ScopeImplProto: Omit = { core.flatMap((results) => pipe( core.exitCollectAll(results, { parallel: true }), - Option.map(core.exitAsUnit), - Option.getOrElse(() => core.exitUnit) + Option.map(core.exitAsVoid), + Option.getOrElse(() => core.exitVoid) ) ) ) : @@ -3073,8 +3073,8 @@ const ScopeImplProto: Omit = { core.flatMap((results) => pipe( core.exitCollectAll(results, { parallel: true }), - Option.map(core.exitAsUnit), - Option.getOrElse(() => core.exitUnit) + Option.map(core.exitAsVoid), + Option.getOrElse(() => core.exitVoid) ) ) ) @@ -3086,7 +3086,7 @@ const ScopeImplProto: Omit = { return fin(this.state.exit) } this.state.finalizers.add(fin) - return core.unit + return core.void }) } } @@ -3153,7 +3153,7 @@ export const fiberRefLocallyScoped = dual< (value: A) => (self: FiberRef.FiberRef) => Effect.Effect, (self: FiberRef.FiberRef, value: A) => Effect.Effect >(2, (self, value) => - core.asUnit( + core.asVoid( acquireRelease( core.flatMap( core.fiberRefGet(self), @@ -3214,7 +3214,7 @@ export const currentSupervisor: FiberRef.FiberRef> = /* @internal */ export const fiberAwaitAll = (fibers: Iterable>): Effect.Effect => - core.asUnit(internalFiber._await(fiberAll(fibers))) + core.asVoid(internalFiber._await(fiberAll(fibers))) /** @internal */ export const fiberAll = (fibers: Iterable>): Fiber.Fiber, E> => ({ @@ -3260,7 +3260,7 @@ export const fiberAll = (fibers: Iterable>): Fiber.Fiber /* @internal */ export const fiberInterruptFork = (self: Fiber.Fiber): Effect.Effect => - core.asUnit(forkDaemon(core.interruptFiber(self))) + core.asVoid(forkDaemon(core.interruptFiber(self))) /* @internal */ export const fiberJoinAll = (fibers: Iterable>): Effect.Effect, E> => diff --git a/packages/effect/src/internal/groupBy.ts b/packages/effect/src/internal/groupBy.ts index 6f82e7f527..206608bf55 100644 --- a/packages/effect/src/internal/groupBy.ts +++ b/packages/effect/src/internal/groupBy.ts @@ -442,7 +442,7 @@ export const groupByKey = dual< Queue.offer(innerQueue, take.chunk(values)), Effect.catchSomeCause((cause) => Cause.isInterruptedOnly(cause) ? - Option.some(Effect.unit) : + Option.some(Effect.void) : Option.none() ) ) @@ -455,7 +455,7 @@ export const groupByKey = dual< Queue.offer(innerQueue, take.chunk(values)), (cause) => Cause.isInterruptedOnly(cause) ? - Option.some(Effect.unit) : + Option.some(Effect.void) : Option.none() ) }, { discard: true }) @@ -472,7 +472,7 @@ export const groupByKey = dual< Queue.offer(innerQueue, take.end), Effect.catchSomeCause((cause) => Cause.isInterruptedOnly(cause) ? - Option.some(Effect.unit) : + Option.some(Effect.void) : Option.none() ) ), { discard: true }), diff --git a/packages/effect/src/internal/layer.ts b/packages/effect/src/internal/layer.ts index 048bd10a01..52ced6b61d 100644 --- a/packages/effect/src/internal/layer.ts +++ b/packages/effect/src/internal/layer.ts @@ -203,7 +203,7 @@ class MemoMapImpl implements Layer.MemoMap { acquire as Effect.Effect], E>, core.flatMap(([patch, b]) => pipe(effect.patchFiberRefs(patch), core.as(b))), core.onExit(core.exitMatch({ - onFailure: () => core.unit, + onFailure: () => core.void, onSuccess: () => core.scopeAddFinalizerExit(scope, release) })) ) @@ -216,7 +216,7 @@ class MemoMapImpl implements Layer.MemoMap { core.deferredMake], E>(), core.flatMap((deferred) => pipe( - ref.make(() => core.unit), + ref.make(() => core.void), core.map((finalizerRef) => { const resource = core.uninterruptibleMask((restore) => pipe( @@ -245,7 +245,7 @@ class MemoMapImpl implements Layer.MemoMap { core.whenEffect( ref.modify(observers, (n) => [n === 1, n - 1] as const) ), - core.asUnit + core.asVoid )), core.zipRight(ref.update(observers, (n) => n + 1)), core.zipRight( @@ -270,7 +270,7 @@ class MemoMapImpl implements Layer.MemoMap { pipe( core.deferredAwait(deferred), core.onExit(core.exitMatchEffect({ - onFailure: () => core.unit, + onFailure: () => core.void, onSuccess: () => ref.update(observers, (n) => n + 1) })) ), @@ -1197,7 +1197,7 @@ const provideSomeRuntime = dual< core.withFiberRuntime((fiber) => { fiber.setFiberRefs(FiberRefsPatch.patch(fiber.id(), fiber.getFiberRefs())(rollbackRefs)) fiber._runtimeFlags = runtimeFlags.patch(rollbackFlags)(fiber._runtimeFlags) - return core.unit + return core.void }) ) }) diff --git a/packages/effect/src/internal/managedRuntime.ts b/packages/effect/src/internal/managedRuntime.ts index bbdb522734..5df50e6642 100644 --- a/packages/effect/src/internal/managedRuntime.ts +++ b/packages/effect/src/internal/managedRuntime.ts @@ -71,7 +71,7 @@ export const make = ( disposeEffect: core.suspend(() => { ;(self as any).runtime = core.die("ManagedRuntime disposed") self.cachedRuntime = undefined - return Scope.close(self.scope, core.exitUnit) + return Scope.close(self.scope, core.exitVoid) }), runFork(effect: Effect.Effect, options?: Runtime.RunForkOptions): Fiber.RuntimeFiber { return self.cachedRuntime === undefined ? diff --git a/packages/effect/src/internal/pool.ts b/packages/effect/src/internal/pool.ts index c52d96c075..8d1fb416a3 100644 --- a/packages/effect/src/internal/pool.ts +++ b/packages/effect/src/internal/pool.ts @@ -75,13 +75,13 @@ interface Strategy { */ class NoneStrategy implements Strategy { initial(): Effect.Effect { - return core.unit + return core.void } track(): Effect.Effect { - return core.unit + return core.void } run(): Effect.Effect { - return core.unit + return core.void } } @@ -100,7 +100,7 @@ class TimeToLiveStrategy implements Strategy]): Effect.Effect { - return core.asUnit(core.flatMap( + return core.asVoid(core.flatMap( state[0].currentTimeMillis, (now) => ref.set(state[1], now) )) @@ -222,7 +222,7 @@ class PoolImpl implements Pool.Pool { if (state.size <= this.min) { return [allocateUinterruptible(this), { ...state, free: state.free + 1 }] as const } - return [core.unit, { ...state, size: state.size - 1 }] as const + return [core.void, { ...state, size: state.size - 1 }] as const })), onSuccess: (item) => core.flatMap(ref.get(this.invalidated), (set) => { @@ -303,7 +303,7 @@ const finalizeInvalid = ( if (state.size <= self.min) { return [allocateUinterruptible(self), { ...state, free: state.free + 1 }] as const } - return [core.unit, { ...state, size: state.size - 1 }] as const + return [core.void, { ...state, size: state.size - 1 }] as const })) ) ) @@ -317,7 +317,7 @@ const getAndShutdown = (self: PoolImpl): Effect.Effect => if (state.free > 0) { return [ core.matchCauseEffect(queue.take(self.items), { - onFailure: () => core.unit, + onFailure: () => core.void, onSuccess: (attempted) => pipe( forEach(attempted, (a) => ref.update(self.invalidated, HashSet.remove(a))), @@ -330,7 +330,7 @@ const getAndShutdown = (self: PoolImpl): Effect.Effect => ] as const } if (state.size > 0) { - return [core.unit, state] as const + return [core.void, state] as const } return [queue.shutdown(self.items), { ...state, size: state.size - 1 }] as const })) @@ -348,7 +348,7 @@ const initialize = (self: PoolImpl): Effect.Effect => { size: state.size + 1, free: state.free + 1 } ] as const } - return [core.unit, state] as const + return [core.void, state] as const })) ), self.min, @@ -376,7 +376,7 @@ const shrink = (self: PoolImpl): Effect.Effect => { ...state, free: state.free - 1 } ] as const } - return [core.unit, state] as const + return [core.void, state] as const })) ) @@ -393,7 +393,7 @@ const forEach = ( f: (a: A) => Effect.Effect ): Effect.Effect => core.exitMatch(self.result, { - onFailure: () => core.unit, + onFailure: () => core.void, onSuccess: f }) diff --git a/packages/effect/src/internal/pubsub.ts b/packages/effect/src/internal/pubsub.ts index c6bd55d000..852532856b 100644 --- a/packages/effect/src/internal/pubsub.ts +++ b/packages/effect/src/internal/pubsub.ts @@ -885,7 +885,7 @@ class SubscriptionImpl implements Queue.Dequeue { this.strategy.unsafeOnPubSubEmptySpace(this.pubsub, this.subscribers) })), core.whenEffect(core.deferredSucceed(this.shutdownHook, void 0)), - core.asUnit + core.asVoid ) }) ) @@ -1053,7 +1053,7 @@ class PubSubImpl implements PubSub.PubSub { this.scope.close(core.exitInterrupt(state.id())), core.zipRight(this.strategy.shutdown), core.whenEffect(core.deferredSucceed(this.shutdownHook, void 0)), - core.asUnit + core.asVoid ) })) } @@ -1298,8 +1298,8 @@ class BackPressureStrategy implements PubSubStrategy { publishers, ([_, deferred, last]) => last ? - pipe(core.deferredInterruptWith(deferred, fiberId), core.asUnit) : - core.unit, + pipe(core.deferredInterruptWith(deferred, fiberId), core.asVoid) : + core.void, false, false ) @@ -1408,7 +1408,7 @@ class BackPressureStrategy implements PubSubStrategy { */ export class DroppingStrategy implements PubSubStrategy { get shutdown(): Effect.Effect { - return core.unit + return core.void } handleSurplus( @@ -1452,7 +1452,7 @@ export class DroppingStrategy implements PubSubStrategy { */ export class SlidingStrategy implements PubSubStrategy { get shutdown(): Effect.Effect { - return core.unit + return core.void } handleSurplus( diff --git a/packages/effect/src/internal/query.ts b/packages/effect/src/internal/query.ts index 72506e8015..3ba13226c2 100644 --- a/packages/effect/src/internal/query.ts +++ b/packages/effect/src/internal/query.ts @@ -153,7 +153,7 @@ export const cacheRequest = >( core.flatMap(cache.getEither(request), (orNew) => { switch (orNew._tag) { case "Left": { - return core.unit + return core.void } case "Right": { return core.deferredComplete(orNew.right.handle, result) @@ -161,7 +161,7 @@ export const cacheRequest = >( } })) } - return core.unit + return core.void }) } diff --git a/packages/effect/src/internal/queue.ts b/packages/effect/src/internal/queue.ts index 4563fce912..f787f8d4a6 100644 --- a/packages/effect/src/internal/queue.ts +++ b/packages/effect/src/internal/queue.ts @@ -125,7 +125,7 @@ class QueueImpl implements Queue.Queue { ), core.zipRight(this.strategy.shutdown), core.whenEffect(core.deferredSucceed(this.shutdownHook, void 0)), - core.asUnit + core.asVoid ) }) ) @@ -548,9 +548,9 @@ class BackPressureStrategy implements Queue.Strategy { isLastItem ? pipe( core.deferredInterruptWith(deferred, fiberId), - core.asUnit + core.asVoid ) : - core.unit, + core.void, false, false ) @@ -630,7 +630,7 @@ class DroppingStrategy implements Queue.Strategy { } get shutdown(): Effect.Effect { - return core.unit + return core.void } onCompleteTakersWithEmptyQueue(): void { @@ -662,7 +662,7 @@ class SlidingStrategy implements Queue.Strategy { } get shutdown(): Effect.Effect { - return core.unit + return core.void } onCompleteTakersWithEmptyQueue(): void { diff --git a/packages/effect/src/internal/rateLimiter.ts b/packages/effect/src/internal/rateLimiter.ts index d28874224b..1d2e821abb 100644 --- a/packages/effect/src/internal/rateLimiter.ts +++ b/packages/effect/src/internal/rateLimiter.ts @@ -38,7 +38,7 @@ const tokenBucket = (limit: number, window: DurationInput): Effect.Effect< const refill: Effect.Effect = Effect.sleep(millisPerToken).pipe( Effect.zipRight(latch.releaseAll), Effect.zipRight(semaphore.release(1)), - Effect.flatMap((free) => free === limit ? Effect.unit : refill) + Effect.flatMap((free) => free === limit ? Effect.void : refill) ) yield* _( latch.take(1), diff --git a/packages/effect/src/internal/reloadable.ts b/packages/effect/src/internal/reloadable.ts index 99e980c5cc..ce4fe12c67 100644 --- a/packages/effect/src/internal/reloadable.ts +++ b/packages/effect/src/internal/reloadable.ts @@ -139,5 +139,5 @@ export const reloadFork = >( reloadable.reload, effect.ignoreLogged, fiberRuntime.forkDaemon, - core.asUnit + core.asVoid )) diff --git a/packages/effect/src/internal/runtime.ts b/packages/effect/src/internal/runtime.ts index 94287a6aa6..a7ab7a12ee 100644 --- a/packages/effect/src/internal/runtime.ts +++ b/packages/effect/src/internal/runtime.ts @@ -66,7 +66,7 @@ export const unsafeFork = (runtime: Runtime.Runtime) => core.scopeAddFinalizer( closeableScope, core.fiberIdWith((id) => - equals(id, fiberRuntime.id()) ? core.unit : core.interruptAsFiber(fiberRuntime, id) + equals(id, fiberRuntime.id()) ? core.void : core.interruptAsFiber(fiberRuntime, id) ) ), core.onExit(self, (exit) => _scope.close(closeableScope, exit)) @@ -483,12 +483,12 @@ export const asyncEffect = ( onFailure: (cause) => core.deferredFailCause(deferred, cause), onSuccess: (cleanup_) => { cleanup = cleanup_ - return core.unit + return core.void } } ) )), - restore(core.onInterrupt(core.deferredAwait(deferred), () => cleanup ?? core.unit)) + restore(core.onInterrupt(core.deferredAwait(deferred), () => cleanup ?? core.void)) ) )) ) diff --git a/packages/effect/src/internal/schedule.ts b/packages/effect/src/internal/schedule.ts index 865e84f163..77a22c1fc0 100644 --- a/packages/effect/src/internal/schedule.ts +++ b/packages/effect/src/internal/schedule.ts @@ -246,7 +246,7 @@ export const as = dual< >(2, (self, out) => map(self, () => out)) /** @internal */ -export const asUnit = ( +export const asVoid = ( self: Schedule.Schedule ): Schedule.Schedule => map(self, constVoid) @@ -2059,7 +2059,7 @@ export const elapsed: Schedule.Schedule = makeWithState( export const forever: Schedule.Schedule = unfold(0, (n) => n + 1) /** @internal */ -export const once: Schedule.Schedule = asUnit(recurs(1)) +export const once: Schedule.Schedule = asVoid(recurs(1)) /** @internal */ -export const stop: Schedule.Schedule = asUnit(recurs(0)) +export const stop: Schedule.Schedule = asVoid(recurs(0)) diff --git a/packages/effect/src/internal/scopedCache.ts b/packages/effect/src/internal/scopedCache.ts index 5b2fde02c0..6d639676da 100644 --- a/packages/effect/src/internal/scopedCache.ts +++ b/packages/effect/src/internal/scopedCache.ts @@ -160,11 +160,11 @@ export const releaseOwner = ( self: Complete ): Effect.Effect => Exit.matchEffect(self.exit, { - onFailure: () => core.unit, + onFailure: () => core.void, onSuccess: ([, finalizer]) => core.flatMap( core.sync(() => MutableRef.decrementAndGet(self.ownerCount)), - (numOwner) => effect.when(finalizer(Exit.unit), () => numOwner === 0) + (numOwner) => effect.when(finalizer(Exit.void), () => numOwner === 0) ) }) @@ -315,14 +315,14 @@ class ScopedCacheImpl fiberRuntime.scopedEffect(core.asUnit(s))) + return core.flatMap(finalScoped, (s) => fiberRuntime.scopedEffect(core.asVoid(s))) }) ) } @@ -560,14 +560,14 @@ class ScopedCacheImpl | undefined): Effect.Effect { if (mapValue === undefined) { - return core.unit + return core.void } switch (mapValue._tag) { case "Complete": { return releaseOwner(mapValue) } case "Pending": { - return core.unit + return core.void } case "Refreshing": { return releaseOwner(mapValue.complete) diff --git a/packages/effect/src/internal/scopedRef.ts b/packages/effect/src/internal/scopedRef.ts index 82b84426b2..2e588c36b7 100644 --- a/packages/effect/src/internal/scopedRef.ts +++ b/packages/effect/src/internal/scopedRef.ts @@ -27,7 +27,7 @@ const scopedRefVariance = { /** @internal */ const close = (self: ScopedRef.ScopedRef): Effect.Effect => - core.flatMap(ref.get(self.ref), (tuple) => tuple[0].close(core.exitUnit)) + core.flatMap(ref.get(self.ref), (tuple) => tuple[0].close(core.exitVoid)) /** @internal */ export const fromAcquire = ( @@ -83,14 +83,14 @@ export const set = dual< core.flatten( synchronized.modifyEffect(self.ref, ([oldScope, value]) => core.uninterruptible( - core.scopeClose(oldScope, core.exitUnit).pipe( + core.scopeClose(oldScope, core.exitVoid).pipe( core.zipRight(fiberRuntime.scopeMake()), core.flatMap((newScope) => core.exit(fiberRuntime.scopeExtend(acquire, newScope)).pipe( core.flatMap((exit) => core.exitMatch(exit, { onFailure: (cause) => - core.scopeClose(newScope, core.exitUnit).pipe( + core.scopeClose(newScope, core.exitVoid).pipe( core.as( [ core.failCause(cause) as Effect.Effect, @@ -101,7 +101,7 @@ export const set = dual< onSuccess: (value) => core.succeed( [ - core.unit as Effect.Effect, + core.void as Effect.Effect, [newScope, value] as const ] as const ) diff --git a/packages/effect/src/internal/sink.ts b/packages/effect/src/internal/sink.ts index 1edfb51f37..4068110767 100644 --- a/packages/effect/src/internal/sink.ts +++ b/packages/effect/src/internal/sink.ts @@ -565,7 +565,7 @@ const dropLoop = ( ) }, onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }) /** @internal */ @@ -600,7 +600,7 @@ const dropUntilEffectReader = ( channel.unwrap ), onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }) /** @internal */ @@ -649,7 +649,7 @@ const dropWhileEffectReader = ( channel.unwrap ), onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }) /** @internal */ @@ -1346,7 +1346,7 @@ export const forEach = (f: (input: In) => Effect.Effect): onInput: (input: Chunk.Chunk) => pipe(core.fromEffect(Effect.forEach(input, (v) => f(v), { discard: true })), core.flatMap(() => process)), onFailure: core.failCause, - onDone: () => core.unit + onDone: () => core.void }) return new SinkImpl(process) } @@ -1358,7 +1358,7 @@ export const forEachChunk = ( const process: Channel.Channel, E, E, void, unknown, R> = core.readWithCause({ onInput: (input: Chunk.Chunk) => pipe(core.fromEffect(f(input)), core.flatMap(() => process)), onFailure: core.failCause, - onDone: () => core.unit + onDone: () => core.void }) return new SinkImpl(process) } @@ -1370,7 +1370,7 @@ export const forEachWhile = ( const process: Channel.Channel, Chunk.Chunk, E, E, void, unknown, R> = core.readWithCause({ onInput: (input: Chunk.Chunk) => forEachWhileReader(f, input, 0, input.length, process), onFailure: core.failCause, - onDone: () => core.unit + onDone: () => core.void }) return new SinkImpl(process) } @@ -1405,10 +1405,10 @@ export const forEachChunkWhile = ( onInput: (input: Chunk.Chunk) => pipe( core.fromEffect(f(input)), - core.flatMap((cont) => cont ? reader : core.unit) + core.flatMap((cont) => cont ? reader : core.void) ), onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }) return new SinkImpl(reader) } diff --git a/packages/effect/src/internal/stm/stm.ts b/packages/effect/src/internal/stm/stm.ts index 495eebbe16..930c1c7362 100644 --- a/packages/effect/src/internal/stm/stm.ts +++ b/packages/effect/src/internal/stm/stm.ts @@ -98,7 +98,7 @@ export const asSomeError = (self: STM.STM): STM.STM(self: STM.STM): STM.STM => pipe(self, core.map(constVoid)) +export const asVoid = (self: STM.STM): STM.STM => pipe(self, core.map(constVoid)) /** @internal */ export const attempt = (evaluate: LazyArg): STM.STM => @@ -273,7 +273,7 @@ export const catchTags: { })) /** @internal */ -export const check = (predicate: LazyArg): STM.STM => suspend(() => predicate() ? unit : core.retry) +export const check = (predicate: LazyArg): STM.STM => suspend(() => predicate() ? void_ : core.retry) /** @internal */ export const collect = dual< @@ -573,7 +573,7 @@ export const forEach = dual< const loop: STM.STM = suspend(() => { const next = iterator.next() if (next.done) { - return unit + return void_ } return pipe(f(next.value), core.flatMap(() => loop)) }) @@ -713,7 +713,7 @@ export const if_ = dual< /** @internal */ export const ignore = (self: STM.STM): STM.STM => - match(self, { onFailure: () => unit, onSuccess: () => unit }) + match(self, { onFailure: () => void_, onSuccess: () => void_ }) /** @internal */ export const isFailure = (self: STM.STM): STM.STM => @@ -806,7 +806,7 @@ const loopDiscardLoop = ( core.flatMap(() => loopDiscardLoop(inc(initial), cont, inc, body)) ) } - return unit + return void_ } /** @internal */ @@ -872,7 +872,7 @@ export const none = (self: STM.STM, E, R>): STM.STM core.fail(Option.some(e)), onSuccess: Option.match({ - onNone: () => unit, + onNone: () => void_, onSome: () => core.fail(Option.none()) }) }) @@ -1370,7 +1370,11 @@ export const try_: { } /** @internal */ -export const unit: STM.STM = core.succeed(void 0) +const void_: STM.STM = core.succeed(void 0) +export { + /** @internal */ + void_ as void +} /** @internal */ export const unless = dual< diff --git a/packages/effect/src/internal/stm/stm/tExit.ts b/packages/effect/src/internal/stm/stm/tExit.ts index 72950388a2..8c337e5aef 100644 --- a/packages/effect/src/internal/stm/stm/tExit.ts +++ b/packages/effect/src/internal/stm/stm/tExit.ts @@ -183,5 +183,8 @@ export const retry: TExit = { } } -/** @internal */ -export const unit = (): TExit => succeed(undefined) +const void_: TExit = succeed(undefined) +export { + /** @internal */ + void_ as void +} diff --git a/packages/effect/src/internal/stm/tMap.ts b/packages/effect/src/internal/stm/tMap.ts index f19530b41f..c92fbe8bd4 100644 --- a/packages/effect/src/internal/stm/tMap.ts +++ b/packages/effect/src/internal/stm/tMap.ts @@ -187,7 +187,7 @@ export const forEach = dual< reduceSTM( self, void 0 as void, - (_, value, key) => stm.asUnit(f(key, value)) + (_, value, key) => stm.asVoid(f(key, value)) )) /** @internal */ @@ -501,7 +501,7 @@ export const setIfAbsent = dual< get(self, key), Option.match({ onNone: () => set(self, key, value), - onSome: () => stm.unit + onSome: () => stm.void }) )) diff --git a/packages/effect/src/internal/stm/tPubSub.ts b/packages/effect/src/internal/stm/tPubSub.ts index dad900df6e..2f869ede59 100644 --- a/packages/effect/src/internal/stm/tPubSub.ts +++ b/packages/effect/src/internal/stm/tPubSub.ts @@ -64,7 +64,7 @@ class TPubSubImpl implements TPubSub.TPubSub { awaitShutdown: STM.STM = core.flatMap( this.isShutdown, - (isShutdown) => isShutdown ? stm.unit : core.retry + (isShutdown) => isShutdown ? stm.void : core.retry ) capacity(): number { @@ -195,7 +195,7 @@ class TPubSubSubscriptionImpl implements TQueue.TDequeue { awaitShutdown: STM.STM = core.flatMap( this.isShutdown, - (isShutdown) => isShutdown ? stm.unit : core.retry + (isShutdown) => isShutdown ? stm.void : core.retry ) capacity(): number { diff --git a/packages/effect/src/internal/stm/tQueue.ts b/packages/effect/src/internal/stm/tQueue.ts index 5083409b92..c44675d78a 100644 --- a/packages/effect/src/internal/stm/tQueue.ts +++ b/packages/effect/src/internal/stm/tQueue.ts @@ -110,7 +110,7 @@ class TQueueImpl implements TQueue.TQueue { shutdown: STM.STM = core.withSTMRuntime((runtime) => { tRef.unsafeSet(this.ref, void 0, runtime.journal) - return stm.unit + return stm.void }) isShutdown: STM.STM = core.effect((journal) => { @@ -120,7 +120,7 @@ class TQueueImpl implements TQueue.TQueue { awaitShutdown: STM.STM = core.flatMap( this.isShutdown, - (isShutdown) => isShutdown ? stm.unit : core.retry + (isShutdown) => isShutdown ? stm.void : core.retry ) offer(value: A): STM.STM { diff --git a/packages/effect/src/internal/stream.ts b/packages/effect/src/internal/stream.ts index fef02fb41b..94b9597c67 100644 --- a/packages/effect/src/internal/stream.ts +++ b/packages/effect/src/internal/stream.ts @@ -103,7 +103,7 @@ export const accumulateChunks = (self: Stream.Stream): Stream. ) }, onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }) return new StreamImpl(core.pipeTo(toChannel(self), accumulator(Chunk.empty()))) } @@ -235,7 +235,7 @@ export const aggregateWithinEither = dual< core.fromEffect(Ref.set(consumed, true)), channel.zipRight(core.write(signal.elements)), channel.zipRight(core.fromEffect(Ref.get(endAfterEmit))), - core.flatMap((bool) => bool ? core.unit : handoffConsumer) + core.flatMap((bool) => bool ? core.void : handoffConsumer) ) } case HandoffSignal.OP_HALT: { @@ -341,7 +341,7 @@ export const aggregateWithinEither = dual< Effect.map((wasConsumed) => wasConsumed ? core.write(Chunk.of>(Either.right(b))) : - core.unit + core.void ), channel.unwrap ) @@ -478,7 +478,7 @@ export const _async = ( const canceler = register(emit.make((resume) => InternalTake.fromPull(resume).pipe( Effect.flatMap((take) => Queue.offer(output, take)), - Effect.asUnit, + Effect.asVoid, runPromiseExit ).then((exit) => { if (Exit.isFailure(exit)) { @@ -498,7 +498,7 @@ export const _async = ( onFailure: (maybeError) => core.fromEffect(Queue.shutdown(output)).pipe( channel.zipRight(Option.match(maybeError, { - onNone: () => core.unit, + onNone: () => core.void, onSome: (error) => core.fail(error) })) ), @@ -506,7 +506,7 @@ export const _async = ( }), channel.unwrap ) - return fromChannel(loop).pipe(ensuring(value ?? Effect.unit)) + return fromChannel(loop).pipe(ensuring(value ?? Effect.void)) }) ) ), @@ -533,7 +533,7 @@ export const asyncEffect = ( pipe( InternalTake.fromPull(k), Effect.flatMap((take) => Queue.offer(output, take)), - Effect.asUnit, + Effect.asVoid, Runtime.runPromiseExit(runtime) ).then((exit) => { if (Exit.isFailure(exit)) { @@ -552,7 +552,7 @@ export const asyncEffect = ( onFailure: (maybeError) => pipe( core.fromEffect(Queue.shutdown(output)), - channel.zipRight(Option.match(maybeError, { onNone: () => core.unit, onSome: core.fail })) + channel.zipRight(Option.match(maybeError, { onNone: () => core.void, onSome: core.fail })) ), onSuccess: (chunk) => pipe(core.write(chunk), core.flatMap(() => loop)) }), @@ -588,7 +588,7 @@ export const asyncScoped = ( pipe( InternalTake.fromPull(k), Effect.flatMap((take) => Queue.offer(output, take)), - Effect.asUnit, + Effect.asVoid, Runtime.runPromiseExit(runtime) ).then((exit) => { if (Exit.isFailure(exit)) { @@ -814,7 +814,7 @@ export const buffer = dual< onFailure: (cause) => pipe( Cause.flipCauseOption(cause), - Option.match({ onNone: () => core.unit, onSome: core.failCause }) + Option.match({ onNone: () => core.void, onSome: core.failCause }) ), onSuccess: (value) => core.flatMap(core.write(Chunk.of(value)), () => process) })) @@ -851,7 +851,7 @@ export const bufferChunks = dual< const process: Channel.Channel, unknown, E, unknown, void, unknown> = pipe( core.fromEffect(Queue.take(queue)), core.flatMap(InternalTake.match({ - onEnd: () => core.unit, + onEnd: () => core.void, onFailure: core.failCause, onSuccess: (value) => pipe(core.write(value), core.flatMap(() => process)) })) @@ -914,7 +914,7 @@ const bufferUnbounded = (self: Stream.Stream): Stream.Stream, unknown, E, unknown, void, unknown> = pipe( core.fromEffect(Queue.take(queue)), core.flatMap(InternalTake.match({ - onEnd: () => core.unit, + onEnd: () => core.void, onFailure: core.failCause, onSuccess: (value) => core.flatMap(core.write(value), () => process) })) @@ -945,7 +945,7 @@ const bufferSignal = ( Effect.zipRight(Deferred.await(deferred)) ) ), - Effect.asUnit, + Effect.asVoid, core.fromEffect ) return core.readWithCause({ @@ -959,7 +959,7 @@ const bufferSignal = ( Effect.flatMap((added) => pipe(Ref.set(ref, deferred), Effect.when(() => added))) ) ), - Effect.asUnit, + Effect.asVoid, core.fromEffect, core.flatMap(() => producer(queue, ref)) ), @@ -976,7 +976,7 @@ const bufferSignal = ( channel.zipRight( core.fromEffect(Deferred.succeed(deferred, void 0)), InternalTake.match(take, { - onEnd: () => core.unit, + onEnd: () => core.void, onFailure: core.failCause, onSuccess: (value) => pipe(core.write(value), core.flatMap(() => process)) }) @@ -1202,7 +1202,7 @@ export const changesWith = dual< ) }, onFailure: core.failCause, - onDone: () => core.unit + onDone: () => core.void }) return new StreamImpl(pipe(toChannel(self), core.pipeTo(writer(Option.none())))) }) @@ -1256,7 +1256,7 @@ export const changesWithEffect = dual< ) ), onFailure: core.failCause, - onDone: () => core.unit + onDone: () => core.void }) return new StreamImpl(pipe(toChannel(self), core.pipeTo(writer(Option.none())))) } @@ -1661,7 +1661,7 @@ export const debounce = dual< return core.failCause(signal.cause) } case HandoffSignal.OP_END: { - return core.unit + return core.void } } }), @@ -1693,7 +1693,7 @@ export const debounce = dual< case HandoffSignal.OP_END: { return pipe( Fiber.join(previous), - Effect.map((chunk) => pipe(core.write(chunk), channel.zipRight(core.unit))) + Effect.map((chunk) => pipe(core.write(chunk), channel.zipRight(core.void))) ) } } @@ -1714,7 +1714,7 @@ export const debounce = dual< return core.failCause(signal.cause) } case HandoffSignal.OP_END: { - return core.unit + return core.void } } }), @@ -1882,7 +1882,7 @@ export const distributedWithDynamic = dual< Effect.Effect<[number, Queue.Dequeue>>]>, never, Scope.Scope | R -> => distributedWithDynamicCallback(self, options.maximumLag, options.decide, () => Effect.unit)) +> => distributedWithDynamicCallback(self, options.maximumLag, options.decide, () => Effect.void)) /** @internal */ export const distributedWithDynamicCallback = dual< @@ -1961,13 +1961,13 @@ export const distributedWithDynamicCallback = dual< }) ) } - return Effect.unit + return Effect.void }) ) ) ) ), - Effect.asUnit + Effect.asVoid ) const queuesLock = yield* $(Effect.makeSemaphore(1)) const newQueue = yield* $( @@ -2013,7 +2013,7 @@ export const distributedWithDynamicCallback = dual< pipe( Queue.offer(queue, endTake), Effect.catchSomeCause((cause) => - Cause.isInterrupted(cause) ? Option.some(Effect.unit) : Option.none() + Cause.isInterrupted(cause) ? Option.some(Effect.void) : Option.none() ) ) ) @@ -2022,7 +2022,7 @@ export const distributedWithDynamicCallback = dual< ) ), Effect.zipRight(done(endTake)), - Effect.asUnit + Effect.asVoid ) ) yield* $( @@ -2067,7 +2067,7 @@ export const drainFork = dual< scoped( pipe( that, - runForEachScoped(() => Effect.unit), + runForEachScoped(() => Effect.void), Effect.catchAllCause((cause) => Deferred.failCause(backgroundDied, cause)), Effect.forkScoped ) @@ -2098,7 +2098,7 @@ export const drop = dual< ) }, onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }) return new StreamImpl(pipe(toChannel(self), channel.pipeToOrFail(loop(n)))) }) @@ -2126,7 +2126,7 @@ export const dropRight = dual< return pipe(core.write(outputs), core.flatMap(() => reader)) }, onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }) return new StreamImpl(pipe(toChannel(self), channel.pipeToOrFail(reader))) }) @@ -2175,7 +2175,7 @@ export const dropUntilEffect = dual< channel.unwrap ), onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }) return new StreamImpl(pipe(toChannel(self), channel.pipeToOrFail(loop))) } @@ -2236,7 +2236,7 @@ export const dropWhileEffect = dual< channel.unwrap ), onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }) return new StreamImpl(channel.pipeToOrFail( toChannel(self), @@ -2470,7 +2470,7 @@ export const filterMapWhileEffect = dual< } else { return channel.unwrap( Option.match(pf(next.value), { - onNone: () => Effect.succeed(core.unit), + onNone: () => Effect.succeed(core.void), onSome: Effect.map( (a2) => core.flatMap(core.write(Chunk.of(a2)), () => loop(iterator)) ) @@ -2484,7 +2484,7 @@ export const filterMapWhileEffect = dual< /** @internal */ export const finalizer = (finalizer: Effect.Effect): Stream.Stream => - acquireRelease(Effect.unit, () => finalizer) + acquireRelease(Effect.void, () => finalizer) /** @internal */ export const find: { @@ -2502,7 +2502,7 @@ export const find: { onSome: (n) => core.write(Chunk.of(n)) }), onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }) return new StreamImpl(pipe(toChannel(self), core.pipeTo(loop))) }) @@ -2533,7 +2533,7 @@ export const findEffect: { channel.unwrap ), onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }) return new StreamImpl(pipe(toChannel(self), core.pipeTo(loop))) } @@ -2590,7 +2590,7 @@ export const flatMap = dual< as, Chunk.map((a) => toChannel(f(a))), Chunk.reduce( - core.unit as Channel.Channel, unknown, E2, unknown, unknown, unknown, R2>, + core.void as Channel.Channel, unknown, E2, unknown, unknown, unknown, R2>, (left, right) => pipe(left, channel.zipRight(right)) ) ) @@ -2684,7 +2684,7 @@ export const flattenChunks = (self: Stream.Stream, E, R> () => flatten ), onFailure: core.failCause, - onDone: () => core.unit + onDone: () => core.void }) return new StreamImpl(pipe(toChannel(self), core.pipeTo(flatten))) } @@ -2742,10 +2742,10 @@ export const flattenExitOption = ( onSome: Exit.match({ onFailure: (cause) => Option.match(Cause.flipCauseOption(cause), { - onNone: () => core.unit, + onNone: () => core.void, onSome: core.failCause }), - onSuccess: () => core.unit + onSuccess: () => core.void }) }) ) @@ -2772,7 +2772,7 @@ export const flattenExitOption = ( > = core.readWithCause({ onInput: (chunk: Chunk.Chunk>>) => processChunk(chunk, process), onFailure: (cause) => core.failCause(cause), - onDone: () => core.unit + onDone: () => core.void }) return new StreamImpl(pipe(toChannel(self), core.pipeTo(process))) } @@ -2797,7 +2797,7 @@ export const fromAsyncIterable = ( pipe( Effect.acquireRelease( Effect.sync(() => iterable[Symbol.asyncIterator]()), - (iterator) => iterator.return ? Effect.promise(async () => iterator.return!()) : Effect.unit + (iterator) => iterator.return ? Effect.promise(async () => iterator.return!()) : Effect.void ), Effect.map((iterator) => repeatEffectOption(pipe( @@ -2831,7 +2831,7 @@ export const toChannel = ( /** @internal */ export const fromChunk = (chunk: Chunk.Chunk): Stream.Stream => - new StreamImpl(Chunk.isEmpty(chunk) ? core.unit : core.write(chunk)) + new StreamImpl(Chunk.isEmpty(chunk) ? core.void : core.write(chunk)) /** @internal */ export const fromChunkPubSub: { @@ -2887,7 +2887,7 @@ export const fromEffectOption = (effect: Effect.Effect core.unit, + onNone: () => core.void, onSome: core.fail }), onSuccess: (a) => core.write(Chunk.of(a)) @@ -2954,7 +2954,7 @@ export const fromIteratorSucceed = ( let next: IteratorResult = iterator.next() if (maxChunkSize === 1) { if (next.done) { - return core.unit + return core.void } return pipe( core.write(Chunk.of(next.value)), @@ -2977,7 +2977,7 @@ export const fromIteratorSucceed = ( core.flatMap(() => loop(iterator)) ) } - return core.unit + return core.void }), channel.unwrap ) @@ -3249,11 +3249,11 @@ export const haltWhen = dual< core.readWith({ onInput: (input: Chunk.Chunk) => core.flatMap(core.write(input), () => writer(fiber)), onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }), onSome: Exit.match({ onFailure: core.failCause, - onSuccess: () => core.unit + onSuccess: () => core.void }) })), channel.unwrap @@ -3292,12 +3292,12 @@ export const haltWhenDeferred = dual< core.readWith({ onInput: (input: Chunk.Chunk) => pipe(core.write(input), core.flatMap(() => writer)), onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }), onSome: (effect) => channel.unwrap(Effect.match(effect, { onFailure: core.fail, - onSuccess: () => core.unit + onSuccess: () => core.void })) })), channel.unwrap @@ -3404,7 +3404,7 @@ export const interleaveWith = dual< return pipe( core.fromEffect(Handoff.take(left)), core.flatMap(InternalTake.match({ - onEnd: () => rightDone ? core.unit : process(true, rightDone), + onEnd: () => rightDone ? core.void : process(true, rightDone), onFailure: core.failCause, onSuccess: (chunk) => pipe(core.write(chunk), core.flatMap(() => process(leftDone, rightDone))) })) @@ -3414,7 +3414,7 @@ export const interleaveWith = dual< return pipe( core.fromEffect(Handoff.take(right)), core.flatMap(InternalTake.match({ - onEnd: () => leftDone ? core.unit : process(leftDone, true), + onEnd: () => leftDone ? core.void : process(leftDone, true), onFailure: core.failCause, onSuccess: (chunk) => pipe(core.write(chunk), core.flatMap(() => process(leftDone, rightDone))) })) @@ -3423,7 +3423,7 @@ export const interleaveWith = dual< return process(leftDone, rightDone) }, onFailure: core.failCause, - onDone: () => core.unit + onDone: () => core.void }) return pipe( toChannel(decider), @@ -3469,7 +3469,7 @@ export const intersperse = dual< ) }, onFailure: core.failCause, - onDone: () => core.unit + onDone: () => core.void }) return writer(true) }) @@ -3589,7 +3589,7 @@ export const mapAccum = dual< ) }, onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }) return new StreamImpl(pipe(toChannel(self), core.pipeTo(accumulator(s)))) } @@ -3647,7 +3647,7 @@ export const mapAccumEffect = dual< channel.unwrap ), onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }) return new StreamImpl(pipe(toChannel(self), channel.pipeToOrFail(accumulator(s)))) }) @@ -4041,7 +4041,7 @@ export const onDone = dual< cleanup: () => Effect.Effect ): Stream.Stream => new StreamImpl( - pipe(toChannel(self), core.ensuringWith((exit) => Exit.isSuccess(exit) ? cleanup() : Effect.unit)) + pipe(toChannel(self), core.ensuringWith((exit) => Exit.isSuccess(exit) ? cleanup() : Effect.void)) ) ) @@ -4184,7 +4184,7 @@ export const paginateChunk = ( const loop = (s: S): Channel.Channel, unknown, never, unknown, unknown, unknown> => { const page = f(s) return Option.match(page[1], { - onNone: () => channel.zipRight(core.write(page[0]), core.unit), + onNone: () => channel.zipRight(core.write(page[0]), core.void), onSome: (s) => core.flatMap(core.write(page[0]), () => loop(s)) }) } @@ -4200,7 +4200,7 @@ export const paginateChunkEffect = ( channel.unwrap( Effect.map(f(s), ([chunk, option]) => Option.match(option, { - onNone: () => channel.zipRight(core.write(chunk), core.unit), + onNone: () => channel.zipRight(core.write(chunk), core.void), onSome: (s) => core.flatMap(core.write(chunk), () => loop(s)) })) ) @@ -4277,7 +4277,7 @@ export const peel = dual< onDone: (_) => channel.zipRight( core.fromEffect(Handoff.offer(handoff, { _tag: OP_END })), - core.unit + core.void ) }) return _sink.fromChannel( @@ -4306,7 +4306,7 @@ export const peel = dual< return core.failCause(signal.cause) } case OP_END: { - return core.unit + return core.void } } }), @@ -4762,7 +4762,7 @@ class StreamRechunker { if (this.pos !== 0) { return core.write(Chunk.unsafeFromArray(this.builder)) } - return core.unit + return core.void } } @@ -4968,7 +4968,7 @@ export const repeatElementsWith = dual< const loop: Channel.Channel, Chunk.Chunk, E, E, void, unknown, R2> = core.readWith({ onInput: feed, onFailure: core.fail, - onDone: () => core.unit + onDone: () => core.void }) return loop }), @@ -5018,7 +5018,7 @@ export const repeatWith = dual< const process = pipe(self, map(options.onElement), toChannel) const loop: Channel.Channel, unknown, E, unknown, void, unknown, R | R2> = channel.unwrap( Effect.match(driver.next(void 0), { - onFailure: () => core.unit, + onFailure: () => core.void, onSuccess: () => pipe( process, @@ -5396,7 +5396,7 @@ export const runIntoQueueElementsScoped = dual< core.pipeTo(toChannel(self), writer), channel.drain, channelExecutor.runScoped, - Effect.asUnit + Effect.asVoid ) }) @@ -5424,7 +5424,7 @@ export const runIntoQueueScoped = dual< channel.mapOutEffect((take) => Queue.offer(queue, take)), channel.drain, channelExecutor.runScoped, - Effect.asUnit + Effect.asVoid ) }) @@ -5640,7 +5640,7 @@ export const scanEffect = dual< export const scoped = ( effect: Effect.Effect ): Stream.Stream> => - new StreamImpl(channel.ensuring(channel.scoped(pipe(effect, Effect.map(Chunk.of))), Effect.unit)) + new StreamImpl(channel.ensuring(channel.scoped(pipe(effect, Effect.map(Chunk.of))), Effect.void)) /** @internal */ export const some = (self: Stream.Stream, E, R>): Stream.Stream, R> => @@ -5738,7 +5738,7 @@ export const slidingSize = dual< () => reader(queueSize + input.length) ), onFailure: (cause) => emitOnStreamEnd(queueSize, core.failCause(cause)), - onDone: () => emitOnStreamEnd(queueSize, core.unit) + onDone: () => emitOnStreamEnd(queueSize, core.void) }) return pipe(toChannel(self), core.pipeTo(reader(0))) })) @@ -5771,14 +5771,14 @@ export const split = dual< onFailure: core.fail, onDone: () => { if (Chunk.isEmpty(leftovers)) { - return core.unit + return core.void } if (Option.isNone(pipe(leftovers, Chunk.findFirst(predicate)))) { - return channel.zipRight(core.write(Chunk.of(leftovers)), core.unit) + return channel.zipRight(core.write(Chunk.of(leftovers)), core.void) } return channel.zipRight( split(Chunk.empty(), leftovers), - core.unit + core.void ) } }) @@ -5883,7 +5883,7 @@ export const take = dual< return new StreamImpl( pipe( toChannel(self), - channel.pipeToOrFail(0 < n ? loop(n) : core.unit) + channel.pipeToOrFail(0 < n ? loop(n) : core.void) ) ) }) @@ -5908,7 +5908,7 @@ export const takeRight = dual< return reader }, onFailure: core.fail, - onDone: () => pipe(core.write(queue.toChunk()), channel.zipRight(core.unit)) + onDone: () => pipe(core.write(queue.toChunk()), channel.zipRight(core.void)) }) return pipe(toChannel(self), core.pipeTo(reader)) }), @@ -6132,8 +6132,8 @@ export const tapSink = dual< pipe( core.fromEffect(Queue.offer(queue, InternalTake.end)), core.foldCauseChannel({ - onFailure: () => core.unit, - onSuccess: () => core.unit + onFailure: () => core.void, + onSuccess: () => core.void }) ) }) @@ -6271,7 +6271,7 @@ const throttleEnforceEffect = ( channel.unwrap ), onFailure: core.failCause, - onDone: () => core.unit + onDone: () => core.void }) const throttled = pipe( Clock.currentTimeMillis, @@ -6321,7 +6321,7 @@ const throttleShapeEffect = ( channel.unwrap ), onFailure: core.failCause, - onDone: () => core.unit + onDone: () => core.void }) const throttled = pipe( Clock.currentTimeMillis, @@ -6557,7 +6557,7 @@ export const toReadableStream = (source: Stream.Stream) => { }) }) ), - Effect.tapErrorCause(() => Scope.close(scope, Exit.unit)), + Effect.tapErrorCause(() => Scope.close(scope, Exit.void)), Effect.catchTags({ "None": () => Effect.sync(() => { @@ -6568,14 +6568,14 @@ export const toReadableStream = (source: Stream.Stream) => { controller.error(error.value) }) }), - Effect.asUnit + Effect.asVoid ) }, pull() { return Effect.runPromise(pull) }, cancel() { - return Effect.runPromise(Scope.close(scope, Exit.unit)) + return Effect.runPromise(Scope.close(scope, Exit.void)) } }) } @@ -6639,7 +6639,7 @@ export const transduce = dual< core.succeed([upstreamDone.ref, concatAndGet(leftover)] as const), core.flatMap(([done, newLeftovers]) => { const nextChannel = done && Chunk.isEmpty(newLeftovers) ? - core.unit : + core.void : transducer return pipe(core.write(Chunk.of(z)), core.flatMap(() => nextChannel)) }) @@ -6668,7 +6668,7 @@ export const unfoldChunk = ( ): Stream.Stream => { const loop = (s: S): Channel.Channel, unknown, never, unknown, unknown, unknown> => Option.match(f(s), { - onNone: () => core.unit, + onNone: () => core.void, onSome: ([chunk, s]) => core.flatMap(core.write(chunk), () => loop(s)) }) return new StreamImpl(core.suspend(() => loop(s))) @@ -6685,7 +6685,7 @@ export const unfoldChunkEffect = ( Effect.map( f(s), Option.match({ - onNone: () => core.unit, + onNone: () => core.void, onSome: ([chunk, s]) => core.flatMap(core.write(chunk), () => loop(s)) }) ) @@ -6700,8 +6700,11 @@ export const unfoldEffect = ( ): Stream.Stream => unfoldChunkEffect(s, (s) => pipe(f(s), Effect.map(Option.map(([a, s]) => [Chunk.of(a), s])))) -/** @internal */ -export const unit: Stream.Stream = succeed(void 0) +const void_: Stream.Stream = succeed(void 0) +export { + /** @internal */ + void_ as void +} /** @internal */ export const unwrap = ( @@ -7873,11 +7876,11 @@ export const zipWithNext = ( onFailure: core.failCause, onDone: () => Option.match(last, { - onNone: () => core.unit, + onNone: () => core.void, onSome: (value) => channel.zipRight( core.write(Chunk.of]>([value, Option.none()])), - core.unit + core.void ) }) }) diff --git a/packages/effect/src/internal/supervisor.ts b/packages/effect/src/internal/supervisor.ts index 4a6dd9586d..285df2e624 100644 --- a/packages/effect/src/internal/supervisor.ts +++ b/packages/effect/src/internal/supervisor.ts @@ -294,7 +294,7 @@ export const fromEffect = (effect: Effect.Effect): Supervisor.Supervisor fromEffect(core.unit)) +export const none = globalValue("effect/Supervisor/none", () => fromEffect(core.void)) /** @internal */ export const fibersIn = ( diff --git a/packages/effect/src/internal/take.ts b/packages/effect/src/internal/take.ts index f61f82ed89..4509cc8339 100644 --- a/packages/effect/src/internal/take.ts +++ b/packages/effect/src/internal/take.ts @@ -196,4 +196,4 @@ export const tap = dual< >(2, ( self: Take.Take, f: (chunk: Chunk.Chunk) => Effect.Effect -): Effect.Effect => pipe(self.exit, Exit.forEachEffect(f), Effect.asUnit)) +): Effect.Effect => pipe(self.exit, Exit.forEachEffect(f), Effect.asVoid)) diff --git a/packages/effect/test/Channel/error-handling.test.ts b/packages/effect/test/Channel/error-handling.test.ts index 2a72c3f7ba..a9a21ceaa8 100644 --- a/packages/effect/test/Channel/error-handling.test.ts +++ b/packages/effect/test/Channel/error-handling.test.ts @@ -28,7 +28,7 @@ describe("Channel", () => { Effect.gen(function*($) { const deferred = yield* $(Deferred.make()) const finished = yield* $(Deferred.make()) - const ref = yield* $(Ref.make>(Exit.unit)) + const ref = yield* $(Ref.make>(Exit.void)) const effect = pipe( Deferred.succeed(deferred, void 0), Effect.zipRight(Effect.never) diff --git a/packages/effect/test/Channel/finalization.test.ts b/packages/effect/test/Channel/finalization.test.ts index 5c5c50e91e..953612eba2 100644 --- a/packages/effect/test/Channel/finalization.test.ts +++ b/packages/effect/test/Channel/finalization.test.ts @@ -157,9 +157,9 @@ describe("Channel", () => { it.effect("ensuring - finalizer failure is propagated", () => Effect.gen(function*(_) { const result = yield* _( - Channel.unit, + Channel.void, Channel.ensuring(Effect.dieMessage("die")), - Channel.ensuring(Effect.unit), + Channel.ensuring(Effect.void), Channel.runDrain, Effect.exit ) diff --git a/packages/effect/test/Channel/interruption.test.ts b/packages/effect/test/Channel/interruption.test.ts index aef2ce83b8..bcea0f8ca3 100644 --- a/packages/effect/test/Channel/interruption.test.ts +++ b/packages/effect/test/Channel/interruption.test.ts @@ -81,7 +81,7 @@ describe("Channel", () => { it.effect("runScoped - in uninterruptible region", () => Effect.gen(function*(_) { - const result = yield* _(Effect.uninterruptible(Channel.run(Channel.unit))) + const result = yield* _(Effect.uninterruptible(Channel.run(Channel.void))) assert.isUndefined(result) })) }) diff --git a/packages/effect/test/Channel/merging.test.ts b/packages/effect/test/Channel/merging.test.ts index 8beccf4bee..085130ca79 100644 --- a/packages/effect/test/Channel/merging.test.ts +++ b/packages/effect/test/Channel/merging.test.ts @@ -139,7 +139,7 @@ describe("Channel", () => { onOtherDone: (_rightDone) => MergeDecision.Done(pipe( Ref.get(interrupted), - Effect.flatMap((isInterrupted) => isInterrupted ? Effect.unit : Effect.fail(void 0)) + Effect.flatMap((isInterrupted) => isInterrupted ? Effect.void : Effect.fail(void 0)) )) }) const result = yield* $(Effect.exit(Channel.runDrain(merged))) diff --git a/packages/effect/test/Channel/reading.test.ts b/packages/effect/test/Channel/reading.test.ts index 6ef8fdfc4e..7847b72260 100644 --- a/packages/effect/test/Channel/reading.test.ts +++ b/packages/effect/test/Channel/reading.test.ts @@ -21,8 +21,8 @@ export const mapper = ( Channel.write(f(a)), () => mapper(f) ), - onFailure: () => Channel.unit, - onDone: () => Channel.unit + onFailure: () => Channel.void, + onDone: () => Channel.void }) } @@ -32,11 +32,11 @@ export const refWriter = ( return Channel.readWith({ onInput: (a: A) => Channel.flatMap( - Channel.fromEffect(Effect.asUnit(Ref.update(ref, ReadonlyArray.prepend(a)))), + Channel.fromEffect(Effect.asVoid(Ref.update(ref, ReadonlyArray.prepend(a)))), () => refWriter(ref) ), - onFailure: () => Channel.unit, - onDone: () => Channel.unit + onFailure: () => Channel.void, + onDone: () => Channel.void }) } @@ -53,7 +53,7 @@ export const refReader = ( }) ), Channel.flatMap(Option.match({ - onNone: () => Channel.unit, + onNone: () => Channel.void, onSome: (i) => Channel.flatMap(Channel.write(i), () => refReader(ref)) })) ) @@ -112,8 +112,8 @@ describe("Channel", () => { Channel.zipRight(Channel.write(input)), Channel.flatMap(inner) ), - onFailure: () => Channel.unit, - onDone: () => Channel.unit + onFailure: () => Channel.void, + onDone: () => Channel.void }) return pipe( inner(), @@ -126,7 +126,7 @@ describe("Channel", () => { const channel = pipe( Channel.writeAll(1, 2), Channel.pipeTo(mapper(f)), - Channel.pipeTo(pipe(mapper(g), Channel.concatMap((ns) => Channel.writeAll(...ns)), Channel.asUnit)), + Channel.pipeTo(pipe(mapper(g), Channel.concatMap((ns) => Channel.writeAll(...ns)), Channel.asVoid)), Channel.pipeTo(innerChannel) ) const [chunk, list] = yield* $(Channel.runCollect(channel)) @@ -205,12 +205,12 @@ describe("Channel", () => { const read = pipe( Channel.read(), Channel.mapEffect((i) => event(`Read ${i}`)), - Channel.asUnit + Channel.asVoid ) const right = pipe( read, Channel.zipRight(read), - Channel.catchAll(() => Channel.unit) + Channel.catchAll(() => Channel.void) ) const channel = pipe(left, Channel.pipeTo(right)) const result = yield* $(Channel.runDrain(channel), Effect.zipRight(Ref.get(ref))) @@ -236,8 +236,8 @@ describe("Channel", () => { refWriter(destination), Channel.mergeWith({ other: refWriter(destination), - onSelfDone: () => MergeDecision.AwaitConst(Effect.unit), - onOtherDone: () => MergeDecision.AwaitConst(Effect.unit) + onSelfDone: () => MergeDecision.AwaitConst(Effect.void), + onOtherDone: () => MergeDecision.AwaitConst(Effect.void) }) ) const [missing, surplus] = yield* $( @@ -274,8 +274,8 @@ describe("Channel", () => { Channel.pipeTo(refWriter(destination)), Channel.mergeWith({ other: pipe(mapper(f), Channel.pipeTo(refWriter(destination))), - onSelfDone: () => MergeDecision.AwaitConst(Effect.unit), - onOtherDone: () => MergeDecision.AwaitConst(Effect.unit) + onSelfDone: () => MergeDecision.AwaitConst(Effect.void), + onOtherDone: () => MergeDecision.AwaitConst(Effect.void) }) ) const [missing, surplus] = yield* $( diff --git a/packages/effect/test/Channel/scoping.test.ts b/packages/effect/test/Channel/scoping.test.ts index 94b891758e..0b25fb434f 100644 --- a/packages/effect/test/Channel/scoping.test.ts +++ b/packages/effect/test/Channel/scoping.test.ts @@ -56,9 +56,9 @@ describe("Channel", () => { it.effect("finalizer failure is propagated", () => Effect.gen(function*($) { const exit = yield* $( - Channel.unit, + Channel.void, Channel.ensuring(Effect.die("ok")), - Channel.ensuring(Effect.unit), + Channel.ensuring(Effect.void), Channel.runDrain, Effect.sandbox, Effect.either diff --git a/packages/effect/test/Channel/stack-safety.test.ts b/packages/effect/test/Channel/stack-safety.test.ts index 6a9aa8dcba..bd883f19a6 100644 --- a/packages/effect/test/Channel/stack-safety.test.ts +++ b/packages/effect/test/Channel/stack-safety.test.ts @@ -36,7 +36,7 @@ describe("Channel", () => { pipe( channel, Channel.concatMap(() => Channel.write(n)), - Channel.asUnit + Channel.asVoid ) ), Channel.runCollect diff --git a/packages/effect/test/Effect/async.test.ts b/packages/effect/test/Effect/async.test.ts index 13f333abba..a5e2362ead 100644 --- a/packages/effect/test/Effect/async.test.ts +++ b/packages/effect/test/Effect/async.test.ts @@ -105,7 +105,7 @@ describe("Effect", () => { Deferred.await(step), Effect.zipRight(Effect.sync(() => resume(Ref.update(unexpectedPlace, Chunk.prepend(1))))) )) - return Effect.unit + return Effect.void }), Effect.flatMap(() => Effect.async(() => { diff --git a/packages/effect/test/Effect/concurrency.test.ts b/packages/effect/test/Effect/concurrency.test.ts index 2597182c89..98c92d0d20 100644 --- a/packages/effect/test/Effect/concurrency.test.ts +++ b/packages/effect/test/Effect/concurrency.test.ts @@ -54,7 +54,7 @@ describe("Effect", () => { Effect.acquireUseRelease( Deferred.succeed(acquire, void 0), () => Effect.never, - () => Effect.asUnit(Deferred.succeed(release, 42)) + () => Effect.asVoid(Deferred.succeed(release, 42)) ) ), Effect.fork @@ -150,7 +150,7 @@ describe("Effect", () => { Effect.zipRight(Fiber.interrupt(fiber)), Effect.zipRight(Ref.update(ref, (n) => n + 1)) ), - Effect.unit + Effect.void ) ) ) @@ -181,7 +181,7 @@ describe("Effect", () => { Effect.gen(function*($) { const latch = yield* $(Deferred.make()) const fiber = yield* $( - Effect.unit, + Effect.void, Effect.race(Effect.zip(Deferred.succeed(latch, true), Effect.sleep("45 seconds"))), Effect.uninterruptible, Effect.fork diff --git a/packages/effect/test/Effect/environment.test.ts b/packages/effect/test/Effect/environment.test.ts index 94d760bf6c..77bef4a690 100644 --- a/packages/effect/test/Effect/environment.test.ts +++ b/packages/effect/test/Effect/environment.test.ts @@ -49,7 +49,7 @@ describe("Effect", () => { it.effect("effect tag", () => Effect.gen(function*($) { const [n, s, z] = yield* $(Effect.all([ - Effect.andThen(Effect.unit, DemoTag.getNumbers), + Effect.andThen(Effect.void, DemoTag.getNumbers), Effect.andThen(Effect.succeed("a"), DemoTag.strings), Effect.andThen(Effect.succeed("a"), DemoTag.fn) ])) diff --git a/packages/effect/test/Effect/error-handling.test.ts b/packages/effect/test/Effect/error-handling.test.ts index fbad4bd371..1d959dd43b 100644 --- a/packages/effect/test/Effect/error-handling.test.ts +++ b/packages/effect/test/Effect/error-handling.test.ts @@ -27,14 +27,14 @@ const deepErrorEffect = (n: number): Effect.Effect throw ExampleError }) } - return pipe(Effect.unit, Effect.zipRight(deepErrorEffect(n - 1))) + return pipe(Effect.void, Effect.zipRight(deepErrorEffect(n - 1))) } const deepErrorFail = (n: number): Effect.Effect => { if (n === 0) { return Effect.fail(ExampleError) } - return pipe(Effect.unit, Effect.zipRight(deepErrorFail(n - 1))) + return pipe(Effect.void, Effect.zipRight(deepErrorFail(n - 1))) } describe("Effect", () => { @@ -351,10 +351,10 @@ describe("Effect", () => { const fiberId = FiberId.make(0, 123) const bothCause = Cause.parallel(Cause.interrupt(fiberId), Cause.die(error)) const thenCause = Cause.sequential(Cause.interrupt(fiberId), Cause.die(error)) - const plain = yield* $(Effect.die(error), Effect.orElse(() => Effect.unit), Effect.exit) - const both = yield* $(Effect.failCause(bothCause), Effect.orElse(() => Effect.unit), Effect.exit) - const then = yield* $(Effect.failCause(thenCause), Effect.orElse(() => Effect.unit), Effect.exit) - const fail = yield* $(Effect.fail(error), Effect.orElse(() => Effect.unit), Effect.exit) + const plain = yield* $(Effect.die(error), Effect.orElse(() => Effect.void), Effect.exit) + const both = yield* $(Effect.failCause(bothCause), Effect.orElse(() => Effect.void), Effect.exit) + const then = yield* $(Effect.failCause(thenCause), Effect.orElse(() => Effect.void), Effect.exit) + const fail = yield* $(Effect.fail(error), Effect.orElse(() => Effect.void), Effect.exit) assert.deepStrictEqual(plain, Exit.die(error)) assert.deepStrictEqual(both, Exit.die(error)) assert.deepStrictEqual(then, Exit.die(error)) diff --git a/packages/effect/test/Effect/filtering.test.ts b/packages/effect/test/Effect/filtering.test.ts index 036a6f0f33..ebb1a3d329 100644 --- a/packages/effect/test/Effect/filtering.test.ts +++ b/packages/effect/test/Effect/filtering.test.ts @@ -14,7 +14,7 @@ const exactlyOnce = ( const ref = yield* $(Ref.make(0)) const res = yield* $(f(pipe(Ref.update(ref, (n) => n + 1), Effect.zipRight(Effect.succeed(value))))) const count = yield* $(Ref.get(ref)) - yield* $(count !== 1 ? Effect.fail("Accessed more than once") : Effect.unit) + yield* $(count !== 1 ? Effect.fail("Accessed more than once") : Effect.void) return res }) } diff --git a/packages/effect/test/Effect/finalization.test.ts b/packages/effect/test/Effect/finalization.test.ts index 525f1e73af..c7fbabf0a2 100644 --- a/packages/effect/test/Effect/finalization.test.ts +++ b/packages/effect/test/Effect/finalization.test.ts @@ -20,9 +20,9 @@ const asyncExampleError = (): Effect.Effect => { }) } -const asyncUnit = (): Effect.Effect => { +const asyncVoid = (): Effect.Effect => { return Effect.async((cb) => { - cb(Effect.unit) + cb(Effect.void) }) } @@ -98,9 +98,9 @@ describe("Effect", () => { it.effect("acquireUseRelease exit.effect() is usage result", () => Effect.gen(function*($) { const result = yield* $(Effect.acquireUseRelease( - Effect.unit, + Effect.void, () => Effect.succeed(42), - () => Effect.unit + () => Effect.void )) assert.strictEqual(result, 42) })) @@ -110,8 +110,8 @@ describe("Effect", () => { pipe( Effect.acquireUseRelease( Effect.fail(ExampleError), - () => Effect.unit, - () => Effect.unit + () => Effect.void, + () => Effect.void ), Effect.exit ) @@ -123,8 +123,8 @@ describe("Effect", () => { const result = yield* $( pipe( Effect.acquireUseRelease( - Effect.unit, - () => Effect.unit, + Effect.void, + () => Effect.void, () => Effect.die(ExampleError) ), Effect.exit @@ -137,9 +137,9 @@ describe("Effect", () => { const result = yield* $( pipe( Effect.acquireUseRelease( - Effect.unit, + Effect.void, () => Effect.fail(ExampleError), - () => Effect.unit + () => Effect.void ), Effect.exit ) @@ -151,8 +151,8 @@ describe("Effect", () => { const result = yield* $( Effect.acquireUseRelease( Effect.fail(ExampleError), - () => Effect.unit, - () => Effect.unit + () => Effect.void, + () => Effect.void ), Effect.either, Effect.flatMap(identity), @@ -165,8 +165,8 @@ describe("Effect", () => { const result = yield* $( pipe( Effect.acquireUseRelease( - Effect.unit, - () => Effect.unit, + Effect.void, + () => Effect.void, () => Effect.die(ExampleError) ), Effect.exit @@ -178,9 +178,9 @@ describe("Effect", () => { Effect.gen(function*($) { const result = yield* $( Effect.acquireUseRelease( - Effect.unit, + Effect.void, () => Effect.fail(ExampleError), - () => Effect.unit + () => Effect.void ), Effect.exit ) @@ -189,14 +189,14 @@ describe("Effect", () => { it.effect("test eval of async fail", () => Effect.gen(function*($) { const io1 = Effect.acquireUseRelease( - Effect.unit, + Effect.void, () => asyncExampleError(), - () => asyncUnit() + () => asyncVoid() ) const io2 = Effect.acquireUseRelease( - asyncUnit(), + asyncVoid(), () => asyncExampleError(), - () => asyncUnit() + () => asyncVoid() ) const a1 = yield* $(Effect.exit(io1)) const a2 = yield* $(Effect.exit(io2)) @@ -219,8 +219,8 @@ describe("Effect", () => { const fiber = yield* $( Effect.acquireUseRelease( Effect.acquireUseRelease( - Effect.unit, - () => Effect.unit, + Effect.void, + () => Effect.void, () => pipe( log("start 1"), @@ -228,7 +228,7 @@ describe("Effect", () => { Effect.zipRight(log("release 1")) ) ), - () => Effect.unit, + () => Effect.void, () => pipe( log("start 2"), @@ -285,9 +285,9 @@ describe("Effect", () => { Effect.gen(function*($) { const ref = yield* $(Ref.make(false)) yield* $( - Effect.unit, + Effect.void, Effect.onExit(Exit.match({ - onFailure: () => Effect.unit, + onFailure: () => Effect.void, onSuccess: () => Ref.set(ref, true) })) ) @@ -302,7 +302,7 @@ describe("Effect", () => { Effect.onExit((exit) => Exit.isFailure(exit) && Cause.isDie(exit.effect_instruction_i0) ? Ref.set(ref, true) : - Effect.unit + Effect.void ), Effect.sandbox, Effect.ignore @@ -320,8 +320,8 @@ describe("Effect", () => { Effect.zipRight(Effect.never), Effect.onExit((exit) => Exit.isFailure(exit) && Cause.isInterrupted(exit.effect_instruction_i0) ? - pipe(Deferred.succeed(latch2, void 0), Effect.asUnit) : - Effect.unit + pipe(Deferred.succeed(latch2, void 0), Effect.asVoid) : + Effect.void ), Effect.fork ) diff --git a/packages/effect/test/Effect/forking.test.ts b/packages/effect/test/Effect/forking.test.ts index cecce33b22..09786c7fd4 100644 --- a/packages/effect/test/Effect/forking.test.ts +++ b/packages/effect/test/Effect/forking.test.ts @@ -50,7 +50,7 @@ describe("Effect", () => { const deferred = yield* $(Deferred.make()) yield* $( Effect.fail(void 0), - Effect.forkWithErrorHandler((e) => pipe(Deferred.succeed(deferred, e), Effect.asUnit)) + Effect.forkWithErrorHandler((e) => pipe(Deferred.succeed(deferred, e), Effect.asVoid)) ) const result = yield* $(Deferred.await(deferred)) assert.isUndefined(result) diff --git a/packages/effect/test/Effect/interruption.test.ts b/packages/effect/test/Effect/interruption.test.ts index 829fc419ac..0f9d3b973b 100644 --- a/packages/effect/test/Effect/interruption.test.ts +++ b/packages/effect/test/Effect/interruption.test.ts @@ -54,8 +54,8 @@ describe("Effect", () => { pipe( Effect.acquireUseRelease( pipe(Deferred.succeed(deferred, void 0), Effect.zipLeft(Deferred.await(awaiter))), - () => Effect.unit, - () => Effect.unit + () => Effect.void, + () => Effect.void ), Effect.forkDaemon ) @@ -84,9 +84,9 @@ describe("Effect", () => { const fiber = yield* $( Effect.fork( Effect.acquireUseRelease( - Effect.unit, + Effect.void, () => Effect.never, - () => Effect.unit + () => Effect.void ) ) ) @@ -100,9 +100,9 @@ describe("Effect", () => { const fiber = yield* $( Effect.fork( Effect.acquireUseRelease( - Effect.unit, + Effect.void, () => pipe(Deferred.succeed(deferred1, void 0), Effect.zipRight(Effect.never)), - () => pipe(Deferred.succeed(deferred2, void 0), Effect.zipRight(Effect.unit)) + () => pipe(Deferred.succeed(deferred2, void 0), Effect.zipRight(Effect.void)) ) ) ) @@ -127,7 +127,7 @@ describe("Effect", () => { pipe( Effect.acquireUseRelease( pipe(Deferred.succeed(deferred1, void 0), Effect.zipRight(Deferred.await(deferred2))), - () => Effect.unit, + () => Effect.void, () => Deferred.await(deferred3) ), Effect.disconnect, @@ -143,9 +143,9 @@ describe("Effect", () => { Effect.gen(function*($) { const fiber = yield* $( Effect.acquireUseRelease( - Effect.unit, + Effect.void, () => Effect.never, - () => Effect.unit + () => Effect.void ), Effect.disconnect, Effect.fork @@ -160,9 +160,9 @@ describe("Effect", () => { const fiber = yield* $( pipe( Effect.acquireUseRelease( - Effect.unit, + Effect.void, () => pipe(Deferred.succeed(deferred1, void 0), Effect.zipRight(Effect.never)), - () => pipe(Deferred.succeed(deferred2, void 0), Effect.zipRight(Effect.unit)) + () => pipe(Deferred.succeed(deferred2, void 0), Effect.zipRight(Effect.void)) ), Effect.disconnect, Effect.fork @@ -240,7 +240,7 @@ describe("Effect", () => { Effect.onExit((exit) => Ref.update(exits, Chunk.prepend(exit))) ) ), - Effect.asUnit + Effect.asVoid )), Effect.exit, Effect.flatMap((exit) => Ref.update(exits, Chunk.prepend(exit))) @@ -283,7 +283,7 @@ describe("Effect", () => { release, Effect.zipRight(Effect.never), Effect.ensuring(pipe( - Effect.unit, + Effect.void, Effect.zipRight(Effect.fail("uh oh")), Effect.catchAll(() => Ref.set(recovered, true)) )), @@ -399,7 +399,7 @@ describe("Effect", () => { }), Effect.exit, Effect.zipRight(release), - Effect.zipRight(pipe(Effect.unit, Effect.forever)), + Effect.zipRight(pipe(Effect.void, Effect.forever)), Effect.ensuring(Ref.set(ref, true)), Effect.fork ) @@ -473,7 +473,7 @@ describe("Effect", () => { Effect.zipRight(Effect.sleep(Duration.millis(10))), Effect.zipRight(Ref.set(ref, true)) ), - () => Effect.unit + () => Effect.void ), Effect.uninterruptible, Effect.fork @@ -499,9 +499,9 @@ describe("Effect", () => { Deferred.await(latch2), Effect.zipRight(Effect.sleep(Duration.millis(10))), Effect.zipRight(Ref.set(ref, true)), - Effect.asUnit + Effect.asVoid ), - () => Effect.unit + () => Effect.void ), Effect.uninterruptible, Effect.fork @@ -519,7 +519,7 @@ describe("Effect", () => { pipe( release, Effect.zipRight(Effect.sleep(Duration.millis(10))), - Effect.zipRight(pipe(Ref.set(ref, true), Effect.asUnit)), + Effect.zipRight(pipe(Ref.set(ref, true), Effect.asVoid)), Effect.uninterruptible, Effect.fork ) @@ -553,7 +553,7 @@ describe("Effect", () => { pipe(ref, MutableRef.set(MutableRef.get(ref) - 1)) }) }) - yield* $(Effect.unit, Effect.race(effect)) + yield* $(Effect.void, Effect.race(effect)) const result = MutableRef.get(ref) assert.strictEqual(result, 0) })) diff --git a/packages/effect/test/Effect/provide-runtime.test.ts b/packages/effect/test/Effect/provide-runtime.test.ts index 8ec4ec91b1..3e71adffd8 100644 --- a/packages/effect/test/Effect/provide-runtime.test.ts +++ b/packages/effect/test/Effect/provide-runtime.test.ts @@ -33,7 +33,7 @@ describe("Effect", () => { return Effect.gen(function*(_) { const rt = yield* _(Layer.succeedContext(Context.empty()), Layer.toRuntime) const pre = yield* _(Effect.context()) - yield* _(Effect.provide(Effect.unit, rt)) + yield* _(Effect.provide(Effect.void, rt)) const post = yield* _(Effect.context()) assert.isTrue(Equal.equals(pre, post)) }).pipe( @@ -69,7 +69,7 @@ describe("Effect", () => { ] )) - await Effect.runPromise(Scope.close(scope, Exit.unit)) + await Effect.runPromise(Scope.close(scope, Exit.void)) assert.deepStrictEqual(all[0].a, 2) assert.deepStrictEqual(all[0].b, { value: 1 }) diff --git a/packages/effect/test/Effect/stack-safety.test.ts b/packages/effect/test/Effect/stack-safety.test.ts index 0749580cbe..5b01becf5d 100644 --- a/packages/effect/test/Effect/stack-safety.test.ts +++ b/packages/effect/test/Effect/stack-safety.test.ts @@ -24,7 +24,7 @@ describe("Effect", () => { Effect.gen(function*($) { const array = Array.from({ length: 10000 }, (_, i) => i) const result = yield* $(array.reduce( - (acc, _) => pipe(Effect.orDie(acc), Effect.either, Effect.asUnit), + (acc, _) => pipe(Effect.orDie(acc), Effect.either, Effect.asVoid), Effect.orDie(Effect.try(constVoid)) )) assert.isUndefined(result) diff --git a/packages/effect/test/Effect/timeout.test.ts b/packages/effect/test/Effect/timeout.test.ts index c5288fdd49..6b5c619cf9 100644 --- a/packages/effect/test/Effect/timeout.test.ts +++ b/packages/effect/test/Effect/timeout.test.ts @@ -45,18 +45,18 @@ describe("Effect", () => { it.live("timeout repetition of uninterruptible effect", () => Effect.gen(function*($) { const result = yield* $( - pipe(Effect.unit, Effect.uninterruptible, Effect.forever, Effect.timeout(Duration.millis(10)), Effect.option) + pipe(Effect.void, Effect.uninterruptible, Effect.forever, Effect.timeout(Duration.millis(10)), Effect.option) ) assert.deepStrictEqual(result, Option.none()) })) it.effect("timeout in uninterruptible region", () => Effect.gen(function*($) { - const result = yield* $(Effect.unit, Effect.timeout(Duration.seconds(20)), Effect.uninterruptible) + const result = yield* $(Effect.void, Effect.timeout(Duration.seconds(20)), Effect.uninterruptible) assert.deepStrictEqual(result, void 0) })) it.effect("timeout - disconnect - returns with the produced value if the effect completes before the timeout elapses", () => Effect.gen(function*($) { - const result = yield* $(Effect.unit, Effect.disconnect, Effect.timeout(Duration.millis(100))) + const result = yield* $(Effect.void, Effect.disconnect, Effect.timeout(Duration.millis(100))) assert.deepStrictEqual(result, void 0) })) it.effect("timeout - disconnect - returns `NoSuchElementException` otherwise", () => diff --git a/packages/effect/test/Effect/traversing.test.ts b/packages/effect/test/Effect/traversing.test.ts index 0dcf2fa34b..0b49982bed 100644 --- a/packages/effect/test/Effect/traversing.test.ts +++ b/packages/effect/test/Effect/traversing.test.ts @@ -393,7 +393,7 @@ describe("Effect", () => { Effect.gen(function*($) { const result = yield* $( [], - Effect.forEach(() => Effect.unit, { + Effect.forEach(() => Effect.void, { concurrency: "unbounded", discard: true }) @@ -446,7 +446,7 @@ describe("Effect", () => { })) it.effect("mergeAll - return error if it exists in list", () => Effect.gen(function*($) { - const effects: ReadonlyArray> = [Effect.unit, Effect.fail(1)] + const effects: ReadonlyArray> = [Effect.void, Effect.fail(1)] const result = yield* $(effects, Effect.mergeAll(void 0 as void, constVoid), Effect.exit) assert.deepStrictEqual(result, Exit.fail(1)) })) @@ -476,7 +476,7 @@ describe("Effect", () => { })) it.effect("mergeAll/concurrency - return error if it exists in list", () => Effect.gen(function*($) { - const effects: ReadonlyArray> = [Effect.unit, Effect.fail(1)] + const effects: ReadonlyArray> = [Effect.void, Effect.fail(1)] const result = yield* $( effects, Effect.mergeAll(void 0 as void, constVoid, { @@ -654,7 +654,7 @@ describe("Effect", () => { Effect.gen(function*($) { const result = yield* $( pipe( - [Effect.unit, Effect.unit], + [Effect.void, Effect.void], Effect.reduceEffect(Effect.fail(1), constVoid, { concurrency: "unbounded" }), @@ -665,11 +665,11 @@ describe("Effect", () => { })) it.effect("reduceEffect/concurrency - return error if it exists in list", () => Effect.gen(function*($) { - const effects: ReadonlyArray> = [Effect.unit, Effect.fail(1)] + const effects: ReadonlyArray> = [Effect.void, Effect.fail(1)] const result = yield* $( pipe( effects, - Effect.reduceEffect(Effect.unit as Effect.Effect, constVoid, { + Effect.reduceEffect(Effect.void as Effect.Effect, constVoid, { concurrency: "unbounded" }), Effect.exit diff --git a/packages/effect/test/Fiber.test.ts b/packages/effect/test/Fiber.test.ts index 59d2861652..55eec46cb9 100644 --- a/packages/effect/test/Fiber.test.ts +++ b/packages/effect/test/Fiber.test.ts @@ -17,7 +17,7 @@ import { assert, describe } from "vitest" const initial = "initial" const update = "update" -const fibers = Array.from({ length: 10000 }, () => Fiber.unit) +const fibers = Array.from({ length: 10000 }, () => Fiber.void) describe("Fiber", () => { it.effect("should track blockingOn in await", () => @@ -109,7 +109,7 @@ describe("Fiber", () => { const fiber = yield* $(withLatch((release) => Effect.fork( Effect.acquireUseRelease( - Effect.asUnit(release), + Effect.asVoid(release), () => Effect.never, () => Ref.set(ref, true) ) @@ -142,7 +142,7 @@ describe("Fiber", () => { if (n === 100) { return pipe(Queue.shutdown(queue), Effect.zipRight(Effect.fail("fail"))) } - return pipe(Queue.offer(queue, n), Effect.asUnit) + return pipe(Queue.offer(queue, n), Effect.asVoid) } const queue = yield* $(Queue.unbounded()) yield* $(Queue.offerAll(queue, Array.from(Array(100), (_, i) => i + 1))) @@ -221,7 +221,7 @@ describe("Fiber", () => { }), 10000) it.effect("all - stack safety", () => Effect.gen(function*($) { - const result = yield* $(Fiber.join(Fiber.all(fibers)), Effect.asUnit) + const result = yield* $(Fiber.join(Fiber.all(fibers)), Effect.asVoid) assert.isUndefined(result) }), 10000) }) diff --git a/packages/effect/test/FiberMap.test.ts b/packages/effect/test/FiberMap.test.ts index 3b04734b79..508dfaa8b9 100644 --- a/packages/effect/test/FiberMap.test.ts +++ b/packages/effect/test/FiberMap.test.ts @@ -54,8 +54,8 @@ describe("FiberMap", () => { it.scoped("join", () => Effect.gen(function*(_) { const map = yield* _(FiberMap.make()) - FiberMap.unsafeSet(map, "a", Effect.runFork(Effect.unit)) - FiberMap.unsafeSet(map, "b", Effect.runFork(Effect.unit)) + FiberMap.unsafeSet(map, "a", Effect.runFork(Effect.void)) + FiberMap.unsafeSet(map, "b", Effect.runFork(Effect.void)) FiberMap.unsafeSet(map, "c", Effect.runFork(Effect.fail("fail"))) FiberMap.unsafeSet(map, "d", Effect.runFork(Effect.fail("ignored"))) const result = yield* _(FiberMap.join(map), Effect.flip) diff --git a/packages/effect/test/FiberRef.test.ts b/packages/effect/test/FiberRef.test.ts index 9a0ff192c5..5766620b7c 100644 --- a/packages/effect/test/FiberRef.test.ts +++ b/packages/effect/test/FiberRef.test.ts @@ -176,7 +176,7 @@ describe("FiberRef", () => { it.scoped("fork function is applied on fork - 1", () => Effect.gen(function*($) { const fiberRef = yield* $(FiberRef.make(0, { fork: increment })) - const child = yield* $(Effect.fork(Effect.unit)) + const child = yield* $(Effect.fork(Effect.void)) yield* $(Fiber.join(child)) const result = yield* $(FiberRef.get(fiberRef)) assert.strictEqual(result, 1) @@ -184,7 +184,7 @@ describe("FiberRef", () => { it.scoped("fork function is applied on fork - 2", () => Effect.gen(function*($) { const fiberRef = yield* $(FiberRef.make(0, { fork: increment })) - const child = yield* $(Effect.unit, Effect.fork, Effect.flatMap(Fiber.join), Effect.fork) + const child = yield* $(Effect.void, Effect.fork, Effect.flatMap(Fiber.join), Effect.fork) yield* $(Fiber.join(child)) const result = yield* $(FiberRef.get(fiberRef)) assert.strictEqual(result, 2) @@ -228,7 +228,7 @@ describe("FiberRef", () => { yield* $( success, Effect.zip(failure1.pipe(Effect.zip(failure2, { concurrent: true })), { concurrent: true }), - Effect.orElse(() => Effect.unit) + Effect.orElse(() => Effect.void) ) const result = yield* $(FiberRef.get(fiberRef)) assert.isTrue(result.includes(initial)) @@ -312,7 +312,7 @@ describe("FiberRef", () => { const latch = yield* $(Deferred.make()) const winner1 = FiberRef.set(fiberRef, update1).pipe( Effect.zipRight(Deferred.succeed(latch, void 0)), - Effect.asUnit + Effect.asVoid ) const losers1 = Deferred.await(latch).pipe( Effect.zipRight(FiberRef.set(fiberRef, update2)), @@ -332,7 +332,7 @@ describe("FiberRef", () => { Effect.gen(function*($) { const fiberRef = yield* $(FiberRef.make(initial)) const loser = FiberRef.set(fiberRef, update).pipe(Effect.zipRight(Effect.fail("darn"))) - yield* $(Effect.raceAll([loser, ...Array.from({ length: 63 }, () => loser)]), Effect.orElse(() => Effect.unit)) + yield* $(Effect.raceAll([loser, ...Array.from({ length: 63 }, () => loser)]), Effect.orElse(() => Effect.void)) const result = yield* $(FiberRef.get(fiberRef)) assert.strictEqual(result, initial) })) diff --git a/packages/effect/test/FiberRefs.test.ts b/packages/effect/test/FiberRefs.test.ts index 4f779896fb..3c958cf8af 100644 --- a/packages/effect/test/FiberRefs.test.ts +++ b/packages/effect/test/FiberRefs.test.ts @@ -45,7 +45,7 @@ describe("FiberRefs", () => { describe("currentLogAnnotations", () => { it.it("doesnt leak", () => { - Effect.unit.pipe(Effect.annotateLogs("test", "abc"), Effect.runSync) + Effect.void.pipe(Effect.annotateLogs("test", "abc"), Effect.runSync) expect(FiberRef.currentLogAnnotations.pipe(FiberRef.get, Effect.map(HashMap.size), Effect.runSync)).toBe(0) }) }) diff --git a/packages/effect/test/FiberSet.test.ts b/packages/effect/test/FiberSet.test.ts index 3aa499a184..9f92e32a2e 100644 --- a/packages/effect/test/FiberSet.test.ts +++ b/packages/effect/test/FiberSet.test.ts @@ -53,8 +53,8 @@ describe("FiberSet", () => { it.scoped("join", () => Effect.gen(function*(_) { const set = yield* _(FiberSet.make()) - FiberSet.unsafeAdd(set, Effect.runFork(Effect.unit)) - FiberSet.unsafeAdd(set, Effect.runFork(Effect.unit)) + FiberSet.unsafeAdd(set, Effect.runFork(Effect.void)) + FiberSet.unsafeAdd(set, Effect.runFork(Effect.void)) FiberSet.unsafeAdd(set, Effect.runFork(Effect.fail("fail"))) const result = yield* _(FiberSet.join(set), Effect.flip) assert.strictEqual(result, "fail") diff --git a/packages/effect/test/KeyedPool.test.ts b/packages/effect/test/KeyedPool.test.ts index 2eb7aabbb3..a7449b7d2b 100644 --- a/packages/effect/test/KeyedPool.test.ts +++ b/packages/effect/test/KeyedPool.test.ts @@ -22,7 +22,7 @@ describe("KeyedPool", () => { pool.pipe( KeyedPool.get("key1"), Effect.repeatN(3), - Effect.asUnit + Effect.asVoid ) ) const fiber = yield* $(Effect.fork( diff --git a/packages/effect/test/Layer.test.ts b/packages/effect/test/Layer.test.ts index 4386074b2c..2fdeed8b2e 100644 --- a/packages/effect/test/Layer.test.ts +++ b/packages/effect/test/Layer.test.ts @@ -32,13 +32,13 @@ describe("Layer", () => { Deferred.succeed(deferred, void 0).pipe( Effect.map((bool) => Context.make(BoolTag, bool)) ), - () => Effect.unit + () => Effect.void ) ) const env = layer1.pipe(Layer.merge(layer2), Layer.build) const fiber = yield* $(Effect.scoped(env), Effect.forkDaemon) yield* $(Deferred.await(deferred)) - const result = yield* $(Fiber.interrupt(fiber), Effect.asUnit) + const result = yield* $(Fiber.interrupt(fiber), Effect.asVoid) assert.isUndefined(result) })) it.effect("preserves identity of acquired resources", () => @@ -54,7 +54,7 @@ describe("Layer", () => { Effect.flatMap((chunk) => Ref.set(testRef, chunk)) ) ).pipe( - Effect.tap(() => Effect.unit) + Effect.tap(() => Effect.void) ) ) yield* $( @@ -182,7 +182,7 @@ describe("Layer", () => { Layer.provide(Layer.merge(layer2, layer3)) ) ) - const result = yield* $(Effect.unit, Effect.provide(layer), Effect.exit) + const result = yield* $(Effect.void, Effect.provide(layer), Effect.exit) assert.isTrue(Exit.isFailure(result)) })) it.effect("fresh with merge", () => @@ -674,9 +674,9 @@ describe("Layer", () => { yield* $(Layer.buildWithMemoMap(layer1, memoMap, scope1)) yield* $(Layer.buildWithMemoMap(layer2, memoMap, scope2)) - yield* $(Scope.close(scope2, Exit.unit)) + yield* $(Scope.close(scope2, Exit.void)) yield* $(Layer.buildWithMemoMap(layer2, memoMap, scope1)) - yield* $(Scope.close(scope1, Exit.unit)) + yield* $(Scope.close(scope1, Exit.void)) const result = yield* $(Ref.get(ref)) assert.deepStrictEqual(Array.from(result), [acquire1, acquire2, release2, acquire2, release2, release1]) @@ -695,8 +695,8 @@ describe("Layer", () => { yield* $(Layer.buildWithMemoMap(layer1, memoMap, scope1)) yield* $(Layer.buildWithMemoMap(layer2, memoMap, scope2)) - yield* $(Scope.close(scope1, Exit.unit)) - yield* $(Scope.close(scope2, Exit.unit)) + yield* $(Scope.close(scope1, Exit.void)) + yield* $(Scope.close(scope2, Exit.void)) const result = yield* $(Ref.get(ref)) assert.deepStrictEqual(Array.from(result), [acquire1, acquire2, release2, release1]) diff --git a/packages/effect/test/ManagedRuntime.test.ts b/packages/effect/test/ManagedRuntime.test.ts index 5c58ea3c5f..4877112a1b 100644 --- a/packages/effect/test/ManagedRuntime.test.ts +++ b/packages/effect/test/ManagedRuntime.test.ts @@ -12,8 +12,8 @@ describe.concurrent("ManagedRuntime", () => { count++ })) const runtime = ManagedRuntime.make(layer) - await runtime.runPromise(Effect.unit) - await runtime.runPromise(Effect.unit) + await runtime.runPromise(Effect.void) + await runtime.runPromise(Effect.void) await runtime.dispose() assert.strictEqual(count, 1) }) @@ -42,8 +42,8 @@ describe.concurrent("ManagedRuntime", () => { })) const runtimeA = ManagedRuntime.make(layer) const runtimeB = ManagedRuntime.make(layer, runtimeA.memoMap) - await runtimeA.runPromise(Effect.unit) - await runtimeB.runPromise(Effect.unit) + await runtimeA.runPromise(Effect.void) + await runtimeB.runPromise(Effect.void) await runtimeA.dispose() await runtimeB.dispose() assert.strictEqual(count, 1) diff --git a/packages/effect/test/Metric.test.ts b/packages/effect/test/Metric.test.ts index 6d99d2ba2c..c937e9a3b6 100644 --- a/packages/effect/test/Metric.test.ts +++ b/packages/effect/test/Metric.test.ts @@ -34,7 +34,7 @@ describe("Metric", () => { const id = nextName() const counter = Metric.counter(id).pipe(Metric.taggedWithLabels(labels), Metric.withConstantInput(1)) const result = yield* $( - counter(Effect.unit).pipe(Effect.zipRight(counter(Effect.unit)), Effect.zipRight(Metric.value(counter))) + counter(Effect.void).pipe(Effect.zipRight(counter(Effect.void)), Effect.zipRight(Metric.value(counter))) ) assert.deepStrictEqual(result, MetricState.counter(2)) })) @@ -128,7 +128,7 @@ describe("Metric", () => { const name = nextName() const result = yield* $( pipe( - Effect.unit, + Effect.void, Effect.withMetric( Metric.counter(name).pipe( Metric.taggedWithLabels(labels), @@ -137,7 +137,7 @@ describe("Metric", () => { ), Effect.zipRight( pipe( - Effect.unit, + Effect.void, Effect.withMetric(pipe( Metric.counter(name), Metric.taggedWithLabels(labels), @@ -206,7 +206,7 @@ describe("Metric", () => { const counter = pipe(Metric.counter(name), Metric.withConstantInput(1)) const result = yield* $( pipe( - Effect.unit, + Effect.void, Effect.withMetric(counter), Effect.zipRight(pipe(Effect.fail("error"), Effect.withMetric(counter), Effect.ignore)), Effect.zipRight(Metric.value(counter)) diff --git a/packages/effect/test/Option.test.ts b/packages/effect/test/Option.test.ts index 10e766aefe..4d48074455 100644 --- a/packages/effect/test/Option.test.ts +++ b/packages/effect/test/Option.test.ts @@ -173,7 +173,7 @@ describe("Option", () => { }) it("unit", () => { - Util.deepStrictEqual(_.unit, _.some(undefined)) + Util.deepStrictEqual(_.void, _.some(undefined)) }) it("product", () => { diff --git a/packages/effect/test/RateLimiter.test.ts b/packages/effect/test/RateLimiter.test.ts index 88681cf288..2e0354f664 100644 --- a/packages/effect/test/RateLimiter.test.ts +++ b/packages/effect/test/RateLimiter.test.ts @@ -146,11 +146,11 @@ describe("RateLimiter", () => { const deferred = yield* _(Deferred.make()) // Use up all of the available tokens - yield* _(Effect.forEach(ReadonlyArray.range(1, 10), () => limit(Effect.unit))) + yield* _(Effect.forEach(ReadonlyArray.range(1, 10), () => limit(Effect.void))) // Make an additional request when there are no tokens available yield* _( - limit(Effect.unit), + limit(Effect.void), Effect.zipRight(Deferred.succeed(deferred, void 0)), Effect.fork ) @@ -295,7 +295,7 @@ const RateLimiterTestSuite = (algorithm: "fixed-window" | "token-bucket") => { interval: "1 seconds", algorithm })) - yield* _(limit(Effect.unit)) + yield* _(limit(Effect.void)) const fiber = yield* _(Effect.fork(limit(Ref.set(count, 1)))) const interruption = yield* _(Effect.fork(Fiber.interrupt(fiber))) yield* _(Fiber.join(interruption)) @@ -331,8 +331,8 @@ const RateLimiterTestSuite = (algorithm: "fixed-window" | "token-bucket") => { interval: "1 seconds", algorithm })) - yield* _(limit(Effect.unit)) - const fiber1 = yield* _(Effect.fork(limit(Effect.unit))) + yield* _(limit(Effect.void)) + const fiber1 = yield* _(Effect.fork(limit(Effect.void))) yield* _(TestClock.adjust("1 seconds")) yield* _(Fiber.interrupt(fiber1)) const fiber2 = yield* _(Effect.fork(limit(Clock.currentTimeMillis))) @@ -361,11 +361,11 @@ const RateLimiterTestSuite = (algorithm: "fixed-window" | "token-bucket") => { ) yield* _(Deferred.await(latch)) const fibers = yield* _( - Effect.fork(limit(Effect.unit)), + Effect.fork(limit(Effect.void)), Effect.replicateEffect(1000) ) yield* _(Fiber.interruptAll(fibers)) - const fiber = yield* _(Effect.fork(limit(Effect.unit))) + const fiber = yield* _(Effect.fork(limit(Effect.void))) yield* _(TestClock.adjust("1 seconds")) yield* _(Fiber.join(fiber)) }), 10_000) @@ -378,10 +378,10 @@ const RateLimiterTestSuite = (algorithm: "fixed-window" | "token-bucket") => { algorithm })) - yield* _(limit(Effect.unit)) - const fiber = yield* _(limit(Effect.unit), RateLimiter.withCost(10), Effect.fork) + yield* _(limit(Effect.void)) + const fiber = yield* _(limit(Effect.void), RateLimiter.withCost(10), Effect.fork) yield* _(Effect.yieldNow()) yield* _(Fiber.interrupt(fiber)) - yield* _(limit(Effect.unit), RateLimiter.withCost(9)) + yield* _(limit(Effect.void), RateLimiter.withCost(9)) })) } diff --git a/packages/effect/test/STM.test.ts b/packages/effect/test/STM.test.ts index ee4907cc0a..139589467d 100644 --- a/packages/effect/test/STM.test.ts +++ b/packages/effect/test/STM.test.ts @@ -37,7 +37,7 @@ class UnpureBarrier { return Effect.async((cb) => { const check = () => { if (this.#isOpen) { - cb(Effect.unit) + cb(Effect.void) } else { setTimeout(() => { check() @@ -135,7 +135,7 @@ const permutation = (ref1: TRef.TRef, ref2: TRef.TRef): STM.STM< ref1, TRef.set(b), STM.tap(() => pipe(ref2, TRef.set(a))), - STM.asUnit + STM.asVoid ) ) ) @@ -534,7 +534,7 @@ describe("STM", () => { it.effect("mergeAll - return error if it exists in list", () => Effect.gen(function*($) { const transaction = pipe( - [STM.unit, STM.fail(1)] as Array>, + [STM.void, STM.fail(1)] as Array>, STM.mergeAll(void 0 as void, constVoid) ) const result = yield* $(Effect.exit(STM.commit(transaction))) diff --git a/packages/effect/test/Schedule.test.ts b/packages/effect/test/Schedule.test.ts index 6d442b52a4..58f5c559b0 100644 --- a/packages/effect/test/Schedule.test.ts +++ b/packages/effect/test/Schedule.test.ts @@ -85,7 +85,7 @@ describe("Schedule", () => { } // The 10th retry will succeed, which is only possible if the schedule was reset if (retries == 10) { - return Effect.unit + return Effect.void } return Effect.fail("Boom") }) diff --git a/packages/effect/test/Scope.test.ts b/packages/effect/test/Scope.test.ts index 1749afdc03..5df27b0ac1 100644 --- a/packages/effect/test/Scope.test.ts +++ b/packages/effect/test/Scope.test.ts @@ -68,7 +68,7 @@ describe("Scope", () => { Effect.addFinalizer(() => Deferred.succeed(deferred, void 0)), Effect.zipRight(Effect.addFinalizer(() => Deferred.await(deferred)), { concurrent: true }), Effect.scoped, - Effect.asUnit + Effect.asVoid ) assert.isUndefined(result) })) diff --git a/packages/effect/test/ScopedCache.test.ts b/packages/effect/test/ScopedCache.test.ts index f4b1740a28..a6e3cd7db6 100644 --- a/packages/effect/test/ScopedCache.test.ts +++ b/packages/effect/test/ScopedCache.test.ts @@ -49,7 +49,7 @@ describe("ScopedCache", () => { pipe( Effect.forEach( ReadonlyArray.map(ReadonlyArray.range(1, capacity), (n) => (n / 2) | 0), - (n) => Effect.scoped(Effect.zipRight(cache.get(n), Effect.unit)), + (n) => Effect.scoped(Effect.zipRight(cache.get(n), Effect.void)), { concurrency: "unbounded", discard: true } ), Effect.flatMap(() => cache.cacheStats) @@ -70,7 +70,7 @@ describe("ScopedCache", () => { const observablesResources = yield* $( Effect.forEach( ReadonlyArray.range(0, capacity - 1), - () => ObservableResource.makeUnit() + () => ObservableResource.makeVoid() ) ) const scopedCache = ScopedCache.make({ @@ -82,7 +82,7 @@ describe("ScopedCache", () => { const cache = yield* $(scopedCache) yield* $(Effect.forEach( ReadonlyArray.range(0, capacity - 1), - (n) => Effect.scoped(Effect.zipRight(cache.get(n), Effect.unit)), + (n) => Effect.scoped(Effect.zipRight(cache.get(n), Effect.void)), { concurrency: "unbounded", discard: true } )) yield* $(cache.invalidate(42)) @@ -105,7 +105,7 @@ describe("ScopedCache", () => { it.effect("invalidate - should not invalidate anything before effect is evaluated", () => Effect.gen(function*($) { - const observablesResource = yield* $(ObservableResource.makeUnit()) + const observablesResource = yield* $(ObservableResource.makeVoid()) const scopedCache = ScopedCache.make({ capacity: 4, timeToLive: Duration.infinity, @@ -113,11 +113,11 @@ describe("ScopedCache", () => { }) yield* $(Effect.scoped(Effect.gen(function*($) { const cache = yield* $(scopedCache) - yield* $(Effect.scoped(Effect.zipRight(cache.get(void 0), Effect.unit))) + yield* $(Effect.scoped(Effect.zipRight(cache.get(void 0), Effect.void))) const invalidateEffect = cache.invalidate(void 0) const cacheContainsKey42BeforeInvalidate = yield* $(cache.contains(void 0)) yield* $(observablesResource.assertAcquiredOnceAndNotCleaned()) - yield* $(Effect.scoped(Effect.zipRight(cache.get(void 0), Effect.unit))) + yield* $(Effect.scoped(Effect.zipRight(cache.get(void 0), Effect.void))) yield* $(invalidateEffect) const cacheContainsKey42AfterInvalidate = yield* $(cache.contains(void 0)) yield* $(observablesResource.assertAcquiredOnceAndCleaned()) @@ -132,7 +132,7 @@ describe("ScopedCache", () => { const observablesResources = yield* $( Effect.forEach( ReadonlyArray.range(0, capacity - 1), - () => ObservableResource.makeUnit() + () => ObservableResource.makeVoid() ) ) const scopedCache = ScopedCache.make({ @@ -144,7 +144,7 @@ describe("ScopedCache", () => { const cache = yield* $(scopedCache) yield* $(Effect.forEach( ReadonlyArray.range(0, capacity - 1), - (n) => Effect.scoped(Effect.zipRight(cache.get(n), Effect.unit)), + (n) => Effect.scoped(Effect.zipRight(cache.get(n), Effect.void)), { concurrency: "unbounded", discard: true } )) yield* $(cache.invalidateAll) @@ -170,7 +170,7 @@ describe("ScopedCache", () => { it.effect("get - should not put anything in the cache before the scoped effect returned by get is used", () => Effect.gen(function*($) { - const observablesResource = yield* $(ObservableResource.makeUnit()) + const observablesResource = yield* $(ObservableResource.makeVoid()) const scopedCache = ScopedCache.make({ capacity: 1, timeToLive: Duration.seconds(60), @@ -261,7 +261,7 @@ describe("ScopedCache", () => { it.effect("get - sequential use of the scoped effect returned by a single call to get should create only one resource", () => Effect.gen(function*($) { - const subResource = yield* $(ObservableResource.makeUnit()) + const subResource = yield* $(ObservableResource.makeVoid()) const scopedCache = ScopedCache.make({ capacity: 1, timeToLive: Duration.seconds(60), @@ -282,7 +282,7 @@ describe("ScopedCache", () => { it.effect("get - sequential use should create only one resource", () => Effect.gen(function*($) { - const subResource = yield* $(ObservableResource.makeUnit()) + const subResource = yield* $(ObservableResource.makeVoid()) const scopedCache = ScopedCache.make({ capacity: 1, timeToLive: Duration.seconds(60), @@ -325,7 +325,7 @@ describe("ScopedCache", () => { it.effect("get - concurrent use of the scoped effect returned by a single call to get should create only one resource", () => Effect.gen(function*($) { - const subResource = yield* $(ObservableResource.makeUnit()) + const subResource = yield* $(ObservableResource.makeVoid()) const scopedCache = ScopedCache.make({ capacity: 1, timeToLive: Duration.seconds(60), @@ -345,8 +345,8 @@ describe("ScopedCache", () => { yield* $(subResource.assertAcquiredOnceAndNotCleaned()) yield* $(acquire1) yield* $(subResource.assertAcquiredOnceAndNotCleaned()) - yield* $(release2(Exit.unit)) - yield* $(release1(Exit.unit)) + yield* $(release2(Exit.void)) + yield* $(release1(Exit.void)) yield* $(subResource.assertAcquiredOnceAndNotCleaned()) }))) yield* $(subResource.assertAcquiredOnceAndCleaned()) @@ -381,7 +381,7 @@ describe("ScopedCache", () => { it.effect("get - when two scoped effects returned by two calls to get live longer than the cache, the resource should be cleaned only when it is not in use anymore", () => Effect.gen(function*($) { - const subResource = yield* $(ObservableResource.makeUnit()) + const subResource = yield* $(ObservableResource.makeVoid()) const scopedCache = ScopedCache.make({ capacity: 1, timeToLive: Duration.seconds(60), @@ -404,15 +404,15 @@ describe("ScopedCache", () => { return [release1, release2] as const }))) yield* $(subResource.assertAcquiredOnceAndNotCleaned()) - yield* $(release1(Exit.unit)) + yield* $(release1(Exit.void)) yield* $(subResource.assertAcquiredOnceAndNotCleaned()) - yield* $(release2(Exit.unit)) + yield* $(release2(Exit.void)) yield* $(subResource.assertAcquiredOnceAndCleaned()) })) it.effect("get - when two scoped effects obtained by a single scoped effect returned by a single call to get live longer than the cache, the resource should be cleaned only when it is not in use anymore", () => Effect.gen(function*($) { - const subResource = yield* $(ObservableResource.makeUnit()) + const subResource = yield* $(ObservableResource.makeVoid()) const scopedCache = ScopedCache.make({ capacity: 1, timeToLive: Duration.seconds(60), @@ -430,9 +430,9 @@ describe("ScopedCache", () => { return [release1, release2] as const }))) yield* $(subResource.assertAcquiredOnceAndNotCleaned()) - yield* $(release1(Exit.unit)) + yield* $(release1(Exit.void)) yield* $(subResource.assertAcquiredOnceAndNotCleaned()) - yield* $(release2(Exit.unit)) + yield* $(release2(Exit.void)) yield* $(subResource.assertAcquiredOnceAndCleaned()) })) @@ -454,7 +454,7 @@ describe("ScopedCache", () => { yield* $( Effect.forEach( ReadonlyArray.range(0, numCreatedKey - 1), - (key) => Effect.scoped(Effect.asUnit(cache.get(key))), + (key) => Effect.scoped(Effect.asVoid(cache.get(key))), { discard: true } ) ) @@ -482,7 +482,7 @@ describe("ScopedCache", () => { it.effect("get - the scoped effect returned by get should recall lookup function if resource is too old and release the previous resource", () => Effect.gen(function*($) { - const watchableLookup = yield* $(WatchableLookup.makeUnit()) + const watchableLookup = yield* $(WatchableLookup.makeVoid()) yield* $(Effect.scoped(Effect.gen(function*($) { const cache = yield* $(ScopedCache.make({ capacity: 10, @@ -490,15 +490,15 @@ describe("ScopedCache", () => { lookup: (key: void) => watchableLookup(key) })) const scoped = cache.get(void 0) - yield* $(Effect.scoped(Effect.asUnit(scoped))) + yield* $(Effect.scoped(Effect.asVoid(scoped))) yield* $(TestClock.adjust(Duration.seconds(5))) - yield* $(Effect.scoped(Effect.asUnit(scoped))) + yield* $(Effect.scoped(Effect.asVoid(scoped))) yield* $(watchableLookup.assertCalledTimes(void 0, (n) => expect(n).toBe(1))) yield* $(TestClock.adjust(Duration.seconds(4))) - yield* $(Effect.scoped(Effect.asUnit(scoped))) + yield* $(Effect.scoped(Effect.asVoid(scoped))) yield* $(watchableLookup.assertCalledTimes(void 0, (n) => expect(n).toBe(1))) yield* $(TestClock.adjust(Duration.seconds(2))) - yield* $(Effect.scoped(Effect.asUnit(scoped))) + yield* $(Effect.scoped(Effect.asVoid(scoped))) yield* $(watchableLookup.assertCalledTimes(void 0, (n) => expect(n).toBe(2))) yield* $(watchableLookup.assertFirstNCreatedResourcesCleaned(void 0, 1)) }))) @@ -506,14 +506,14 @@ describe("ScopedCache", () => { it.effect("get - should recall lookup function if resource is too old and release old resource when using the scoped effect multiple times", () => Effect.gen(function*($) { - const watchableLookup = yield* $(WatchableLookup.makeUnit()) + const watchableLookup = yield* $(WatchableLookup.makeVoid()) yield* $(Effect.scoped(Effect.gen(function*($) { const cache = yield* $(ScopedCache.make({ capacity: 10, timeToLive: Duration.seconds(10), lookup: (key: void) => watchableLookup(key) })) - const scoped = Effect.scoped(Effect.asUnit(cache.get(void 0))) + const scoped = Effect.scoped(Effect.asVoid(cache.get(void 0))) yield* $(scoped) yield* $(TestClock.adjust(Duration.seconds(5))) yield* $(scoped) @@ -530,7 +530,7 @@ describe("ScopedCache", () => { it.effect("get - when resource is expired but still used it should wait until resource is not cleaned anymore to clean immediately", () => Effect.gen(function*($) { - const watchableLookup = yield* $(WatchableLookup.makeUnit()) + const watchableLookup = yield* $(WatchableLookup.makeVoid()) yield* $(Effect.scoped(Effect.gen(function*($) { const cache = yield* $(ScopedCache.make({ capacity: 10, @@ -545,11 +545,11 @@ describe("ScopedCache", () => { const release: Scope.Scope.Finalizer = (exit) => Scope.close(scope, exit) yield* $(acquire) yield* $(TestClock.adjust(Duration.seconds(11))) - yield* $(Effect.scoped(Effect.asUnit(cache.get(void 0)))) + yield* $(Effect.scoped(Effect.asVoid(cache.get(void 0)))) yield* $(watchableLookup.assertCalledTimes(void 0, (n) => expect(n).toBe(2))) const firstCreatedResource = yield* $(watchableLookup.firstCreatedResource(void 0)) yield* $(firstCreatedResource.assertAcquiredOnceAndNotCleaned()) - yield* $(release(Exit.unit)) + yield* $(release(Exit.void)) yield* $(firstCreatedResource.assertAcquiredOnceAndCleaned()) }))) })) @@ -633,7 +633,7 @@ describe("ScopedCache", () => { it.effect("refresh - should clean old resource when making a new one", () => Effect.gen(function*($) { - const watchableLookup = yield* $(WatchableLookup.makeUnit()) + const watchableLookup = yield* $(WatchableLookup.makeVoid()) const scopedCache = ScopedCache.make({ capacity: 1, timeToLive: Duration.infinity, @@ -696,7 +696,7 @@ describe("ScopedCache", () => { const scopedCache = ScopedCache.make({ capacity, timeToLive: Duration.infinity, - lookup: (_: number) => Effect.unit + lookup: (_: number) => Effect.void }) yield* $(Effect.scoped(Effect.gen(function*($) { const cache = yield* $(scopedCache) @@ -752,14 +752,14 @@ describe("ScopedCache", () => { it.effect("refresh - should not clean the resource if it's not yet expired until the new resource is ready", () => Effect.gen(function*($) { - const watchableLookup = yield* $(WatchableLookup.makeUnit()) + const watchableLookup = yield* $(WatchableLookup.makeVoid()) yield* $(Effect.scoped(Effect.gen(function*($) { const cache = yield* $(ScopedCache.make({ capacity: 10, timeToLive: Duration.seconds(10), lookup: watchableLookup })) - yield* $(Effect.scoped(Effect.asUnit(cache.get(void 0)))) + yield* $(Effect.scoped(Effect.asVoid(cache.get(void 0)))) yield* $(TestClock.adjust(Duration.seconds(9))) yield* $(watchableLookup.lock()) const refreshFiber = yield* $(Effect.fork(cache.refresh(void 0))) @@ -783,14 +783,14 @@ describe("ScopedCache", () => { it.effect("refresh - should clean the resource if it's expired and not in used", () => Effect.gen(function*($) { - const watchableLookup = yield* $(WatchableLookup.makeUnit()) + const watchableLookup = yield* $(WatchableLookup.makeVoid()) yield* $(Effect.scoped(Effect.gen(function*($) { const cache = yield* $(ScopedCache.make({ capacity: 10, timeToLive: Duration.seconds(10), lookup: watchableLookup })) - yield* $(Effect.scoped(Effect.asUnit(cache.get(void 0)))) + yield* $(Effect.scoped(Effect.asVoid(cache.get(void 0)))) yield* $(TestClock.adjust(Duration.seconds(11))) yield* $(watchableLookup.lock()) const refreshFiber = yield* $(Effect.fork(cache.refresh(void 0))) @@ -812,7 +812,7 @@ describe("ScopedCache", () => { it.effect("refresh - should wait to clean expired resource until it's not in use anymore", () => Effect.gen(function*($) { - const watchableLookup = yield* $(WatchableLookup.makeUnit()) + const watchableLookup = yield* $(WatchableLookup.makeVoid()) yield* $(Effect.scoped(Effect.gen(function*($) { const cache = yield* $(ScopedCache.make({ capacity: 10, @@ -831,7 +831,7 @@ describe("ScopedCache", () => { yield* $(watchableLookup.assertCalledTimes(void 0, (n) => expect(n).toBe(2))) const firstCreatedResource = yield* $(watchableLookup.firstCreatedResource(void 0)) yield* $(firstCreatedResource.assertAcquiredOnceAndNotCleaned()) - yield* $(release(Exit.unit)) + yield* $(release(Exit.void)) yield* $(firstCreatedResource.assertAcquiredOnceAndCleaned()) }))) })) @@ -841,7 +841,7 @@ describe("ScopedCache", () => { ScopedCache.make({ capacity: 10, timeToLive: Duration.seconds(10), - lookup: () => Effect.unit + lookup: () => Effect.void }), Effect.scoped ) diff --git a/packages/effect/test/Sink/foreign.test.ts b/packages/effect/test/Sink/foreign.test.ts index 7d52bd7b7b..35ea9e2237 100644 --- a/packages/effect/test/Sink/foreign.test.ts +++ b/packages/effect/test/Sink/foreign.test.ts @@ -10,7 +10,7 @@ import * as Stream from "effect/Stream" import { unify } from "effect/Unify" import { assert, describe } from "vitest" -const runSink = (sink: Sink.Sink) => Stream.run(Effect.unit, sink) +const runSink = (sink: Sink.Sink) => Stream.run(Effect.void, sink) describe("Channel.Foreign", () => { it.effect("Tag", () => diff --git a/packages/effect/test/Stream/async.test.ts b/packages/effect/test/Stream/async.test.ts index 5f2ebea181..785aff7504 100644 --- a/packages/effect/test/Stream/async.test.ts +++ b/packages/effect/test/Stream/async.test.ts @@ -52,7 +52,7 @@ describe("Stream", () => { const result = yield* $( Stream.async((emit) => { emit.end() - return Effect.unit + return Effect.void }), Stream.runCollect ) @@ -65,7 +65,7 @@ describe("Stream", () => { const result = yield* $( Stream.async((emit) => { emit.fromEffect(Effect.fail(error)) - return Effect.unit + return Effect.void }), Stream.runCollect, Effect.exit @@ -109,7 +109,7 @@ describe("Stream", () => { ) ) ) - return Effect.unit + return Effect.void }, 5) const sink = pipe(Sink.take(1), Sink.zipRight(Sink.never)) const fiber = yield* $(stream, Stream.run(sink), Effect.fork) @@ -130,7 +130,7 @@ describe("Stream", () => { }) return pipe( Deferred.succeed(latch, void 0), - Effect.zipRight(Effect.unit) + Effect.zipRight(Effect.void) ) }), Stream.take(array.length), @@ -148,7 +148,7 @@ describe("Stream", () => { const result = yield* $( Stream.asyncEffect((emit) => { emit.fromEffect(Effect.fail(error)) - return Effect.unit + return Effect.void }), Stream.runCollect, Effect.exit @@ -174,7 +174,7 @@ describe("Stream", () => { const result = yield* $( Stream.asyncEffect((emit) => { emit(Effect.fail(Option.none())) - return Effect.unit + return Effect.void }), Stream.runCollect ) @@ -204,7 +204,7 @@ describe("Stream", () => { ) ) ) - return Effect.unit + return Effect.void }, 5) const sink = pipe(Sink.take(1), Sink.zipRight(Sink.never)) const fiber = yield* $(stream, Stream.run(sink), Effect.fork) @@ -323,7 +323,7 @@ describe("Stream", () => { }) return pipe( Deferred.succeed(latch, void 0), - Effect.asUnit + Effect.asVoid ) }), Stream.take(array.length), @@ -340,7 +340,7 @@ describe("Stream", () => { const result = yield* $( Stream.asyncScoped((cb) => { cb(Effect.fail(Option.none())) - return Effect.unit + return Effect.void }), Stream.runCollect ) @@ -353,7 +353,7 @@ describe("Stream", () => { const result = yield* $( Stream.asyncScoped((cb) => { cb(Effect.fail(Option.some(error))) - return Effect.unit + return Effect.void }), Stream.runCollect, Effect.exit @@ -397,7 +397,7 @@ describe("Stream", () => { ) ) ) - return Effect.unit + return Effect.void }, 5) const sink = pipe(Sink.take(1), Sink.zipRight(Sink.never)) const fiber = yield* $(stream, Stream.run(sink), Effect.fork) diff --git a/packages/effect/test/Stream/conditionals.test.ts b/packages/effect/test/Stream/conditionals.test.ts index 807aec631e..68b4065168 100644 --- a/packages/effect/test/Stream/conditionals.test.ts +++ b/packages/effect/test/Stream/conditionals.test.ts @@ -153,7 +153,7 @@ describe("Stream", () => { Effect.gen(function*($) { const error = new Cause.RuntimeException("boom") const result = yield* $( - Effect.unit, + Effect.void, Stream.whenCaseEffect((): Option.Option> => { throw error }), diff --git a/packages/effect/test/Stream/error-handling.test.ts b/packages/effect/test/Stream/error-handling.test.ts index 0e3d3fea76..048159a89f 100644 --- a/packages/effect/test/Stream/error-handling.test.ts +++ b/packages/effect/test/Stream/error-handling.test.ts @@ -140,10 +140,10 @@ describe("Stream", () => { it.effect("catchAllCause - propagates the right Exit value to the failing stream (ZIO #3609)", () => Effect.gen(function*($) { - const ref = yield* $(Ref.make>(Exit.unit)) + const ref = yield* $(Ref.make>(Exit.void)) yield* $( Stream.acquireRelease( - Effect.unit, + Effect.void, (_, exit) => Ref.set(ref, exit) ), Stream.flatMap(() => Stream.fail("boom")), diff --git a/packages/effect/test/Stream/repeating.test.ts b/packages/effect/test/Stream/repeating.test.ts index d20e677d53..828f502469 100644 --- a/packages/effect/test/Stream/repeating.test.ts +++ b/packages/effect/test/Stream/repeating.test.ts @@ -219,7 +219,7 @@ describe("Stream", () => { const ref = yield* $(Ref.make(0)) const schedule = Schedule.spaced(Duration.seconds(1)) const fiber = yield* $( - Stream.repeatEffectWithSchedule(Effect.unit, schedule), + Stream.repeatEffectWithSchedule(Effect.void, schedule), Stream.tap(() => Ref.update(ref, (n) => n + 1)), Stream.runDrain, Effect.fork diff --git a/packages/effect/test/Stream/scoping.test.ts b/packages/effect/test/Stream/scoping.test.ts index 3e4252d919..fc153dab14 100644 --- a/packages/effect/test/Stream/scoping.test.ts +++ b/packages/effect/test/Stream/scoping.test.ts @@ -52,7 +52,7 @@ describe("Stream", () => { const ref = yield* $(Ref.make(false)) const stream = pipe( Stream.make(1), - Stream.concat(Stream.acquireRelease(Ref.set(ref, true), () => Effect.unit)), + Stream.concat(Stream.acquireRelease(Ref.set(ref, true), () => Effect.void)), Stream.take(0) ) yield* $(Stream.runDrain(stream)) @@ -64,7 +64,7 @@ describe("Stream", () => { Effect.gen(function*($) { const ref = yield* $(Ref.make(false)) yield* $( - Stream.acquireRelease(Effect.unit, () => Ref.set(ref, true)), + Stream.acquireRelease(Effect.void, () => Ref.set(ref, true)), Stream.flatMap(() => Stream.fromEffect(Effect.dieMessage("boom"))), Stream.runDrain, Effect.exit @@ -100,7 +100,7 @@ describe("Stream", () => { it.effect("acquireRelease - propagates errors", () => Effect.gen(function*($) { const result = yield* $( - Stream.acquireRelease(Effect.unit, () => Effect.dieMessage("die")), + Stream.acquireRelease(Effect.void, () => Effect.dieMessage("die")), Stream.runCollect, Effect.exit ) diff --git a/packages/effect/test/Stream/sequencing.test.ts b/packages/effect/test/Stream/sequencing.test.ts index 76bc8f6018..ac9886f89b 100644 --- a/packages/effect/test/Stream/sequencing.test.ts +++ b/packages/effect/test/Stream/sequencing.test.ts @@ -215,10 +215,10 @@ describe("Stream", () => { Effect.gen(function*($) { const ref = yield* $(Ref.make(false)) const inner = pipe( - Stream.acquireRelease(Effect.unit, (_, exit) => + Stream.acquireRelease(Effect.void, (_, exit) => Exit.match(exit, { onFailure: () => Ref.set(ref, true), - onSuccess: () => Effect.unit + onSuccess: () => Effect.void })), Stream.flatMap(() => Stream.fail("Ouch")) ) @@ -263,7 +263,7 @@ describe("Stream", () => { Effect.flatMap((pull) => pipe( pull, - Effect.zipRight(Scope.close(scope, Exit.unit)), + Effect.zipRight(Scope.close(scope, Exit.void)), Effect.zipRight(Ref.get(ref)) ) ) @@ -463,7 +463,7 @@ describe("Stream", () => { Stream.flatMap((n) => { if (n > 3) { return pipe( - Stream.acquireRelease(Effect.unit, () => Ref.set(ref, true)), + Stream.acquireRelease(Effect.void, () => Ref.set(ref, true)), Stream.flatMap(() => Stream.empty) ) } @@ -488,7 +488,7 @@ describe("Stream", () => { if (n > 8) { return pipe( Stream.acquireRelease( - Effect.unit, + Effect.void, () => Ref.update(ref, (n) => n + 1) ), Stream.flatMap(() => Stream.empty) diff --git a/packages/effect/test/Stream/tapping.test.ts b/packages/effect/test/Stream/tapping.test.ts index b8b252ded6..0660a265e5 100644 --- a/packages/effect/test/Stream/tapping.test.ts +++ b/packages/effect/test/Stream/tapping.test.ts @@ -98,7 +98,7 @@ describe("Stream", () => { Stream.make(1, 2, 3), Stream.tapBoth({ onSuccess: (n) => pipe(Effect.fail("error"), Effect.when(() => n === 3)), - onFailure: () => Effect.unit + onFailure: () => Effect.void }), Stream.either, Stream.runCollect diff --git a/packages/effect/test/Stream/throttling.test.ts b/packages/effect/test/Stream/throttling.test.ts index 6ac8102a53..47c6ad289a 100644 --- a/packages/effect/test/Stream/throttling.test.ts +++ b/packages/effect/test/Stream/throttling.test.ts @@ -335,7 +335,7 @@ describe("Stream", () => { Effect.gen(function*($) { const ref = yield* $(Ref.make(false)) const fiber = yield* $( - Stream.fromEffect(Effect.unit), + Stream.fromEffect(Effect.void), Stream.concat(Stream.fromEffect(pipe( Effect.never, Effect.onInterrupt(() => Ref.set(ref, true)) diff --git a/packages/effect/test/TMap.test.ts b/packages/effect/test/TMap.test.ts index 52ef8589ca..9e680b6f40 100644 --- a/packages/effect/test/TMap.test.ts +++ b/packages/effect/test/TMap.test.ts @@ -491,10 +491,10 @@ describe("TMap", () => { STM.commit, Effect.fork, Effect.zipRight(TMap.toChunk(map)), - Effect.asUnit + Effect.asVoid ), { discard: true }), Effect.exit )) - assert.deepStrictEqual(result, Exit.unit) + assert.deepStrictEqual(result, Exit.void) })) }) diff --git a/packages/effect/test/utils/cache/ObservableResource.ts b/packages/effect/test/utils/cache/ObservableResource.ts index b7b5a97665..b07fb7d449 100644 --- a/packages/effect/test/utils/cache/ObservableResource.ts +++ b/packages/effect/test/utils/cache/ObservableResource.ts @@ -40,7 +40,7 @@ class ObservableResourceImpl implements ObservableResource { } } -export const makeUnit = (): Effect.Effect> => make(void 0) +export const makeVoid = (): Effect.Effect> => make(void 0) export const make = (value: V): Effect.Effect> => makeEffect(Effect.succeed(value)) diff --git a/packages/effect/test/utils/cache/WatchableLookup.ts b/packages/effect/test/utils/cache/WatchableLookup.ts index 94569724e6..10d16e87d6 100644 --- a/packages/effect/test/utils/cache/WatchableLookup.ts +++ b/packages/effect/test/utils/cache/WatchableLookup.ts @@ -34,7 +34,7 @@ export const make = ( concreteLookup: (key: Key) => Value ): Effect.Effect> => makeEffect((key) => Effect.succeed(concreteLookup(key))) -export const makeUnit = (): Effect.Effect> => make((_: void) => void 0) +export const makeVoid = (): Effect.Effect> => make((_: void) => void 0) export const makeEffect = ( concreteLookup: (key: Key) => Effect.Effect diff --git a/packages/effect/test/utils/coordination.ts b/packages/effect/test/utils/coordination.ts index 8b625684a8..ac4a48b29b 100644 --- a/packages/effect/test/utils/coordination.ts +++ b/packages/effect/test/utils/coordination.ts @@ -52,9 +52,9 @@ export const chunkCoordination = ( return [Chunk.unsafeHead(chunk), Chunk.drop(1)(chunk)] }), Effect.flatMap((chunks) => pipe(Queue.offerAll(queue, chunks))), - Effect.asUnit + Effect.asVoid ), - proceed: pipe(Queue.offer(ps, void 0), Effect.asUnit), + proceed: pipe(Queue.offer(ps, void 0), Effect.asVoid), awaitNext: Queue.take(ps) } }) diff --git a/packages/effect/test/utils/latch.ts b/packages/effect/test/utils/latch.ts index 0ad94e788b..9fca8c86a7 100644 --- a/packages/effect/test/utils/latch.ts +++ b/packages/effect/test/utils/latch.ts @@ -9,7 +9,7 @@ export const withLatch = ( return pipe( Deferred.make(), Effect.flatMap((latch) => - pipe(f(pipe(Deferred.succeed(latch, void 0), Effect.asUnit)), Effect.zipLeft(Deferred.await(latch))) + pipe(f(pipe(Deferred.succeed(latch, void 0), Effect.asVoid)), Effect.zipLeft(Deferred.await(latch))) ) ) } @@ -22,7 +22,7 @@ export const withLatchAwait = ( const latch = yield* $(Deferred.make()) const result = yield* $( f( - pipe(Deferred.succeed(latch, void 0), Effect.asUnit), + pipe(Deferred.succeed(latch, void 0), Effect.asVoid), Effect.uninterruptibleMask((restore) => pipe(Ref.set(ref, false), Effect.zipRight(restore(Deferred.await(latch)))) ) diff --git a/packages/experimental/src/DevTools/Client.ts b/packages/experimental/src/DevTools/Client.ts index f1c69236d3..2190eb7e9f 100644 --- a/packages/experimental/src/DevTools/Client.ts +++ b/packages/experimental/src/DevTools/Client.ts @@ -117,7 +117,7 @@ export const make: Effect.Effect return requests.offer(metricsSnapshot()) } case "Pong": { - return Effect.unit + return Effect.void } } }), diff --git a/packages/experimental/src/Machine.ts b/packages/experimental/src/Machine.ts index c2f6417aef..1fcb7051fb 100644 --- a/packages/experimental/src/Machine.ts +++ b/packages/experimental/src/Machine.ts @@ -594,7 +594,7 @@ export const boot = < currentState = newState return PubSub.publish(pubsub, newState) } - return Effect.unit + return Effect.void } const run = Effect.gen(function*(_) { @@ -602,7 +602,7 @@ export const boot = < const fiberMap = yield* _(FiberMap.make()) const fork = (effect: Effect.Effect) => - Effect.asUnit(FiberSet.run(fiberSet, MachineDefect.wrap(effect))) + Effect.asVoid(FiberSet.run(fiberSet, MachineDefect.wrap(effect))) const forkWith: { (state: Machine.State): ( effect: Effect.Effect @@ -621,7 +621,7 @@ export const boot = < (id: string): (effect: Effect.Effect) => Effect.Effect (effect: Effect.Effect, id: string): Effect.Effect } = dual(2, (effect: Effect.Effect, id: string): Effect.Effect => - Effect.asUnit( + Effect.asVoid( FiberMap.run(fiberMap, id, MachineDefect.wrap(effect)) )) const forkReplaceWith: { @@ -647,7 +647,7 @@ export const boot = < } = dual(2, (effect: Effect.Effect, id: string): Effect.Effect => Effect.suspend(() => { if (MutableHashMap.has(fiberMap.backing, id)) { - return Effect.unit + return Effect.void } return forkReplace(effect, id) })) @@ -723,7 +723,7 @@ export const boot = < Effect.flatMap(([request, deferred, span, addSpan]) => Effect.flatMap(Deferred.isDone(deferred), (done) => { if (done) { - return Effect.unit + return Effect.void } const procedure = procedureMap[request._tag] @@ -794,7 +794,7 @@ export const boot = < FiberRef.getWith( FiberRef.unhandledErrorLogLevel, Option.match({ - onNone: () => Effect.unit, + onNone: () => Effect.void, onSome: (level) => Effect.log(`Unhandled Machine (${runState.identifier}) failure`, cause).pipe( Effect.locally(FiberRef.currentLogLevel, level) diff --git a/packages/experimental/src/Persistence.ts b/packages/experimental/src/Persistence.ts index c45087eef2..f530eff6eb 100644 --- a/packages/experimental/src/Persistence.ts +++ b/packages/experimental/src/Persistence.ts @@ -256,7 +256,7 @@ export const layerResult = Layer.effect( set: (key, value) => { const ttl = TimeToLive.getFinite(key, value) if (Option.isSome(ttl) && Duration.equals(ttl.value, Duration.zero)) { - return Effect.unit + return Effect.void } return encode("set", key, value).pipe( Effect.flatMap((encoded) => storage.set(makeKey(key), encoded, ttl)) diff --git a/packages/experimental/src/TimeToLive.ts b/packages/experimental/src/TimeToLive.ts index 6a243ceb66..8b17dcd533 100644 --- a/packages/experimental/src/TimeToLive.ts +++ b/packages/experimental/src/TimeToLive.ts @@ -31,7 +31,7 @@ export interface TimeToLive { * @since 1.0.0 * @category accessors */ -export const get = (u: unknown, exit: Exit.Exit = Exit.unit as any): Duration.Duration => +export const get = (u: unknown, exit: Exit.Exit = Exit.void as any): Duration.Duration => isTimeToLive(u) ? Duration.decode(u[symbol](exit)) : Duration.infinity /** @@ -40,7 +40,7 @@ export const get = (u: unknown, exit: Exit.Exit = Exit.unit as any): */ export const getFinite = ( u: unknown, - exit: Exit.Exit = Exit.unit as any + exit: Exit.Exit = Exit.void as any ): Option.Option => { const value = get(u, exit) return Duration.isFinite(value) ? Option.some(value) : Option.none() diff --git a/packages/opentelemetry/src/NodeSdk.ts b/packages/opentelemetry/src/NodeSdk.ts index c3ef4b9ec3..b23bda8f0a 100644 --- a/packages/opentelemetry/src/NodeSdk.ts +++ b/packages/opentelemetry/src/NodeSdk.ts @@ -76,10 +76,10 @@ export const layer: { Tracer.layer.pipe( Layer.provide(layerTracerProvider(config.spanProcessor, config.tracerConfig)) ) - : Layer.effectDiscard(Effect.unit) + : Layer.effectDiscard(Effect.void) const MetricsLive = config.metricReader ? Metrics.layer(() => config.metricReader!) - : Layer.effectDiscard(Effect.unit) + : Layer.effectDiscard(Effect.void) return Layer.merge(TracerLive, MetricsLive).pipe( Layer.provideMerge(ResourceLive) ) diff --git a/packages/opentelemetry/src/WebSdk.ts b/packages/opentelemetry/src/WebSdk.ts index 259a208661..231f86ab05 100644 --- a/packages/opentelemetry/src/WebSdk.ts +++ b/packages/opentelemetry/src/WebSdk.ts @@ -74,10 +74,10 @@ export const layer: { const ResourceLive = Resource.layer(config.resource) const TracerLive = config.spanProcessor ? Tracer.layer.pipe(Layer.provide(layerTracerProvider(config.spanProcessor, config.tracerConfig))) - : Layer.effectDiscard(Effect.unit) + : Layer.effectDiscard(Effect.void) const MetricsLive = config.metricReader ? Metrics.layer(() => config.metricReader!) - : Layer.effectDiscard(Effect.unit) + : Layer.effectDiscard(Effect.void) return Layer.merge(TracerLive, MetricsLive).pipe( Layer.provideMerge(ResourceLive) ) diff --git a/packages/platform-browser/src/internal/runtime.ts b/packages/platform-browser/src/internal/runtime.ts index a28c30cc9b..7e80f9c5f5 100644 --- a/packages/platform-browser/src/internal/runtime.ts +++ b/packages/platform-browser/src/internal/runtime.ts @@ -27,7 +27,7 @@ export const runMain: RunMain = ( _effect : Effect.tapErrorCause(_effect, (cause) => { if (Cause.isInterruptedOnly(cause)) { - return Effect.unit + return Effect.void } return Effect.logError(cause) }) diff --git a/packages/platform-browser/src/internal/workerRunner.ts b/packages/platform-browser/src/internal/workerRunner.ts index a56faf460a..80ca073f05 100644 --- a/packages/platform-browser/src/internal/workerRunner.ts +++ b/packages/platform-browser/src/internal/workerRunner.ts @@ -69,7 +69,7 @@ const platformRunnerImpl = Runner.PlatformRunner.of({ port.removeEventListener("error", onError as any) }) }).pipe( - Effect.tapErrorCause((cause) => Cause.isInterruptedOnly(cause) ? Effect.unit : Effect.logDebug(cause)), + Effect.tapErrorCause((cause) => Cause.isInterruptedOnly(cause) ? Effect.void : Effect.logDebug(cause)), Effect.retry(Schedule.forever), Effect.annotateLogs({ package: "@effect/platform-browser", diff --git a/packages/platform-bun/src/internal/http/server.ts b/packages/platform-bun/src/internal/http/server.ts index eb7d63e0a9..82b5b74e8c 100644 --- a/packages/platform-bun/src/internal/http/server.ts +++ b/packages/platform-bun/src/internal/http/server.ts @@ -58,7 +58,7 @@ export const make = ( ws.data.closeDeferred, Socket.defaultCloseCodeIsError(code) ? Exit.fail(new Socket.SocketCloseError({ reason: "Close", code, closeReason })) - : Exit.unit + : Exit.void ) } } @@ -115,7 +115,7 @@ export const make = ( ), Effect.interruptible, Effect.forkScoped, - Effect.asUnit + Effect.asVoid ) } }) diff --git a/packages/platform-bun/src/internal/worker.ts b/packages/platform-bun/src/internal/worker.ts index da3ab7d144..9d2e14bf0b 100644 --- a/packages/platform-bun/src/internal/worker.ts +++ b/packages/platform-bun/src/internal/worker.ts @@ -14,7 +14,7 @@ const platformWorkerImpl = Worker.PlatformWorker.of({ yield* _(Effect.addFinalizer(() => pipe( Effect.async((resume, signal) => { - port.addEventListener("close", () => resume(Effect.unit), { once: true, signal }) + port.addEventListener("close", () => resume(Effect.void), { once: true, signal }) port.postMessage([1]) }), // TODO: make configurable diff --git a/packages/platform-bun/src/internal/workerRunner.ts b/packages/platform-bun/src/internal/workerRunner.ts index 73985b9047..aa6a277ee8 100644 --- a/packages/platform-bun/src/internal/workerRunner.ts +++ b/packages/platform-bun/src/internal/workerRunner.ts @@ -37,7 +37,7 @@ const platformRunnerImpl = Runner.PlatformRunner.of({ port.removeEventListener("error", onError) }) }), - Effect.tapErrorCause((cause) => Cause.isInterruptedOnly(cause) ? Effect.unit : Effect.logDebug(cause)), + Effect.tapErrorCause((cause) => Cause.isInterruptedOnly(cause) ? Effect.void : Effect.logDebug(cause)), Effect.retry(Schedule.forever), Effect.annotateLogs({ package: "@effect/platform-bun", diff --git a/packages/platform-node-shared/src/NodeSocket.ts b/packages/platform-node-shared/src/NodeSocket.ts index 0cbb5ab921..a204da1fc0 100644 --- a/packages/platform-node-shared/src/NodeSocket.ts +++ b/packages/platform-node-shared/src/NodeSocket.ts @@ -91,10 +91,10 @@ export const fromNetSocket = ( if (Socket.isCloseEvent(chunk)) { conn.destroy(chunk.code > 1000 ? new Error(`closed with code ${chunk.code}`) : undefined) } else if (chunk === EOF) { - conn.end(() => resume(Effect.unit)) + conn.end(() => resume(Effect.void)) } else { conn.write(chunk, (error) => { - resume(error ? Effect.fail(new Socket.SocketGenericError({ reason: "Write", error })) : Effect.unit) + resume(error ? Effect.fail(new Socket.SocketGenericError({ reason: "Write", error })) : Effect.void) }) } }) @@ -109,7 +109,7 @@ export const fromNetSocket = ( yield* _( Effect.async((resume) => { conn.on("end", () => { - resume(Effect.unit) + resume(Effect.void) }) conn.on("error", (error) => { resume(Effect.fail(new Socket.SocketGenericError({ reason: "Read", error }))) diff --git a/packages/platform-node-shared/src/internal/commandExecutor.ts b/packages/platform-node-shared/src/internal/commandExecutor.ts index e1869d3530..896ee84fe5 100644 --- a/packages/platform-node-shared/src/internal/commandExecutor.ts +++ b/packages/platform-node-shared/src/internal/commandExecutor.ts @@ -88,7 +88,7 @@ const runCommand = return pipe( // Validate that the directory is accessible Option.match(command.cwd, { - onNone: () => Effect.unit, + onNone: () => Effect.void, onSome: (dir) => fileSystem.access(dir) }), Effect.zipRight( @@ -96,11 +96,11 @@ const runCommand = spawn, ([handle, exitCode]) => Effect.flatMap(Deferred.isDone(exitCode), (done) => - done ? Effect.unit : Effect.suspend(() => { + done ? Effect.void : Effect.suspend(() => { if (handle.kill("SIGTERM")) { return Deferred.await(exitCode) } - return Effect.unit + return Effect.void })) ) ), @@ -138,7 +138,7 @@ const runCommand = const kill: CommandExecutor.Process["kill"] = (signal = "SIGTERM") => Effect.suspend(() => handle.kill(signal) - ? Effect.asUnit(Deferred.await(exitCodeDeferred)) + ? Effect.asVoid(Deferred.await(exitCodeDeferred)) : Effect.fail(toPlatformError("kill", new globalThis.Error("Failed to kill process"), command)) ) @@ -170,7 +170,7 @@ const runCommand = }), Effect.tap((process) => Option.match(command.stdin, { - onNone: () => Effect.unit, + onNone: () => Effect.void, onSome: (stdin) => Effect.forkDaemon(Stream.run(stdin, process.stdin)) }) ) diff --git a/packages/platform-node-shared/src/internal/fileSystem.ts b/packages/platform-node-shared/src/internal/fileSystem.ts index 431b321734..9efe025e90 100644 --- a/packages/platform-node-shared/src/internal/fileSystem.ts +++ b/packages/platform-node-shared/src/internal/fileSystem.ts @@ -349,7 +349,7 @@ const makeFile = (() => { this.position = this.position + BigInt(bytesWritten) } - return bytesWritten < buffer.length ? this.writeAllChunk(buffer.subarray(bytesWritten)) : Effect.unit + return bytesWritten < buffer.length ? this.writeAllChunk(buffer.subarray(bytesWritten)) : Effect.void } ) } @@ -631,7 +631,7 @@ const writeFile = (path: string, data: Uint8Array, options?: FileSystem.WriteFil if (err) { resume(Effect.fail(handleErrnoException("FileSystem", "writeFile")(err, [path]))) } else { - resume(Effect.unit) + resume(Effect.void) } }) } catch (err) { diff --git a/packages/platform-node-shared/src/internal/runtime.ts b/packages/platform-node-shared/src/internal/runtime.ts index 255238bb97..92c4555ada 100644 --- a/packages/platform-node-shared/src/internal/runtime.ts +++ b/packages/platform-node-shared/src/internal/runtime.ts @@ -15,7 +15,7 @@ export const runMain: RunMain = ( effect : Effect.tapErrorCause(effect, (cause) => { if (Cause.isInterruptedOnly(cause)) { - return Effect.unit + return Effect.void } return Effect.logError(cause) }) diff --git a/packages/platform-node-shared/src/internal/sink.ts b/packages/platform-node-shared/src/internal/sink.ts index 336f687542..3877a7eb5f 100644 --- a/packages/platform-node-shared/src/internal/sink.ts +++ b/packages/platform-node-shared/src/internal/sink.ts @@ -33,7 +33,7 @@ export const fromWritableChannel = ( writable, (cause) => Deferred.failCause(deferred, cause), options, - Deferred.complete(deferred, Effect.unit) + Deferred.complete(deferred, Effect.void) ) ) ) diff --git a/packages/platform-node-shared/src/internal/stream.ts b/packages/platform-node-shared/src/internal/stream.ts index bd82dd8780..8b8b7d0de4 100644 --- a/packages/platform-node-shared/src/internal/stream.ts +++ b/packages/platform-node-shared/src/internal/stream.ts @@ -224,21 +224,21 @@ export const writeInput = ( writable: Writable | NodeJS.WritableStream, onFailure: (cause: Cause.Cause) => Effect.Effect, { encoding, endOnDone = true }: FromWritableOptions = {}, - onDone = Effect.unit + onDone = Effect.void ): AsyncInput.AsyncInputProducer, unknown> => { const write = writeEffect(writable, encoding) const close = endOnDone ? Effect.async((resume) => { if ("closed" in writable && writable.closed) { - resume(Effect.unit) + resume(Effect.void) } else { - writable.once("finish", () => resume(Effect.unit)) + writable.once("finish", () => resume(Effect.void)) writable.end() } }) - : Effect.unit + : Effect.void return { - awaitRead: () => Effect.unit, + awaitRead: () => Effect.void, emit: write, error: (cause) => Effect.zipRight(close, onFailure(cause)), done: (_) => Effect.zipRight(close, onDone) @@ -252,7 +252,7 @@ export const writeEffect = ( ) => (chunk: Chunk.Chunk) => chunk.length === 0 ? - Effect.unit : + Effect.void : Effect.async((resume) => { const iterator = chunk[Symbol.iterator]() let next = iterator.next() @@ -261,7 +261,7 @@ export const writeEffect = ( next = iterator.next() const success = writable.write(item.value, encoding as any) if (next.done) { - resume(Effect.unit) + resume(Effect.void) } else if (success) { loop() } else { @@ -287,7 +287,7 @@ const readableOffer = ( queue.unsafeOffer(Either.left(Exit.fail(onError(err)))) }) readable.on("end", () => { - queue.unsafeOffer(Either.left(Exit.unit)) + queue.unsafeOffer(Either.left(Exit.void)) }) if (readable.readable) { queue.unsafeOffer(Either.right(void 0)) @@ -305,7 +305,7 @@ const readableTake = ( Either.match({ onLeft: Exit.match({ onFailure: Channel.failCause, - onSuccess: (_) => Channel.unit + onSuccess: (_) => Channel.void }), onRight: (_) => Channel.flatMap(read, () => loop) }) @@ -376,7 +376,7 @@ class StreamAdapter extends Readable { } _destroy(_error: Error | null, callback: (error?: Error | null | undefined) => void): void { - Runtime.runFork(this.runtime)(Scope.close(this.scope, Exit.unit)).addObserver((exit) => { + Runtime.runFork(this.runtime)(Scope.close(this.scope, Exit.void)).addObserver((exit) => { callback(exit._tag === "Failure" ? Cause.squash(exit.cause) as any : null) }) } diff --git a/packages/platform-node-shared/src/internal/terminal.ts b/packages/platform-node-shared/src/internal/terminal.ts index 9cbfe49c8a..c42700f0a9 100644 --- a/packages/platform-node-shared/src/internal/terminal.ts +++ b/packages/platform-node-shared/src/internal/terminal.ts @@ -102,7 +102,7 @@ export const make = ( message: (err as Error).message ?? String(err) }))) } - resume(Effect.unit) + resume(Effect.void) }) }) ) diff --git a/packages/platform-node/src/internal/http/client.ts b/packages/platform-node/src/internal/http/client.ts index 8cf59a4267..7962dbf14e 100644 --- a/packages/platform-node/src/internal/http/client.ts +++ b/packages/platform-node/src/internal/http/client.ts @@ -188,7 +188,7 @@ const waitForFinish = (nodeRequest: Http.ClientRequest, request: ClientRequest.C function onFinish() { nodeRequest.off("error", onError) - resume(Effect.unit) + resume(Effect.void) } nodeRequest.once("finish", onFinish) diff --git a/packages/platform-node/src/internal/http/server.ts b/packages/platform-node/src/internal/http/server.ts index f3ee962bb9..9c4c54190e 100644 --- a/packages/platform-node/src/internal/http/server.ts +++ b/packages/platform-node/src/internal/http/server.ts @@ -51,7 +51,7 @@ export const make = ( if (error) { resume(Effect.die(error)) } else { - resume(Effect.unit) + resume(Effect.void) } }) }) @@ -62,7 +62,7 @@ export const make = ( resume(Effect.fail(new Error.ServeError({ error }))) }) server.listen(options, () => { - resume(Effect.unit) + resume(Effect.void) }) })) @@ -73,7 +73,7 @@ export const make = ( Effect.sync(() => new WS.WebSocketServer({ noServer: true })), (wss) => Effect.async((resume) => { - wss.close(() => resume(Effect.unit)) + wss.close(() => resume(Effect.void)) }) ), Scope.extend(scope), @@ -380,7 +380,7 @@ const handleResponse = (request: ServerRequest.ServerRequest, response: ServerRe Effect.suspend((): Effect.Effect => { const nodeResponse = (request as ServerRequestImpl).resolvedResponse if (nodeResponse.writableEnded) { - return Effect.unit + return Effect.void } let headers: Record> = response.headers @@ -396,14 +396,14 @@ const handleResponse = (request: ServerRequest.ServerRequest, response: ServerRe if (request.method === "HEAD") { nodeResponse.writeHead(response.status, headers) nodeResponse.end() - return Effect.unit + return Effect.void } const body = response.body switch (body._tag) { case "Empty": { nodeResponse.writeHead(response.status, headers) nodeResponse.end() - return Effect.unit + return Effect.void } case "Raw": { nodeResponse.writeHead(response.status, headers) @@ -423,12 +423,12 @@ const handleResponse = (request: ServerRequest.ServerRequest, response: ServerRe }) } nodeResponse.end(body.body) - return Effect.unit + return Effect.void } case "Uint8Array": { nodeResponse.writeHead(response.status, headers) nodeResponse.end(body.body) - return Effect.unit + return Effect.void } case "FormData": { return Effect.async((resume) => { @@ -450,7 +450,7 @@ const handleResponse = (request: ServerRequest.ServerRequest, response: ServerRe )) }) .once("finish", () => { - resume(Effect.unit) + resume(Effect.void) }) }) } diff --git a/packages/platform-node/src/internal/worker.ts b/packages/platform-node/src/internal/worker.ts index 3544d871ad..b196530a67 100644 --- a/packages/platform-node/src/internal/worker.ts +++ b/packages/platform-node/src/internal/worker.ts @@ -15,7 +15,7 @@ const platformWorkerImpl = Worker.PlatformWorker.of({ pipe( Effect.async((resume) => { worker.once("exit", () => { - resume(Effect.unit) + resume(Effect.void) }) worker.postMessage([1]) }), diff --git a/packages/platform-node/src/internal/workerRunner.ts b/packages/platform-node/src/internal/workerRunner.ts index 87f91f2aa5..35c6383733 100644 --- a/packages/platform-node/src/internal/workerRunner.ts +++ b/packages/platform-node/src/internal/workerRunner.ts @@ -32,7 +32,7 @@ const platformRunnerImpl = Runner.PlatformRunner.of({ resume(new WorkerError({ reason: "unknown", error })) }) }), - Effect.tapErrorCause((cause) => Cause.isInterruptedOnly(cause) ? Effect.unit : Effect.logDebug(cause)), + Effect.tapErrorCause((cause) => Cause.isInterruptedOnly(cause) ? Effect.void : Effect.logDebug(cause)), Effect.retry(Schedule.forever), Effect.annotateLogs({ package: "@effect/platform-node", diff --git a/packages/platform/src/Http/App.ts b/packages/platform/src/Http/App.ts index f48da35f07..7b9ac7b368 100644 --- a/packages/platform/src/Http/App.ts +++ b/packages/platform/src/Http/App.ts @@ -145,7 +145,7 @@ export const toWebHandlerRuntime = (runtime: Runtime.Runtime) => { } else { ;(request as any)[rejectSymbol](Cause.pretty(exit.cause)) } - return Effect.unit + return Effect.void })) return (request: Request): Promise => new Promise((resolve, reject) => { @@ -181,7 +181,7 @@ export const toWebHandlerLayer = ( readonly handler: (request: Request) => Promise } => { const scope = Effect.runSync(Scope.make()) - const close = () => Effect.runPromise(Scope.close(scope, Exit.unit)) + const close = () => Effect.runPromise(Scope.close(scope, Exit.void)) const build = Effect.map(Layer.toRuntime(layer), (_) => toWebHandlerRuntime(_)(self)) const runner = Effect.runPromise(Scope.extend(build, scope)) const handler = (request: Request): Promise => runner.then((handler) => handler(request)) diff --git a/packages/platform/src/Http/Router.ts b/packages/platform/src/Http/Router.ts index 01728dce05..5479911464 100644 --- a/packages/platform/src/Http/Router.ts +++ b/packages/platform/src/Http/Router.ts @@ -84,7 +84,7 @@ export interface Route extends Inspectable { readonly [RouteTypeId]: RouteTypeId readonly method: Method.Method | "*" readonly path: PathInput - readonly handler: Route.Handler + readonly handler: Route.Handler readonly prefix: Option.Option readonly uninterruptible: boolean } @@ -96,7 +96,7 @@ export declare namespace Route { /** * @since 1.0.0 */ - export type Handler = Effect.Effect< + export type Handler = Effect.Effect< ServerResponse.ServerResponse, E, R | RouteContext | ServerRequest.ServerRequest @@ -242,10 +242,10 @@ export const fromIterable: >( * @since 1.0.0 * @category constructors */ -export const makeRoute: ( +export const makeRoute: ( method: Method.Method, path: PathInput, - handler: Route.Handler, + handler: Route.Handler, prefix?: Option.Option, uninterruptible?: boolean ) => Route> = internal.makeRoute @@ -497,12 +497,12 @@ export const options: { * @category combinators */ export const use: { - ( - f: (self: Route.Handler) => App.Default + ( + f: (self: Route.Handler) => App.Default ): (self: Router) => Router> - ( + ( self: Router, - f: (self: Route.Handler) => App.Default + f: (self: Route.Handler) => App.Default ): Router> } = internal.use @@ -511,12 +511,12 @@ export const use: { * @category combinators */ export const catchAll: { - ( - f: (e: E) => Route.Handler + ( + f: (e: E) => Route.Handler ): (self: Router) => Router> - ( + ( self: Router, - f: (e: E) => Route.Handler + f: (e: E) => Route.Handler ): Router> } = internal.catchAll @@ -525,12 +525,12 @@ export const catchAll: { * @category combinators */ export const catchAllCause: { - ( - f: (e: Cause.Cause) => Route.Handler + ( + f: (e: Cause.Cause) => Route.Handler ): (self: Router) => Router> - ( + ( self: Router, - f: (e: Cause.Cause) => Route.Handler + f: (e: Cause.Cause) => Route.Handler ): Router> } = internal.catchAllCause @@ -539,16 +539,16 @@ export const catchAllCause: { * @category combinators */ export const catchTag: { - ( + ( k: K, - f: (e: Extract) => Route.Handler + f: (e: Extract) => Route.Handler ): ( self: Router ) => Router, R | Exclude> - ( + ( self: Router, k: K, - f: (e: Extract) => Route.Handler + f: (e: Extract) => Route.Handler ): Router, R | Exclude> } = internal.catchTag diff --git a/packages/platform/src/Socket.ts b/packages/platform/src/Socket.ts index 646456a2a7..0f926149f5 100644 --- a/packages/platform/src/Socket.ts +++ b/packages/platform/src/Socket.ts @@ -181,7 +181,7 @@ export const toChannel = ( const exitQueue = yield* _(Queue.unbounded, SocketError | IE>>()) const input: AsyncProducer.AsyncInputProducer, unknown> = { - awaitRead: () => Effect.unit, + awaitRead: () => Effect.void, emit(chunk) { return Effect.catchAllCause( Effect.forEach(chunk, write, { discard: true }), @@ -190,12 +190,12 @@ export const toChannel = ( }, error(error) { return Effect.zipRight( - Scope.close(writeScope, Exit.unit), + Scope.close(writeScope, Exit.void), Queue.offer(exitQueue, Exit.failCause(error)) ) }, done() { - return Scope.close(writeScope, Exit.unit) + return Scope.close(writeScope, Exit.void) } } @@ -212,7 +212,7 @@ export const toChannel = ( .flatMap( Queue.take(exitQueue), Exit.match({ - onFailure: (cause) => Cause.isEmptyType(cause) ? Channel.unit : Channel.failCause(cause), + onFailure: (cause) => Cause.isEmptyType(cause) ? Channel.void : Channel.failCause(cause), onSuccess: (chunk) => Channel.zipRight(Channel.write(chunk), loop) }) ) @@ -350,7 +350,7 @@ export const fromWebSocket = ( yield* _( Effect.async((resume) => { ws.onopen = () => { - resume(Effect.unit) + resume(Effect.void) } }), Effect.timeoutFail({ @@ -388,7 +388,7 @@ export const fromWebSocket = ( FiberSet.join(fiberSet), Effect.catchIf( SocketCloseError.isClean((_) => !closeCodeIsError(_)), - (_) => Effect.unit + (_) => Effect.void ) ) }).pipe( diff --git a/packages/platform/src/Transferable.ts b/packages/platform/src/Transferable.ts index 4188acd923..5d4a3ce9ee 100644 --- a/packages/platform/src/Transferable.ts +++ b/packages/platform/src/Transferable.ts @@ -69,7 +69,7 @@ export const addAll = (tranferables: Iterable): Effect. Effect.flatMap( Effect.serviceOption(Collector), Option.match({ - onNone: () => Effect.unit, + onNone: () => Effect.void, onSome: (_) => _.addAll(tranferables) }) ) diff --git a/packages/platform/src/internal/fileSystem.ts b/packages/platform/src/internal/fileSystem.ts index 44e40bb9a4..c484876a56 100644 --- a/packages/platform/src/internal/fileSystem.ts +++ b/packages/platform/src/internal/fileSystem.ts @@ -99,7 +99,7 @@ const stream = (file: File, { totalBytesRead: bigint ): Channel.Channel, unknown, Error.PlatformError, unknown, void, unknown> { if (bytesToRead !== undefined && bytesToRead <= totalBytesRead) { - return Channel.unit + return Channel.void } const toRead = bytesToRead !== undefined && (bytesToRead - totalBytesRead) < chunkSize @@ -109,7 +109,7 @@ const stream = (file: File, { return Channel.flatMap( file.readAlloc(toRead), Option.match({ - onNone: () => Channel.unit, + onNone: () => Channel.void, onSome: (buf) => Channel.flatMap( Channel.write(Chunk.of(buf)), diff --git a/packages/platform/src/internal/http/middleware.ts b/packages/platform/src/internal/http/middleware.ts index 12771cd49f..7c11d2dd89 100644 --- a/packages/platform/src/internal/http/middleware.ts +++ b/packages/platform/src/internal/http/middleware.ts @@ -54,7 +54,7 @@ export const logger = make((httpApp) => { return Effect.withLogSpan( Effect.onExit(httpApp, (exit) => { if (fiber.getFiberRef(loggerDisabled)) { - return Effect.unit + return Effect.void } return exit._tag === "Failure" ? Effect.annotateLogs(Effect.log(exit.cause), { diff --git a/packages/platform/src/internal/http/multipart.ts b/packages/platform/src/internal/http/multipart.ts index a063ad0742..add20c0943 100644 --- a/packages/platform/src/internal/http/multipart.ts +++ b/packages/platform/src/internal/http/multipart.ts @@ -214,7 +214,7 @@ const makeFromQueue = ( let partsFinished = false const input: AsyncInput.AsyncInputProducer, unknown> = { - awaitRead: () => Effect.unit, + awaitRead: () => Effect.void, emit(element) { return Queue.offer(queue, element) }, @@ -238,7 +238,7 @@ const makeFromQueue = ( const take: Channel.Channel, unknown, never, unknown, void, unknown> = Channel .suspend(() => { if (chunks.length === 0) { - return finished ? Channel.unit : Channel.zipRight(pump, take) + return finished ? Channel.void : Channel.zipRight(pump, take) } const chunk = Chunk.unsafeFromArray(chunks) chunks = [] @@ -282,7 +282,7 @@ const makeFromQueue = ( pump, Channel.suspend(() => { if (partsBuffer.length === 0) { - return Channel.unit + return Channel.void } const parts = Chunk.unsafeFromArray(partsBuffer) partsBuffer = [] @@ -301,7 +301,7 @@ const makeFromQueue = ( if (error._tag === "Some") { return Channel.failCause(error.value) } else if (partsFinished) { - return Channel.unit + return Channel.void } return Channel.zipRight(takeParts, partsChannel) }) diff --git a/packages/platform/src/internal/http/router.ts b/packages/platform/src/internal/http/router.ts index fea4ee162a..806836b597 100644 --- a/packages/platform/src/internal/http/router.ts +++ b/packages/platform/src/internal/http/router.ts @@ -264,7 +264,7 @@ class RouteImpl extends Inspectable.Class implements Route constructor( readonly method: Method.Method | "*", readonly path: Router.PathInput, - readonly handler: Router.Route.Handler, + readonly handler: Router.Route.Handler, readonly prefix = Option.none(), readonly uninterruptible = false ) { @@ -304,10 +304,10 @@ export const fromIterable = >( > => new RouterImpl(Chunk.fromIterable(routes), Chunk.empty()) as any /** @internal */ -export const makeRoute = ( +export const makeRoute = ( method: Method.Method, path: Router.PathInput, - handler: Router.Route.Handler, + handler: Router.Route.Handler, prefix: Option.Option = Option.none(), uninterruptible = false ): Router.Route> => @@ -478,12 +478,12 @@ export const options = route("OPTIONS") /** @internal */ export const use = dual< - ( - f: (self: Router.Route.Handler) => App.Default + ( + f: (self: Router.Route.Handler) => App.Default ) => (self: Router.Router) => Router.Router>, - ( + ( self: Router.Router, - f: (self: Router.Route.Handler) => App.Default + f: (self: Router.Route.Handler) => App.Default ) => Router.Router> >(2, (self, f) => new RouterImpl( @@ -499,38 +499,38 @@ export const use = dual< /** @internal */ export const catchAll = dual< - ( - f: (e: E) => Router.Route.Handler + ( + f: (e: E) => Router.Route.Handler ) => (self: Router.Router) => Router.Router>, - ( + ( self: Router.Router, - f: (e: E) => Router.Route.Handler + f: (e: E) => Router.Route.Handler ) => Router.Router> >(2, (self, f) => use(self, Effect.catchAll(f))) /** @internal */ export const catchAllCause = dual< - ( - f: (e: Cause.Cause) => Router.Route.Handler + ( + f: (e: Cause.Cause) => Router.Route.Handler ) => (self: Router.Router) => Router.Router>, - ( + ( self: Router.Router, - f: (e: Cause.Cause) => Router.Route.Handler + f: (e: Cause.Cause) => Router.Route.Handler ) => Router.Router> >(2, (self, f) => use(self, Effect.catchAllCause(f))) /** @internal */ export const catchTag = dual< - ( + ( k: K, - f: (e: Extract) => Router.Route.Handler + f: (e: Extract) => Router.Route.Handler ) => ( self: Router.Router ) => Router.Router | E1, R | Router.Router.ExcludeProvided>, - ( + ( self: Router.Router, k: K, - f: (e: Extract) => Router.Route.Handler + f: (e: Extract) => Router.Route.Handler ) => Router.Router | E1, R | Router.Router.ExcludeProvided> >(3, (self, k, f) => use(self, Effect.catchTag(k, f))) diff --git a/packages/platform/src/internal/worker.ts b/packages/platform/src/internal/worker.ts index 00d51dd69f..475818cba5 100644 --- a/packages/platform/src/internal/worker.ts +++ b/packages/platform/src/internal/worker.ts @@ -112,7 +112,7 @@ export const makeManager = Effect.gen(function*(_) { Queue.take(backing.queue), Effect.flatMap((msg) => { if (msg[0] === 0) { - return Deferred.complete(readyLatch, Effect.unit) + return Deferred.complete(readyLatch, Effect.void) } return handleMessage(msg[1]) }), @@ -153,7 +153,7 @@ export const makeManager = Effect.gen(function*(_) { const handleMessage = (response: Worker.Worker.Response) => Effect.suspend(() => { const queue = requestMap.get(response[0]) - if (!queue) return Effect.unit + if (!queue) return Effect.void switch (response[1]) { // data @@ -210,7 +210,7 @@ export const makeManager = Effect.gen(function*(_) { exit: Exit.Exit ) => { const release = Effect.zipRight( - Deferred.complete(deferred, Effect.unit), + Deferred.complete(deferred, Effect.void), Effect.sync(() => requestMap.delete(id)) ) return Exit.isFailure(exit) ? @@ -229,7 +229,7 @@ export const makeManager = Effect.gen(function*(_) { .flatMap( Queue.take(queue), Exit.match({ - onFailure: (cause) => Cause.isEmpty(cause) ? Channel.unit : Channel.failCause(cause), + onFailure: (cause) => Cause.isEmpty(cause) ? Channel.void : Channel.failCause(cause), onSuccess: (value) => Channel.flatMap(Channel.write(Chunk.unsafeFromArray(value)), () => loop) }) ) @@ -251,7 +251,7 @@ export const makeManager = Effect.gen(function*(_) { pipe( Effect.suspend(() => { const result = requestMap.get(id) - if (!result) return Effect.unit + if (!result) return Effect.void const transferables = transfers(request) const spanTuple = Option.getOrUndefined( Option.map(span, (span) => [span.traceId, span.spanId, span.sampled] as const) diff --git a/packages/platform/src/internal/workerRunner.ts b/packages/platform/src/internal/workerRunner.ts index 10be3cf8ce..9ccc48efc0 100644 --- a/packages/platform/src/internal/workerRunner.ts +++ b/packages/platform/src/internal/workerRunner.ts @@ -38,7 +38,7 @@ export const make = ( const scope = yield* _(Scope.fork(yield* _(Effect.scope), ExecutionStrategy.parallel)) const fiber = Option.getOrThrow(Fiber.getCurrentFiber()) const shutdown = Effect.zipRight( - Scope.close(scope, Exit.unit), + Scope.close(scope, Exit.void), Fiber.interruptFork(fiber) ) const platform = yield* _(PlatformRunner) @@ -64,7 +64,7 @@ export const make = ( const id = req[0] if (req[1] === 1) { const fiber = fiberMap.get(id) - if (!fiber) return Effect.unit + if (!fiber) return Effect.void return Fiber.interrupt(fiber) } diff --git a/packages/schema/src/ParseResult.ts b/packages/schema/src/ParseResult.ts index f97342c511..e86b034f5c 100644 --- a/packages/schema/src/ParseResult.ts +++ b/packages/schema/src/ParseResult.ts @@ -1008,13 +1008,13 @@ const go = (ast: AST.AST, isDecoding: boolean): Parser => { const e = new Index(index, t.left) if (allErrors) { es.push([nk, e]) - return Effect.unit + return Effect.void } else { return Either.left(new TupleType(ast, input, [e], sortByIndex(output))) } } output.push([nk, t.right]) - return Effect.unit + return Effect.void }) ) } @@ -1053,13 +1053,13 @@ const go = (ast: AST.AST, isDecoding: boolean): Parser => { const e = new Index(index, t.left) if (allErrors) { es.push([nk, e]) - return Effect.unit + return Effect.void } else { return Either.left(new TupleType(ast, input, [e], sortByIndex(output))) } } else { output.push([nk, t.right]) - return Effect.unit + return Effect.void } }) ) @@ -1101,13 +1101,13 @@ const go = (ast: AST.AST, isDecoding: boolean): Parser => { const e = new Index(index, t.left) if (allErrors) { es.push([nk, e]) - return Effect.unit + return Effect.void } else { return Either.left(new TupleType(ast, input, [e], sortByIndex(output))) } } output.push([nk, t.right]) - return Effect.unit + return Effect.void }) ) } @@ -1258,13 +1258,13 @@ const go = (ast: AST.AST, isDecoding: boolean): Parser => { const e = new Key(index, hasKey ? t.left : missing) if (allErrors) { es.push([nk, e]) - return Effect.unit + return Effect.void } else { return Either.left(new TypeLiteral(ast, input, [e], output)) } } output[index] = t.right - return Effect.unit + return Effect.void }) ) } @@ -1318,7 +1318,7 @@ const go = (ast: AST.AST, isDecoding: boolean): Parser => { const e = new Key(index, tv.left) if (allErrors) { es.push([nk, e]) - return Effect.unit + return Effect.void } else { return Either.left(new TypeLiteral(ast, input, [e], output)) } @@ -1326,7 +1326,7 @@ const go = (ast: AST.AST, isDecoding: boolean): Parser => { if (!Object.prototype.hasOwnProperty.call(expectedKeys, key)) { output[key] = tv.right } - return Effect.unit + return Effect.void } } ) @@ -1451,7 +1451,7 @@ const go = (ast: AST.AST, isDecoding: boolean): Parser => { (state) => Effect.suspend(() => { if ("finalResult" in state) { - return Effect.unit + return Effect.void } else { return Effect.flatMap(Effect.either(pr), (t) => { if (Either.isRight(t)) { @@ -1459,7 +1459,7 @@ const go = (ast: AST.AST, isDecoding: boolean): Parser => { } else { state.es.push([nk, new Member(candidate, t.left)]) } - return Effect.unit + return Effect.void }) } }) diff --git a/packages/schema/test/Schema/parseJson.test.ts b/packages/schema/test/Schema/parseJson.test.ts index ae94da8c42..a5a7a07810 100644 --- a/packages/schema/test/Schema/parseJson.test.ts +++ b/packages/schema/test/Schema/parseJson.test.ts @@ -106,8 +106,8 @@ describe("Schema > parseJson", () => { describe("roundtrip", () => { it("Exit", async () => { const schema = S.parseJson(S.Exit({ failure: S.Never, success: S.Void })) - const encoding = S.encodeSync(schema)(Exit.unit) - await Util.expectDecodeUnknownSuccess(schema, encoding, Exit.unit) + const encoding = S.encodeSync(schema)(Exit.void) + await Util.expectDecodeUnknownSuccess(schema, encoding, Exit.void) }) }) }) diff --git a/packages/typeclass/src/Covariant.ts b/packages/typeclass/src/Covariant.ts index e442cce9d8..b33e4f7085 100644 --- a/packages/typeclass/src/Covariant.ts +++ b/packages/typeclass/src/Covariant.ts @@ -69,7 +69,7 @@ export const as = (F: Covariant): { * @category mapping * @since 1.0.0 */ -export const asUnit = ( +export const asVoid = ( F: Covariant ): (self: Kind) => Kind => as(F)(undefined) diff --git a/packages/typeclass/src/Of.ts b/packages/typeclass/src/Of.ts index 4eb29f503c..f8ed2f30f0 100644 --- a/packages/typeclass/src/Of.ts +++ b/packages/typeclass/src/Of.ts @@ -22,13 +22,16 @@ export const ofComposition = ( ) => (a: A): Kind> => F.of(G.of(a)) -/** - * @since 1.0.0 - */ -export const unit = ( +const void_ = ( F: Of ): () => Kind => () => F.of(undefined) +export { + /** + * @since 1.0.0 + */ + void_ as void +} /** * @category do notation diff --git a/packages/typeclass/test/Covariant.test.ts b/packages/typeclass/test/Covariant.test.ts index c639a7bfd9..57dc43d028 100644 --- a/packages/typeclass/test/Covariant.test.ts +++ b/packages/typeclass/test/Covariant.test.ts @@ -34,10 +34,10 @@ describe.concurrent("Covariant", () => { U.deepStrictEqual(pipe(O.some(1), as(2)), O.some(2)) }) - it("asUnit", () => { - const asUnit = _.asUnit(OptionInstances.Covariant) - U.deepStrictEqual(pipe(O.none(), asUnit), O.none()) - U.deepStrictEqual(pipe(O.some(1), asUnit), O.some(undefined)) + it("asVoid", () => { + const asVoid = _.asVoid(OptionInstances.Covariant) + U.deepStrictEqual(pipe(O.none(), asVoid), O.none()) + U.deepStrictEqual(pipe(O.some(1), asVoid), O.some(undefined)) }) it("let", () => { diff --git a/packages/typeclass/test/Of.test.ts b/packages/typeclass/test/Of.test.ts index 3386f79b9c..a4d249d2f4 100644 --- a/packages/typeclass/test/Of.test.ts +++ b/packages/typeclass/test/Of.test.ts @@ -14,6 +14,6 @@ describe.concurrent("Of", () => { }) it("unit", () => { - U.deepStrictEqual(_.unit(OptionInstances.Pointed)(), O.some(undefined)) + U.deepStrictEqual(_.void(OptionInstances.Pointed)(), O.some(undefined)) }) })