From 80ea5477d362510144fa509b58464c9e70de4038 Mon Sep 17 00:00:00 2001 From: Giulio Canti Date: Thu, 15 Feb 2024 10:35:42 +0100 Subject: [PATCH] =?UTF-8?q?swap=20`Schedule`=20type=20parameters=20from=20?= =?UTF-8?q?`Schedule` to `Schedule`, closes #2154 +- swap `ScheduleDriver` type parameters from `ScheduleDriver` to `ScheduleDriver` diff --git a/packages/effect/mod.sh b/packages/effect/mod.sh index 4b67c47bc2..933d4c5923 100755 --- a/packages/effect/mod.sh +++ b/packages/effect/mod.sh @@ -1,5 +1,5 @@ #!/bin/bash -dirs=(../typeclass/src ../typeclass/test ../typeclass/dtslint) +dirs=(../effect/src ../effect/test) for dir in ${dirs[@]}; do echo Refactoring $dir diff --git a/packages/effect/mod.ts b/packages/effect/mod.ts index bebe7557f6..20e6a73909 100644 --- a/packages/effect/mod.ts +++ b/packages/effect/mod.ts @@ -2,7 +2,8 @@ import type k from "ast-types/gen/kinds.js" import type cs from "jscodeshift" const enabled = { - swapEitherParams: true, + swapScheduleParams: true, + swapEitherParams: false, swapLayerParams: false, swapSTMParams: false, swapSTMGenParams: false, @@ -148,12 +149,35 @@ const swapSTMParams = swapParamsREA("STM") const swapSTMGenParams = swapParamsREA("STMGen") const swapLayerParams = swapParamsREA("Layer") +// from: Schedule +// to: Schedule +const swapScheduleParams = (ast: cs.ASTPath) => { + const is = filter(ast, "Schedule") + if ( + is(ast.value.typeName) && + ast.value.typeParameters && + ast.value.typeParameters.params.length === 3 + ) { + const params = ast.value.typeParameters.params + const newParams = [params[2], params[1], params[0]] + popNever(newParams) + popUnknown(newParams) + ast.value.typeParameters.params = newParams + } +} + const popNever = (params: Array) => { if (params.length > 0 && params[params.length - 1].type === "TSNeverKeyword") { params.pop() } } +const popUnknown = (params: Array) => { + if (params.length > 0 && params[params.length - 1].type === "TSUnknownKeyword") { + params.pop() + } +} + export default function transformer(file: cs.FileInfo, api: cs.API) { const j = api.jscodeshift const root = j(file.source) @@ -173,6 +197,9 @@ export default function transformer(file: cs.FileInfo, api: cs.API) { } forEveryTypeReference(root, (ast) => { + if (enabled.swapScheduleParams) { + swapScheduleParams(ast) + } if (enabled.swapEitherParams) { swapEitherParams(ast) } diff --git a/packages/effect/src/Effect.ts b/packages/effect/src/Effect.ts index 0e957a86f1..aa91761d72 100644 --- a/packages/effect/src/Effect.ts +++ b/packages/effect/src/Effect.ts @@ -1737,13 +1737,13 @@ export declare namespace Retry { */ export type Return> = Effect< A, - | (O extends { schedule: Schedule.Schedule } ? E + | (O extends { schedule: Schedule.Schedule } ? E : O extends { until: Refinement } ? E2 : E) | (O extends { while: (...args: Array) => Effect } ? E : never) | (O extends { until: (...args: Array) => Effect } ? E : never), | R - | (O extends { schedule: Schedule.Schedule } ? R : never) + | (O extends { schedule: Schedule.Schedule } ? R : never) | (O extends { while: (...args: Array) => Effect } ? R : never) | (O extends { until: (...args: Array) => Effect } ? R : never) > extends infer Z ? Z : never @@ -1772,16 +1772,16 @@ export const retry: { ): ( self: Effect ) => Retry.Return - ( - policy: Schedule.Schedule, B> + ( + policy: Schedule.Schedule, R1> ): (self: Effect) => Effect >( self: Effect, options: O ): Retry.Return - ( + ( self: Effect, - policy: Schedule.Schedule + policy: Schedule.Schedule ): Effect } = _schedule.retry_combined @@ -1794,13 +1794,13 @@ export const retry: { * @category error handling */ export const retryOrElse: { - ( - policy: Schedule.Schedule, A1>, + ( + policy: Schedule.Schedule, R1>, orElse: (e: NoInfer, out: A1) => Effect ): (self: Effect) => Effect ( self: Effect, - policy: Schedule.Schedule, A1>, + policy: Schedule.Schedule, R1>, orElse: (e: NoInfer, out: A1) => Effect ): Effect } = _schedule.retryOrElse_Effect @@ -3936,14 +3936,14 @@ export declare namespace Repeat { * @category repetition / recursion */ export type Return> = Effect< - (O extends { schedule: Schedule.Schedule } ? Out + (O extends { schedule: Schedule.Schedule } ? Out : O extends { until: Refinement } ? B : A), | E | (O extends { while: (...args: Array) => Effect } ? E : never) | (O extends { until: (...args: Array) => Effect } ? E : never), | R - | (O extends { schedule: Schedule.Schedule } ? R : never) + | (O extends { schedule: Schedule.Schedule } ? R : never) | (O extends { while: (...args: Array) => Effect } ? R : never) | (O extends { until: (...args: Array) => Effect } ? R : never) > extends infer Z ? Z : never @@ -3971,19 +3971,19 @@ export declare namespace Repeat { * @category repetition / recursion */ export const repeat: { - >( + , A>( options: O ): ( self: Effect ) => Repeat.Return - ( - schedule: Schedule.Schedule + ( + schedule: Schedule.Schedule ): (self: Effect) => Effect >( self: Effect, options: O ): Repeat.Return - (self: Effect, schedule: Schedule.Schedule): Effect + (self: Effect, schedule: Schedule.Schedule): Effect } = _schedule.repeat_combined /** @@ -4014,12 +4014,12 @@ export const repeatN: { */ export const repeatOrElse: { ( - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, orElse: (error: E, option: Option.Option) => Effect ): (self: Effect) => Effect ( self: Effect, - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, orElse: (error: E, option: Option.Option) => Effect ): Effect } = _schedule.repeatOrElse_Effect @@ -4034,8 +4034,8 @@ export const repeatOrElse: { * @category repetition / recursion */ export const schedule: { - (schedule: Schedule.Schedule): (self: Effect) => Effect - (self: Effect, schedule: Schedule.Schedule): Effect + (schedule: Schedule.Schedule): (self: Effect) => Effect + (self: Effect, schedule: Schedule.Schedule): Effect } = _schedule.schedule_Effect /** @@ -4046,12 +4046,12 @@ export const schedule: { * @category repetition / recursion */ export const scheduleForked: { - ( - schedule: Schedule.Schedule + ( + schedule: Schedule.Schedule ): (self: Effect) => Effect, never, Scope.Scope | R2 | R> - ( + ( self: Effect, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ): Effect, never, Scope.Scope | R | R2> } = circular.scheduleForked @@ -4065,12 +4065,12 @@ export const scheduleForked: { export const scheduleFrom: { ( initial: In, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ): (self: Effect) => Effect ( self: Effect, initial: In, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ): Effect } = _schedule.scheduleFrom_Effect diff --git a/packages/effect/src/Layer.ts b/packages/effect/src/Layer.ts index 6d0c6fef9c..0da985fb98 100644 --- a/packages/effect/src/Layer.ts +++ b/packages/effect/src/Layer.ts @@ -597,12 +597,12 @@ export const fiberRefLocallyScopedWith: (self: FiberRef, value: (_: A) => * @category retrying */ export const retry: { - ( - schedule: Schedule.Schedule - ): (self: Layer) => Layer - ( + ( + schedule: Schedule.Schedule + ): (self: Layer) => Layer + ( self: Layer, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ): Layer } = internal.retry diff --git a/packages/effect/src/MetricPolling.ts b/packages/effect/src/MetricPolling.ts index 508e721eb7..023fd33ac0 100644 --- a/packages/effect/src/MetricPolling.ts +++ b/packages/effect/src/MetricPolling.ts @@ -70,14 +70,14 @@ export const collectAll: ( * @category utils */ export const launch: { - ( - schedule: Schedule.Schedule + ( + schedule: Schedule.Schedule ): ( self: MetricPolling - ) => Effect.Effect, never, Scope.Scope | R2 | R> - ( + ) => Effect.Effect, never, R2 | R | Scope.Scope> + ( self: MetricPolling, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ): Effect.Effect, never, Scope.Scope | R | R2> } = internal.launch @@ -108,12 +108,12 @@ export const pollAndUpdate: ( * @category constructors */ export const retry: { - ( - policy: Schedule.Schedule + <_, E, R2>( + policy: Schedule.Schedule<_, E, R2> ): (self: MetricPolling) => MetricPolling - ( + ( self: MetricPolling, - policy: Schedule.Schedule + policy: Schedule.Schedule<_, E, R2> ): MetricPolling } = internal.retry diff --git a/packages/effect/src/Reloadable.ts b/packages/effect/src/Reloadable.ts index f0d9720a7e..2530ba5ffb 100644 --- a/packages/effect/src/Reloadable.ts +++ b/packages/effect/src/Reloadable.ts @@ -62,11 +62,11 @@ export declare namespace Reloadable { * @since 2.0.0 * @category constructors */ -export const auto: , In, E, R>( +export const auto: , E, In, R>( tag: Out, options: { readonly layer: Layer.Layer, E, In> - readonly schedule: Schedule.Schedule + readonly schedule: Schedule.Schedule } ) => Layer.Layer>, E, In | R> = internal.auto @@ -78,11 +78,11 @@ export const auto: , In, E, R>( * @since 2.0.0 * @category constructors */ -export const autoFromConfig: , In, E, R>( +export const autoFromConfig: , E, In, R>( tag: Out, options: { readonly layer: Layer.Layer, E, In> - readonly scheduleFromConfig: (context: Context.Context) => Schedule.Schedule + readonly scheduleFromConfig: (context: Context.Context) => Schedule.Schedule } ) => Layer.Layer>, E, In | R> = internal.autoFromConfig diff --git a/packages/effect/src/Resource.ts b/packages/effect/src/Resource.ts index 4655ad10d1..dc9af2a864 100644 --- a/packages/effect/src/Resource.ts +++ b/packages/effect/src/Resource.ts @@ -61,10 +61,10 @@ export declare namespace Resource { * @since 2.0.0 * @category constructors */ -export const auto: ( +export const auto: ( acquire: Effect.Effect, - policy: Schedule.Schedule -) => Effect.Effect, never, Scope.Scope | R | R2> = internal.auto + policy: Schedule.Schedule +) => Effect.Effect, never, R | R2 | Scope.Scope> = internal.auto /** * Retrieves the current value stored in the cache. diff --git a/packages/effect/src/Schedule.ts b/packages/effect/src/Schedule.ts index 51f9650c3c..9e478fe67d 100644 --- a/packages/effect/src/Schedule.ts +++ b/packages/effect/src/Schedule.ts @@ -42,7 +42,7 @@ export const ScheduleDriverTypeId: unique symbol = internal.ScheduleDriverTypeId export type ScheduleDriverTypeId = typeof ScheduleDriverTypeId /** - * A `Schedule` defines a recurring schedule, which consumes + * A `Schedule` defines a recurring schedule, which consumes * values of type `In`, and which returns values of type `Out`. * * Schedules are defined as a possibly infinite set of intervals spread out over @@ -69,7 +69,7 @@ export type ScheduleDriverTypeId = typeof ScheduleDriverTypeId * @category model * @since 2.0.0 */ -export interface Schedule extends Schedule.Variance, Pipeable { +export interface Schedule extends Schedule.Variance, Pipeable { /** * Initial State */ @@ -81,7 +81,7 @@ export interface Schedule extends Schedule.Variance + ): Effect.Effect } /** @@ -92,22 +92,22 @@ export declare namespace Schedule { * @since 2.0.0 * @category models */ - export interface Variance { + export interface Variance { readonly [ScheduleTypeId]: { - readonly _Env: Types.Covariant - readonly _In: Types.Contravariant readonly _Out: Types.Covariant + readonly _In: Types.Contravariant + readonly _R: Types.Covariant } } /** * @since 2.0.0 */ - export interface DriverVariance { + export interface DriverVariance { readonly [ScheduleDriverTypeId]: { - readonly _Env: Types.Covariant - readonly _In: Types.Contravariant readonly _Out: Types.Covariant + readonly _In: Types.Contravariant + readonly _R: Types.Covariant } } } @@ -116,11 +116,11 @@ export declare namespace Schedule { * @since 2.0.0 * @category models */ -export interface ScheduleDriver extends Schedule.DriverVariance { +export interface ScheduleDriver extends Schedule.DriverVariance { readonly state: Effect.Effect readonly last: Effect.Effect readonly reset: Effect.Effect - next(input: In): Effect.Effect, Env> + next(input: In): Effect.Effect, R> } /** @@ -130,14 +130,14 @@ export interface ScheduleDriver extends Schedule.Driver * @since 2.0.0 * @category constructors */ -export const makeWithState: ( +export const makeWithState: ( initial: S, step: ( now: number, input: In, state: S - ) => Effect.Effect -) => Schedule = internal.makeWithState + ) => Effect.Effect +) => Schedule = internal.makeWithState /** * Returns a new schedule with the given delay added to every interval defined @@ -147,8 +147,8 @@ export const makeWithState: ( * @category utils */ export const addDelay: { - (f: (out: Out) => Duration.DurationInput): (self: Schedule) => Schedule - (self: Schedule, f: (out: Out) => Duration.DurationInput): Schedule + (f: (out: Out) => Duration.DurationInput): (self: Schedule) => Schedule + (self: Schedule, f: (out: Out) => Duration.DurationInput): Schedule } = internal.addDelay /** @@ -159,13 +159,13 @@ export const addDelay: { * @category utils */ export const addDelayEffect: { - ( - f: (out: Out) => Effect.Effect - ): (self: Schedule) => Schedule - ( - self: Schedule, - f: (out: Out) => Effect.Effect - ): Schedule + ( + f: (out: Out) => Effect.Effect + ): (self: Schedule) => Schedule + ( + self: Schedule, + f: (out: Out) => Effect.Effect + ): Schedule } = internal.addDelayEffect /** @@ -175,13 +175,13 @@ export const addDelayEffect: { * @category sequencing */ export const andThen: { - ( - that: Schedule - ): (self: Schedule) => Schedule - ( - self: Schedule, - that: Schedule - ): Schedule + ( + that: Schedule + ): (self: Schedule) => Schedule + ( + self: Schedule, + that: Schedule + ): Schedule } = internal.andThen /** @@ -192,13 +192,13 @@ export const andThen: { * @category sequencing */ export const andThenEither: { - ( - that: Schedule - ): (self: Schedule) => Schedule> - ( - self: Schedule, - that: Schedule - ): Schedule> + ( + that: Schedule + ): (self: Schedule) => Schedule, In & In2, R2 | R> + ( + self: Schedule, + that: Schedule + ): Schedule, In & In2, R | R2> } = internal.andThenEither /** @@ -208,8 +208,8 @@ export const andThenEither: { * @category mapping */ export const as: { - (out: Out2): (self: Schedule) => Schedule - (self: Schedule, out: Out2): Schedule + (out: Out2): (self: Schedule) => Schedule + (self: Schedule, out: Out2): Schedule } = internal.as /** @@ -218,7 +218,7 @@ export const as: { * @since 2.0.0 * @category constructors */ -export const asUnit: (self: Schedule) => Schedule = internal.asUnit +export const asUnit: (self: Schedule) => Schedule = internal.asUnit /** * Returns a new schedule that has both the inputs and outputs of this and the @@ -228,21 +228,13 @@ export const asUnit: (self: Schedule) => Schedule( - that: Schedule - ): (self: Schedule) => Schedule< - Env2 | Env, - readonly [In, In2], // readonly because contravariant - [Out, Out2] - > - ( - self: Schedule, - that: Schedule - ): Schedule< - Env | Env2, - readonly [In, In2], // readonly because contravariant - [Out, Out2] - > + ( + that: Schedule + ): (self: Schedule) => Schedule<[Out, Out2], readonly [In, In2], R2 | R> + ( + self: Schedule, + that: Schedule + ): Schedule<[Out, Out2], readonly [In, In2], R | R2> } = internal.bothInOut /** @@ -254,8 +246,8 @@ export const bothInOut: { * @category utils */ export const check: { - (test: (input: In, output: Out) => boolean): (self: Schedule) => Schedule - (self: Schedule, test: (input: In, output: Out) => boolean): Schedule + (test: (input: In, output: Out) => boolean): (self: Schedule) => Schedule + (self: Schedule, test: (input: In, output: Out) => boolean): Schedule } = internal.check /** @@ -267,13 +259,13 @@ export const check: { * @category utils */ export const checkEffect: { - ( - test: (input: In, output: Out) => Effect.Effect - ): (self: Schedule) => Schedule - ( - self: Schedule, - test: (input: In, output: Out) => Effect.Effect - ): Schedule + ( + test: (input: In, output: Out) => Effect.Effect + ): (self: Schedule) => Schedule + ( + self: Schedule, + test: (input: In, output: Out) => Effect.Effect + ): Schedule } = internal.checkEffect /** @@ -282,7 +274,7 @@ export const checkEffect: { * @since 2.0.0 * @category constructors */ -export const collectAllInputs: () => Schedule> = internal.collectAllInputs +export const collectAllInputs: () => Schedule, A> = internal.collectAllInputs /** * Returns a new schedule that collects the outputs of this one into a chunk. @@ -290,7 +282,7 @@ export const collectAllInputs: () => Schedule> = int * @since 2.0.0 * @category utils */ -export const collectAllOutputs: (self: Schedule) => Schedule> = +export const collectAllOutputs: (self: Schedule) => Schedule, In, R> = internal.collectAllOutputs /** @@ -300,7 +292,7 @@ export const collectAllOutputs: (self: Schedule) => * @since 2.0.0 * @category utils */ -export const collectUntil: (f: Predicate) => Schedule> = internal.collectUntil +export const collectUntil: (f: Predicate) => Schedule, A> = internal.collectUntil /** * A schedule that recurs until the effectful condition f fails, collecting @@ -309,9 +301,9 @@ export const collectUntil: (f: Predicate) => Schedule( - f: (a: A) => Effect.Effect -) => Schedule> = internal.collectUntilEffect +export const collectUntilEffect: ( + f: (a: A) => Effect.Effect +) => Schedule, A, R> = internal.collectUntilEffect /** * A schedule that recurs as long as the condition f holds, collecting all @@ -320,7 +312,7 @@ export const collectUntilEffect: ( * @since 2.0.0 * @category utils */ -export const collectWhile: (f: Predicate) => Schedule> = internal.collectWhile +export const collectWhile: (f: Predicate) => Schedule, A> = internal.collectWhile /** * A schedule that recurs as long as the effectful condition holds, collecting @@ -329,9 +321,9 @@ export const collectWhile: (f: Predicate) => Schedule( - f: (a: A) => Effect.Effect -) => Schedule> = internal.collectWhileEffect +export const collectWhileEffect: ( + f: (a: A) => Effect.Effect +) => Schedule, A, R> = internal.collectWhileEffect /** * Returns the composition of this schedule and the specified schedule, by @@ -343,13 +335,8 @@ export const collectWhileEffect: ( * @category utils */ export const compose: { - ( - that: Schedule - ): (self: Schedule) => Schedule - ( - self: Schedule, - that: Schedule - ): Schedule + (that: Schedule): (self: Schedule) => Schedule + (self: Schedule, that: Schedule): Schedule } = internal.compose /** @@ -360,8 +347,8 @@ export const compose: { * @category mapping */ export const mapInput: { - (f: (in2: In2) => In): (self: Schedule) => Schedule - (self: Schedule, f: (in2: In2) => In): Schedule + (f: (in2: In2) => In): (self: Schedule) => Schedule + (self: Schedule, f: (in2: In2) => In): Schedule } = internal.mapInput /** @@ -372,13 +359,13 @@ export const mapInput: { * @category context */ export const mapInputContext: { - ( - f: (env0: Context.Context) => Context.Context - ): (self: Schedule) => Schedule - ( - self: Schedule, - f: (env0: Context.Context) => Context.Context - ): Schedule + ( + f: (env0: Context.Context) => Context.Context + ): (self: Schedule) => Schedule + ( + self: Schedule, + f: (env0: Context.Context) => Context.Context + ): Schedule } = internal.mapInputContext /** @@ -389,13 +376,13 @@ export const mapInputContext: { * @category mapping */ export const mapInputEffect: { - ( - f: (in2: In2) => Effect.Effect - ): (self: Schedule) => Schedule - ( - self: Schedule, - f: (in2: In2) => Effect.Effect - ): Schedule + ( + f: (in2: In2) => Effect.Effect + ): (self: Schedule) => Schedule + ( + self: Schedule, + f: (in2: In2) => Effect.Effect + ): Schedule } = internal.mapInputEffect /** @@ -404,7 +391,7 @@ export const mapInputEffect: { * @since 2.0.0 * @category constructors */ -export const count: Schedule = internal.count +export const count: Schedule = internal.count /** * Cron schedule that recurs every `minute` that matches the schedule. @@ -416,7 +403,7 @@ export const count: Schedule = internal.count * @since 2.0.0 * @category constructors */ -export const cron: (expression: string | Cron.Cron) => Schedule = internal.cron +export const cron: (expression: string | Cron.Cron) => Schedule<[number, number]> = internal.cron /** * Cron-like schedule that recurs every specified `day` of month. Won't recur @@ -429,7 +416,7 @@ export const cron: (expression: string | Cron.Cron) => Schedule Schedule = internal.dayOfMonth +export const dayOfMonth: (day: number) => Schedule = internal.dayOfMonth /** * Cron-like schedule that recurs every specified `day` of each week. It @@ -441,7 +428,7 @@ export const dayOfMonth: (day: number) => Schedule = int * @since 2.0.0 * @category constructors */ -export const dayOfWeek: (day: number) => Schedule = internal.dayOfWeek +export const dayOfWeek: (day: number) => Schedule = internal.dayOfWeek /** * Returns a new schedule with the specified effectfully computed delay added @@ -453,11 +440,11 @@ export const dayOfWeek: (day: number) => Schedule = inte export const delayed: { ( f: (duration: Duration.Duration) => Duration.DurationInput - ): (self: Schedule) => Schedule - ( - self: Schedule, + ): (self: Schedule) => Schedule + ( + self: Schedule, f: (duration: Duration.Duration) => Duration.DurationInput - ): Schedule + ): Schedule } = internal.delayed /** @@ -468,13 +455,13 @@ export const delayed: { * @category constructors */ export const delayedEffect: { - ( - f: (duration: Duration.Duration) => Effect.Effect - ): (self: Schedule) => Schedule - ( - self: Schedule, - f: (duration: Duration.Duration) => Effect.Effect - ): Schedule + ( + f: (duration: Duration.Duration) => Effect.Effect + ): (self: Schedule) => Schedule + ( + self: Schedule, + f: (duration: Duration.Duration) => Effect.Effect + ): Schedule } = internal.delayedEffect /** @@ -484,9 +471,9 @@ export const delayedEffect: { * @since 2.0.0 * @category constructors */ -export const delayedSchedule: ( - schedule: Schedule -) => Schedule = internal.delayedSchedule +export const delayedSchedule: ( + schedule: Schedule +) => Schedule = internal.delayedSchedule /** * Returns a new schedule that outputs the delay between each occurence. @@ -494,8 +481,7 @@ export const delayedSchedule: ( * @since 2.0.0 * @category constructors */ -export const delays: (self: Schedule) => Schedule = - internal.delays +export const delays: (self: Schedule) => Schedule = internal.delays /** * Returns a new schedule that maps both the input and output. @@ -504,19 +490,13 @@ export const delays: (self: Schedule) => Schedule( - options: { - readonly onInput: (in2: In2) => In - readonly onOutput: (out: Out) => Out2 - } - ): (self: Schedule) => Schedule - ( - self: Schedule, - options: { - readonly onInput: (in2: In2) => In - readonly onOutput: (out: Out) => Out2 - } - ): Schedule + ( + options: { readonly onInput: (in2: In2) => In; readonly onOutput: (out: Out) => Out2 } + ): (self: Schedule) => Schedule + ( + self: Schedule, + options: { readonly onInput: (in2: In2) => In; readonly onOutput: (out: Out) => Out2 } + ): Schedule } = internal.mapBoth /** @@ -526,19 +506,19 @@ export const mapBoth: { * @category mapping */ export const mapBothEffect: { - ( + ( options: { - readonly onInput: (input: In2) => Effect.Effect - readonly onOutput: (out: Out) => Effect.Effect + readonly onInput: (input: In2) => Effect.Effect + readonly onOutput: (out: Out) => Effect.Effect } - ): (self: Schedule) => Schedule - ( - self: Schedule, + ): (self: Schedule) => Schedule + ( + self: Schedule, options: { - readonly onInput: (input: In2) => Effect.Effect - readonly onOutput: (out: Out) => Effect.Effect + readonly onInput: (input: In2) => Effect.Effect + readonly onOutput: (out: Out) => Effect.Effect } - ): Schedule + ): Schedule } = internal.mapBothEffect /** @@ -548,9 +528,9 @@ export const mapBothEffect: { * @since 2.0.0 * @category getter */ -export const driver: ( - self: Schedule -) => Effect.Effect> = internal.driver +export const driver: ( + self: Schedule +) => Effect.Effect> = internal.driver /** * A schedule that can recur one time, the specified amount of time into the @@ -559,8 +539,7 @@ export const driver: ( * @since 2.0.0 * @category constructors */ -export const duration: (duration: Duration.DurationInput) => Schedule = - internal.duration +export const duration: (duration: Duration.DurationInput) => Schedule = internal.duration /** * Returns a new schedule that performs a geometric union on the intervals @@ -570,13 +549,13 @@ export const duration: (duration: Duration.DurationInput) => Schedule( - that: Schedule - ): (self: Schedule) => Schedule - ( - self: Schedule, - that: Schedule - ): Schedule + ( + that: Schedule + ): (self: Schedule) => Schedule<[Out, Out2], In & In2, R2 | R> + ( + self: Schedule, + that: Schedule + ): Schedule<[Out, Out2], In & In2, R | R2> } = internal.either /** @@ -586,15 +565,15 @@ export const either: { * @category alternatives */ export const eitherWith: { - ( - that: Schedule, + ( + that: Schedule, f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals - ): (self: Schedule) => Schedule - ( - self: Schedule, - that: Schedule, + ): (self: Schedule) => Schedule<[Out, Out2], In & In2, R2 | R> + ( + self: Schedule, + that: Schedule, f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals - ): Schedule + ): Schedule<[Out, Out2], In & In2, R | R2> } = internal.eitherWith /** @@ -604,7 +583,7 @@ export const eitherWith: { * @since 2.0.0 * @category constructors */ -export const elapsed: Schedule = internal.elapsed +export const elapsed: Schedule = internal.elapsed /** * Returns a new schedule that will run the specified finalizer as soon as the @@ -617,8 +596,8 @@ export const elapsed: Schedule = internal.ela * @category finalization */ export const ensuring: { - (finalizer: Effect.Effect): (self: Schedule) => Schedule - (self: Schedule, finalizer: Effect.Effect): Schedule + (finalizer: Effect.Effect): (self: Schedule) => Schedule + (self: Schedule, finalizer: Effect.Effect): Schedule } = internal.ensuring /** @@ -632,7 +611,7 @@ export const ensuring: { export const exponential: ( base: Duration.DurationInput, factor?: number -) => Schedule = internal.exponential +) => Schedule = internal.exponential /** * A schedule that always recurs, increasing delays by summing the preceding @@ -642,8 +621,7 @@ export const exponential: ( * @since 2.0.0 * @category constructors */ -export const fibonacci: (one: Duration.DurationInput) => Schedule = - internal.fibonacci +export const fibonacci: (one: Duration.DurationInput) => Schedule = internal.fibonacci /** * A schedule that recurs on a fixed interval. Returns the number of @@ -660,7 +638,7 @@ export const fibonacci: (one: Duration.DurationInput) => Schedule Schedule = internal.fixed +export const fixed: (interval: Duration.DurationInput) => Schedule = internal.fixed /** * A schedule that always recurs, producing a count of repeats: 0, 1, 2. @@ -668,7 +646,7 @@ export const fixed: (interval: Duration.DurationInput) => Schedule = internal.forever +export const forever: Schedule = internal.forever /** * A schedule that recurs once with the specified delay. @@ -676,8 +654,7 @@ export const forever: Schedule = internal.forever * @since 2.0.0 * @category constructors */ -export const fromDelay: (delay: Duration.DurationInput) => Schedule = - internal.fromDelay +export const fromDelay: (delay: Duration.DurationInput) => Schedule = internal.fromDelay /** * A schedule that recurs once for each of the specified durations, delaying @@ -690,7 +667,7 @@ export const fromDelay: (delay: Duration.DurationInput) => Schedule -) => Schedule = internal.fromDelays +) => Schedule = internal.fromDelays /** * A schedule that always recurs, mapping input values through the specified @@ -699,7 +676,7 @@ export const fromDelays: ( * @since 2.0.0 * @category constructors */ -export const fromFunction: (f: (a: A) => B) => Schedule = internal.fromFunction +export const fromFunction: (f: (a: A) => B) => Schedule = internal.fromFunction /** * Cron-like schedule that recurs every specified `hour` of each day. It @@ -710,7 +687,7 @@ export const fromFunction: (f: (a: A) => B) => Schedule = int * @since 2.0.0 * @category constructors */ -export const hourOfDay: (hour: number) => Schedule = internal.hourOfDay +export const hourOfDay: (hour: number) => Schedule = internal.hourOfDay /** * A schedule that always recurs, which returns inputs as outputs. @@ -718,7 +695,7 @@ export const hourOfDay: (hour: number) => Schedule = int * @since 2.0.0 * @category constructors */ -export const identity: () => Schedule = internal.identity +export const identity: () => Schedule = internal.identity /** * Returns a new schedule that performs a geometric intersection on the @@ -728,13 +705,13 @@ export const identity: () => Schedule = internal.identity * @category utils */ export const intersect: { - ( - that: Schedule - ): (self: Schedule) => Schedule - ( - self: Schedule, - that: Schedule - ): Schedule + ( + that: Schedule + ): (self: Schedule) => Schedule<[Out, Out2], In & In2, R2 | R> + ( + self: Schedule, + that: Schedule + ): Schedule<[Out, Out2], In & In2, R | R2> } = internal.intersect /** @@ -746,15 +723,15 @@ export const intersect: { * @category utils */ export const intersectWith: { - ( - that: Schedule, + ( + that: Schedule, f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals - ): (self: Schedule) => Schedule - ( - self: Schedule, - that: Schedule, + ): (self: Schedule) => Schedule<[Out, Out2], In & In2, R2 | R> + ( + self: Schedule, + that: Schedule, f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals - ): Schedule + ): Schedule<[Out, Out2], In & In2, R | R2> } = internal.intersectWith /** @@ -769,7 +746,7 @@ export const intersectWith: { * @since 2.0.0 * @category constructors */ -export const jittered: (self: Schedule) => Schedule = internal.jittered +export const jittered: (self: Schedule) => Schedule = internal.jittered /** * Returns a new schedule that randomly modifies the size of the intervals of @@ -782,13 +759,13 @@ export const jittered: (self: Schedule) => Schedule< * @category constructors */ export const jitteredWith: { - (options: { min?: number; max?: number }): ( - self: Schedule - ) => Schedule - ( - self: Schedule, - options: { min?: number; max?: number } - ): Schedule + ( + options: { min?: number | undefined; max?: number | undefined } + ): (self: Schedule) => Schedule + ( + self: Schedule, + options: { min?: number | undefined; max?: number | undefined } + ): Schedule } = internal.jitteredWith /** @@ -799,7 +776,7 @@ export const jitteredWith: { * @since 2.0.0 * @category constructors */ -export const linear: (base: Duration.DurationInput) => Schedule = internal.linear +export const linear: (base: Duration.DurationInput) => Schedule = internal.linear /** * Returns a new schedule that maps the output of this schedule through the @@ -809,8 +786,8 @@ export const linear: (base: Duration.DurationInput) => Schedule(f: (out: Out) => Out2): (self: Schedule) => Schedule - (self: Schedule, f: (out: Out) => Out2): Schedule + (f: (out: Out) => Out2): (self: Schedule) => Schedule + (self: Schedule, f: (out: Out) => Out2): Schedule } = internal.map /** @@ -821,13 +798,13 @@ export const map: { * @category mapping */ export const mapEffect: { - ( - f: (out: Out) => Effect.Effect - ): (self: Schedule) => Schedule - ( - self: Schedule, - f: (out: Out) => Effect.Effect - ): Schedule + ( + f: (out: Out) => Effect.Effect + ): (self: Schedule) => Schedule + ( + self: Schedule, + f: (out: Out) => Effect.Effect + ): Schedule } = internal.mapEffect /** @@ -840,7 +817,7 @@ export const mapEffect: { * @since 2.0.0 * @category constructors */ -export const minuteOfHour: (minute: number) => Schedule = internal.minuteOfHour +export const minuteOfHour: (minute: number) => Schedule = internal.minuteOfHour /** * Returns a new schedule that modifies the delay using the specified @@ -852,11 +829,11 @@ export const minuteOfHour: (minute: number) => Schedule export const modifyDelay: { ( f: (out: Out, duration: Duration.Duration) => Duration.DurationInput - ): (self: Schedule) => Schedule - ( - self: Schedule, + ): (self: Schedule) => Schedule + ( + self: Schedule, f: (out: Out, duration: Duration.Duration) => Duration.DurationInput - ): Schedule + ): Schedule } = internal.modifyDelay /** @@ -867,13 +844,13 @@ export const modifyDelay: { * @category utils */ export const modifyDelayEffect: { - ( - f: (out: Out, duration: Duration.Duration) => Effect.Effect - ): (self: Schedule) => Schedule - ( - self: Schedule, - f: (out: Out, duration: Duration.Duration) => Effect.Effect - ): Schedule + ( + f: (out: Out, duration: Duration.Duration) => Effect.Effect + ): (self: Schedule) => Schedule + ( + self: Schedule, + f: (out: Out, duration: Duration.Duration) => Effect.Effect + ): Schedule } = internal.modifyDelayEffect /** @@ -885,13 +862,13 @@ export const modifyDelayEffect: { * @category utils */ export const onDecision: { - ( - f: (out: Out, decision: ScheduleDecision.ScheduleDecision) => Effect.Effect - ): (self: Schedule) => Schedule - ( - self: Schedule, - f: (out: Out, decision: ScheduleDecision.ScheduleDecision) => Effect.Effect - ): Schedule + ( + f: (out: Out, decision: ScheduleDecision.ScheduleDecision) => Effect.Effect + ): (self: Schedule) => Schedule + ( + self: Schedule, + f: (out: Out, decision: ScheduleDecision.ScheduleDecision) => Effect.Effect + ): Schedule } = internal.onDecision /** @@ -900,7 +877,7 @@ export const onDecision: { * @since 2.0.0 * @category constructors */ -export const once: Schedule = internal.once +export const once: Schedule = internal.once /** * Returns a new schedule that passes through the inputs of this schedule. @@ -908,8 +885,7 @@ export const once: Schedule = internal.once * @since 2.0.0 * @category utils */ -export const passthrough: (self: Schedule) => Schedule = - internal.passthrough +export const passthrough: (self: Schedule) => Schedule = internal.passthrough /** * Returns a new schedule with its context provided to it, so the @@ -919,8 +895,8 @@ export const passthrough: (self: Schedule(context: Context.Context): (self: Schedule) => Schedule - (self: Schedule, context: Context.Context): Schedule + (context: Context.Context): (self: Schedule) => Schedule + (self: Schedule, context: Context.Context): Schedule } = internal.provideContext /** @@ -932,15 +908,15 @@ export const provideContext: { * @category context */ export const provideService: { - ( - tag: any, - service: T1 - ): (self: Schedule) => Schedule, In, Out> - ( - self: Schedule, - tag: any, - service: T1 - ): Schedule, In, Out> + >( + tag: T, + service: Context.Tag.Service + ): (self: Schedule) => Schedule>> + >( + self: Schedule, + tag: T, + service: Context.Tag.Service + ): Schedule>> } = internal.provideService /** @@ -949,7 +925,7 @@ export const provideService: { * @since 2.0.0 * @category utils */ -export const recurUntil: (f: Predicate) => Schedule = internal.recurUntil +export const recurUntil: (f: Predicate) => Schedule = internal.recurUntil /** * A schedule that recurs for until the predicate evaluates to true. @@ -957,7 +933,7 @@ export const recurUntil: (f: Predicate) => Schedule = interna * @since 2.0.0 * @category utils */ -export const recurUntilEffect: (f: (a: A) => Effect.Effect) => Schedule = +export const recurUntilEffect: (f: (a: A) => Effect.Effect) => Schedule = internal.recurUntilEffect /** @@ -967,7 +943,7 @@ export const recurUntilEffect: (f: (a: A) => Effect.Effect(pf: (a: A) => Option.Option) => Schedule> = +export const recurUntilOption: (pf: (a: A) => Option.Option) => Schedule, A> = internal.recurUntilOption /** @@ -976,8 +952,7 @@ export const recurUntilOption: (pf: (a: A) => Option.Option) => Schedul * @since 2.0.0 * @category utils */ -export const recurUpTo: (duration: Duration.DurationInput) => Schedule = - internal.recurUpTo +export const recurUpTo: (duration: Duration.DurationInput) => Schedule = internal.recurUpTo /** * A schedule that recurs for as long as the predicate evaluates to true. @@ -985,7 +960,7 @@ export const recurUpTo: (duration: Duration.DurationInput) => Schedule(f: Predicate) => Schedule = internal.recurWhile +export const recurWhile: (f: Predicate) => Schedule = internal.recurWhile /** * A schedule that recurs for as long as the effectful predicate evaluates to @@ -994,7 +969,7 @@ export const recurWhile: (f: Predicate) => Schedule = interna * @since 2.0.0 * @category utils */ -export const recurWhileEffect: (f: (a: A) => Effect.Effect) => Schedule = +export const recurWhileEffect: (f: (a: A) => Effect.Effect) => Schedule = internal.recurWhileEffect /** @@ -1004,7 +979,7 @@ export const recurWhileEffect: (f: (a: A) => Effect.Effect Schedule = internal.recurs +export const recurs: (n: number) => Schedule = internal.recurs /** * Returns a new schedule that folds over the outputs of this one. @@ -1013,8 +988,8 @@ export const recurs: (n: number) => Schedule = internal. * @category folding */ export const reduce: { - (zero: Z, f: (z: Z, out: Out) => Z): (self: Schedule) => Schedule - (self: Schedule, zero: Z, f: (z: Z, out: Out) => Z): Schedule + (zero: Z, f: (z: Z, out: Out) => Z): (self: Schedule) => Schedule + (self: Schedule, zero: Z, f: (z: Z, out: Out) => Z): Schedule } = internal.reduce /** @@ -1024,15 +999,15 @@ export const reduce: { * @category folding */ export const reduceEffect: { - ( + ( zero: Z, - f: (z: Z, out: Out) => Effect.Effect - ): (self: Schedule) => Schedule - ( - self: Schedule, + f: (z: Z, out: Out) => Effect.Effect + ): (self: Schedule) => Schedule + ( + self: Schedule, zero: Z, - f: (z: Z, out: Out) => Effect.Effect - ): Schedule + f: (z: Z, out: Out) => Effect.Effect + ): Schedule } = internal.reduceEffect /** @@ -1042,7 +1017,7 @@ export const reduceEffect: { * @since 2.0.0 * @category constructors */ -export const repeatForever: Schedule = internal.forever +export const repeatForever: Schedule = internal.forever /** * Returns a new schedule that outputs the number of repetitions of this one. @@ -1050,8 +1025,7 @@ export const repeatForever: Schedule = internal.forever * @since 2.0.0 * @category utils */ -export const repetitions: (self: Schedule) => Schedule = - internal.repetitions +export const repetitions: (self: Schedule) => Schedule = internal.repetitions /** * Return a new schedule that automatically resets the schedule to its initial @@ -1061,8 +1035,8 @@ export const repetitions: (self: Schedule) => Schedu * @category utils */ export const resetAfter: { - (duration: Duration.DurationInput): (self: Schedule) => Schedule - (self: Schedule, duration: Duration.DurationInput): Schedule + (duration: Duration.DurationInput): (self: Schedule) => Schedule + (self: Schedule, duration: Duration.DurationInput): Schedule } = internal.resetAfter /** @@ -1073,8 +1047,8 @@ export const resetAfter: { * @category utils */ export const resetWhen: { - (f: Predicate): (self: Schedule) => Schedule - (self: Schedule, f: Predicate): Schedule + (f: Predicate): (self: Schedule) => Schedule + (self: Schedule, f: Predicate): Schedule } = internal.resetWhen /** @@ -1087,12 +1061,8 @@ export const run: { ( now: number, input: Iterable - ): (self: Schedule) => Effect.Effect, never, Env> - ( - self: Schedule, - now: number, - input: Iterable - ): Effect.Effect, never, Env> + ): (self: Schedule) => Effect.Effect, never, R> + (self: Schedule, now: number, input: Iterable): Effect.Effect, never, R> } = internal.run /** @@ -1105,7 +1075,7 @@ export const run: { * @since 2.0.0 * @category constructors */ -export const secondOfMinute: (second: number) => Schedule = internal.secondOfMinute +export const secondOfMinute: (second: number) => Schedule = internal.secondOfMinute /** * Returns a schedule that recurs continuously, each repetition spaced the @@ -1114,7 +1084,7 @@ export const secondOfMinute: (second: number) => Schedule Schedule = internal.spaced +export const spaced: (duration: Duration.DurationInput) => Schedule = internal.spaced /** * A schedule that does not recur, it just stops. @@ -1122,7 +1092,7 @@ export const spaced: (duration: Duration.DurationInput) => Schedule = internal.stop +export const stop: Schedule = internal.stop /** * Returns a schedule that repeats one time, producing the specified constant @@ -1131,7 +1101,7 @@ export const stop: Schedule = internal.stop * @since 2.0.0 * @category constructors */ -export const succeed: (value: A) => Schedule = internal.succeed +export const succeed: (value: A) => Schedule = internal.succeed /** * Returns a schedule that repeats one time, producing the specified constant @@ -1140,7 +1110,7 @@ export const succeed: (value: A) => Schedule = internal.su * @category constructors * @since 2.0.0 */ -export const sync: (evaluate: LazyArg) => Schedule = internal.sync +export const sync: (evaluate: LazyArg) => Schedule = internal.sync /** * Returns a new schedule that effectfully processes every input to this @@ -1150,13 +1120,13 @@ export const sync: (evaluate: LazyArg) => Schedule = in * @category sequencing */ export const tapInput: { - ( - f: (input: In2) => Effect.Effect - ): (self: Schedule) => Schedule - ( - self: Schedule, - f: (input: In2) => Effect.Effect - ): Schedule + ( + f: (input: In2) => Effect.Effect + ): (self: Schedule) => Schedule + ( + self: Schedule, + f: (input: In2) => Effect.Effect + ): Schedule } = internal.tapInput /** @@ -1167,13 +1137,13 @@ export const tapInput: { * @category sequencing */ export const tapOutput: { - ( - f: (out: XO) => Effect.Effect - ): (self: Schedule) => Schedule - ( - self: Schedule, - f: (out: XO) => Effect.Effect - ): Schedule + ( + f: (out: XO) => Effect.Effect + ): (self: Schedule) => Schedule + ( + self: Schedule, + f: (out: XO) => Effect.Effect + ): Schedule } = internal.tapOutput /** @@ -1183,7 +1153,7 @@ export const tapOutput: { * @since 2.0.0 * @category constructors */ -export const unfold: (initial: A, f: (a: A) => A) => Schedule = internal.unfold +export const unfold: (initial: A, f: (a: A) => A) => Schedule = internal.unfold /** * Returns a new schedule that performs a geometric union on the intervals @@ -1193,13 +1163,13 @@ export const unfold: (initial: A, f: (a: A) => A) => Schedule( - that: Schedule - ): (self: Schedule) => Schedule - ( - self: Schedule, - that: Schedule - ): Schedule + ( + that: Schedule + ): (self: Schedule) => Schedule<[Out, Out2], In & In2, R2 | R> + ( + self: Schedule, + that: Schedule + ): Schedule<[Out, Out2], In & In2, R | R2> } = internal.union /** @@ -1211,15 +1181,15 @@ export const union: { * @category utils */ export const unionWith: { - ( - that: Schedule, + ( + that: Schedule, f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals - ): (self: Schedule) => Schedule - ( - self: Schedule, - that: Schedule, + ): (self: Schedule) => Schedule<[Out, Out2], In & In2, R2 | R> + ( + self: Schedule, + that: Schedule, f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals - ): Schedule + ): Schedule<[Out, Out2], In & In2, R | R2> } = internal.unionWith /** @@ -1230,8 +1200,8 @@ export const unionWith: { * @category utils */ export const untilInput: { - (f: Predicate): (self: Schedule) => Schedule - (self: Schedule, f: Predicate): Schedule + (f: Predicate): (self: Schedule) => Schedule + (self: Schedule, f: Predicate): Schedule } = internal.untilInput /** @@ -1242,13 +1212,13 @@ export const untilInput: { * @category utils */ export const untilInputEffect: { - ( - f: (input: In) => Effect.Effect - ): (self: Schedule) => Schedule - ( - self: Schedule, - f: (input: In) => Effect.Effect - ): Schedule + ( + f: (input: In) => Effect.Effect + ): (self: Schedule) => Schedule + ( + self: Schedule, + f: (input: In) => Effect.Effect + ): Schedule } = internal.untilInputEffect /** @@ -1259,8 +1229,8 @@ export const untilInputEffect: { * @category utils */ export const untilOutput: { - (f: Predicate): (self: Schedule) => Schedule - (self: Schedule, f: Predicate): Schedule + (f: Predicate): (self: Schedule) => Schedule + (self: Schedule, f: Predicate): Schedule } = internal.untilOutput /** @@ -1271,13 +1241,13 @@ export const untilOutput: { * @category utils */ export const untilOutputEffect: { - ( - f: (out: Out) => Effect.Effect - ): (self: Schedule) => Schedule - ( - self: Schedule, - f: (out: Out) => Effect.Effect - ): Schedule + ( + f: (out: Out) => Effect.Effect + ): (self: Schedule) => Schedule + ( + self: Schedule, + f: (out: Out) => Effect.Effect + ): Schedule } = internal.untilOutputEffect /** @@ -1287,8 +1257,8 @@ export const untilOutputEffect: { * @category utils */ export const upTo: { - (duration: Duration.DurationInput): (self: Schedule) => Schedule - (self: Schedule, duration: Duration.DurationInput): Schedule + (duration: Duration.DurationInput): (self: Schedule) => Schedule + (self: Schedule, duration: Duration.DurationInput): Schedule } = internal.upTo /** @@ -1299,8 +1269,8 @@ export const upTo: { * @category utils */ export const whileInput: { - (f: Predicate): (self: Schedule) => Schedule - (self: Schedule, f: Predicate): Schedule + (f: Predicate): (self: Schedule) => Schedule + (self: Schedule, f: Predicate): Schedule } = internal.whileInput /** @@ -1311,13 +1281,13 @@ export const whileInput: { * @category utils */ export const whileInputEffect: { - ( - f: (input: In) => Effect.Effect - ): (self: Schedule) => Schedule - ( - self: Schedule, - f: (input: In) => Effect.Effect - ): Schedule + ( + f: (input: In) => Effect.Effect + ): (self: Schedule) => Schedule + ( + self: Schedule, + f: (input: In) => Effect.Effect + ): Schedule } = internal.whileInputEffect /** @@ -1328,8 +1298,8 @@ export const whileInputEffect: { * @category utils */ export const whileOutput: { - (f: Predicate): (self: Schedule) => Schedule - (self: Schedule, f: Predicate): Schedule + (f: Predicate): (self: Schedule) => Schedule + (self: Schedule, f: Predicate): Schedule } = internal.whileOutput /** @@ -1340,13 +1310,13 @@ export const whileOutput: { * @category utils */ export const whileOutputEffect: { - ( - f: (out: Out) => Effect.Effect - ): (self: Schedule) => Schedule - ( - self: Schedule, - f: (out: Out) => Effect.Effect - ): Schedule + ( + f: (out: Out) => Effect.Effect + ): (self: Schedule) => Schedule + ( + self: Schedule, + f: (out: Out) => Effect.Effect + ): Schedule } = internal.whileOutputEffect /** @@ -1365,7 +1335,7 @@ export const whileOutputEffect: { * @since 2.0.0 * @category constructors */ -export const windowed: (interval: Duration.DurationInput) => Schedule = internal.windowed +export const windowed: (interval: Duration.DurationInput) => Schedule = internal.windowed /** * The same as `intersect` but ignores the right output. @@ -1374,13 +1344,13 @@ export const windowed: (interval: Duration.DurationInput) => Schedule( - that: Schedule - ): (self: Schedule) => Schedule - ( - self: Schedule, - that: Schedule - ): Schedule + ( + that: Schedule + ): (self: Schedule) => Schedule + ( + self: Schedule, + that: Schedule + ): Schedule } = internal.zipLeft /** @@ -1390,13 +1360,13 @@ export const zipLeft: { * @category zipping */ export const zipRight: { - ( - that: Schedule - ): (self: Schedule) => Schedule - ( - self: Schedule, - that: Schedule - ): Schedule + ( + that: Schedule + ): (self: Schedule) => Schedule + ( + self: Schedule, + that: Schedule + ): Schedule } = internal.zipRight /** @@ -1406,13 +1376,13 @@ export const zipRight: { * @category zipping */ export const zipWith: { - ( - that: Schedule, + ( + that: Schedule, f: (out: Out, out2: Out2) => Out3 - ): (self: Schedule) => Schedule - ( - self: Schedule, - that: Schedule, + ): (self: Schedule) => Schedule + ( + self: Schedule, + that: Schedule, f: (out: Out, out2: Out2) => Out3 - ): Schedule + ): Schedule } = internal.zipWith diff --git a/packages/effect/src/Stream.ts b/packages/effect/src/Stream.ts index 1aec5a0b18..51308bdd3e 100644 --- a/packages/effect/src/Stream.ts +++ b/packages/effect/src/Stream.ts @@ -204,14 +204,14 @@ export const aggregate: { * @category utils */ export const aggregateWithin: { - ( + ( sink: Sink.Sink, - schedule: Schedule.Schedule, C> + schedule: Schedule.Schedule, R3> ): (self: Stream) => Stream - ( + ( self: Stream, sink: Sink.Sink, - schedule: Schedule.Schedule, C> + schedule: Schedule.Schedule, R3> ): Stream } = internal.aggregateWithin @@ -233,14 +233,14 @@ export const aggregateWithin: { * @category utils */ export const aggregateWithinEither: { - ( + ( sink: Sink.Sink, - schedule: Schedule.Schedule, C> + schedule: Schedule.Schedule, R3> ): (self: Stream) => Stream, E2 | E, R2 | R3 | R> - ( + ( self: Stream, sink: Sink.Sink, - schedule: Schedule.Schedule, C> + schedule: Schedule.Schedule, R3> ): Stream, E | E2, R | R2 | R3> } = internal.aggregateWithinEither @@ -1595,7 +1595,7 @@ export const fromReadableStreamByob: ( * @since 2.0.0 * @category constructors */ -export const fromSchedule: (schedule: Schedule.Schedule) => Stream = +export const fromSchedule: (schedule: Schedule.Schedule) => Stream = internal.fromSchedule /** @@ -2696,8 +2696,8 @@ export const refineOrDieWith: { * @category utils */ export const repeat: { - (schedule: Schedule.Schedule): (self: Stream) => Stream - (self: Stream, schedule: Schedule.Schedule): Stream + (schedule: Schedule.Schedule): (self: Stream) => Stream + (self: Stream, schedule: Schedule.Schedule): Stream } = internal.repeat /** @@ -2747,9 +2747,9 @@ export const repeatEffectOption: (effect: Effect.Effect( +export const repeatEffectWithSchedule: ( effect: Effect.Effect, - schedule: Schedule.Schedule + schedule: Schedule.Schedule<_, A0, R2> ) => Stream = internal.repeatEffectWithSchedule /** @@ -2761,12 +2761,12 @@ export const repeatEffectWithSchedule: ( * @category utils */ export const repeatEither: { - ( - schedule: Schedule.Schedule + ( + schedule: Schedule.Schedule ): (self: Stream) => Stream, E, R2 | R> - ( + ( self: Stream, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ): Stream, E, R | R2> } = internal.repeatEither @@ -2781,8 +2781,8 @@ export const repeatEither: { * @category utils */ export const repeatElements: { - (schedule: Schedule.Schedule): (self: Stream) => Stream - (self: Stream, schedule: Schedule.Schedule): Stream + (schedule: Schedule.Schedule): (self: Stream) => Stream + (self: Stream, schedule: Schedule.Schedule): Stream } = internal.repeatElements /** @@ -2801,13 +2801,13 @@ export const repeatElements: { * @category utils */ export const repeatElementsWith: { - ( - schedule: Schedule.Schedule, + ( + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C; readonly onSchedule: (b: B) => C } - ): (self: Stream) => Stream - ( + ): (self: Stream) => Stream + ( self: Stream, - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C; readonly onSchedule: (b: B) => C } ): Stream } = internal.repeatElementsWith @@ -2830,13 +2830,13 @@ export const repeatValue: (value: A) => Stream = internal.repeatValue * @category utils */ export const repeatWith: { - ( - schedule: Schedule.Schedule, + ( + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C; readonly onSchedule: (b: B) => C } - ): (self: Stream) => Stream - ( + ): (self: Stream) => Stream + ( self: Stream, - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C; readonly onSchedule: (b: B) => C } ): Stream } = internal.repeatWith @@ -2855,10 +2855,10 @@ export const repeatWith: { * @category utils */ export const retry: { - ( - schedule: Schedule.Schedule - ): (self: Stream) => Stream - (self: Stream, schedule: Schedule.Schedule): Stream + ( + schedule: Schedule.Schedule<_, E0, R2> + ): (self: Stream) => Stream + (self: Stream, schedule: Schedule.Schedule<_, E0, R2>): Stream } = internal.retry /** @@ -3313,10 +3313,10 @@ export const scanReduceEffect = internal.scanReduceEffect * @category utils */ export const schedule: { - ( - schedule: Schedule.Schedule - ): (self: Stream) => Stream - (self: Stream, schedule: Schedule.Schedule): Stream + <_, A0 extends A, R2, A>( + schedule: Schedule.Schedule<_, A0, R2> + ): (self: Stream) => Stream + (self: Stream, schedule: Schedule.Schedule<_, A0, R2>): Stream } = internal.schedule /** @@ -3328,13 +3328,13 @@ export const schedule: { * @category utils */ export const scheduleWith: { - ( - schedule: Schedule.Schedule, + ( + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C; readonly onSchedule: (b: B) => C } - ): (self: Stream) => Stream - ( + ): (self: Stream) => Stream + ( self: Stream, - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C; readonly onSchedule: (b: B) => C } ): Stream } = internal.scheduleWith diff --git a/packages/effect/src/internal/effect/circular.ts b/packages/effect/src/internal/effect/circular.ts index 02d3c9f27f..dabec29f85 100644 --- a/packages/effect/src/internal/effect/circular.ts +++ b/packages/effect/src/internal/effect/circular.ts @@ -375,14 +375,14 @@ export const raceFirst = dual< /** @internal */ export const scheduleForked = dual< - ( - schedule: Schedule.Schedule + ( + schedule: Schedule.Schedule ) => ( self: Effect.Effect ) => Effect.Effect, never, R | R2 | Scope.Scope>, - ( + ( self: Effect.Effect, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ) => Effect.Effect, never, R | R2 | Scope.Scope> >(2, (self, schedule) => pipe(self, _schedule.schedule_Effect(schedule), forkScoped)) diff --git a/packages/effect/src/internal/layer.ts b/packages/effect/src/internal/layer.ts index 691714e6f6..7d28948290 100644 --- a/packages/effect/src/internal/layer.ts +++ b/packages/effect/src/internal/layer.ts @@ -770,14 +770,14 @@ export const project = dual< /** @internal */ export const retry = dual< - ( - schedule: Schedule.Schedule - ) => ( + ( + schedule: Schedule.Schedule + ) => ( self: Layer.Layer ) => Layer.Layer, - ( + ( self: Layer.Layer, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ) => Layer.Layer >(2, (self, schedule) => suspend(() => { @@ -790,10 +790,9 @@ export const retry = dual< ) })) -/** @internal */ -const retryLoop = ( +const retryLoop = ( self: Layer.Layer, - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, stateTag: Context.Tag<{ state: unknown }, { state: unknown }>, state: unknown ): Layer.Layer => { @@ -808,9 +807,8 @@ const retryLoop = ( ) } -/** @internal */ -const retryUpdate = ( - schedule: Schedule.Schedule, +const retryUpdate = ( + schedule: Schedule.Schedule, stateTag: Context.Tag<{ state: unknown }, { state: unknown }>, error: E, state: unknown diff --git a/packages/effect/src/internal/metric/polling.ts b/packages/effect/src/internal/metric/polling.ts index ef5079436f..9206220cb9 100644 --- a/packages/effect/src/internal/metric/polling.ts +++ b/packages/effect/src/internal/metric/polling.ts @@ -64,14 +64,14 @@ export const collectAll = ( /** @internal */ export const launch = dual< - ( - schedule: Schedule.Schedule + ( + schedule: Schedule.Schedule ) => ( self: MetricPolling.MetricPolling ) => Effect.Effect, never, R | R2 | Scope.Scope>, - ( + ( self: MetricPolling.MetricPolling, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ) => Effect.Effect, never, R | R2 | Scope.Scope> >(2, (self, schedule) => pipe( @@ -92,14 +92,14 @@ export const pollAndUpdate = ( /** @internal */ export const retry = dual< - ( - policy: Schedule.Schedule + <_, E, R2>( + policy: Schedule.Schedule<_, E, R2> ) => ( self: MetricPolling.MetricPolling ) => MetricPolling.MetricPolling, - ( + ( self: MetricPolling.MetricPolling, - policy: Schedule.Schedule + policy: Schedule.Schedule<_, E, R2> ) => MetricPolling.MetricPolling >(2, (self, policy) => ({ [MetricPollingTypeId]: MetricPollingTypeId, diff --git a/packages/effect/src/internal/reloadable.ts b/packages/effect/src/internal/reloadable.ts index f5c003188f..99e980c5cc 100644 --- a/packages/effect/src/internal/reloadable.ts +++ b/packages/effect/src/internal/reloadable.ts @@ -25,11 +25,11 @@ const reloadableVariance = { } /** @internal */ -export const auto = , In, E, R>( +export const auto = , E, In, R>( tag: Out, options: { readonly layer: Layer.Layer, E, In> - readonly schedule: Schedule.Schedule + readonly schedule: Schedule.Schedule } ): Layer.Layer>, E, R | In> => _layer.scoped( @@ -52,11 +52,11 @@ export const auto = , In, E, R>( ) /** @internal */ -export const autoFromConfig = , In, E, R>( +export const autoFromConfig = , E, In, R>( tag: Out, options: { readonly layer: Layer.Layer, E, In> - readonly scheduleFromConfig: (context: Context.Context) => Schedule.Schedule + readonly scheduleFromConfig: (context: Context.Context) => Schedule.Schedule } ): Layer.Layer>, E, R | In> => _layer.scoped( diff --git a/packages/effect/src/internal/resource.ts b/packages/effect/src/internal/resource.ts index c0acc4a1ea..74a21dc314 100644 --- a/packages/effect/src/internal/resource.ts +++ b/packages/effect/src/internal/resource.ts @@ -24,9 +24,9 @@ const resourceVariance = { } /** @internal */ -export const auto = ( +export const auto = ( acquire: Effect.Effect, - policy: Schedule.Schedule + policy: Schedule.Schedule ): Effect.Effect, never, R | R2 | Scope.Scope> => core.tap(manual(acquire), (manual) => fiberRuntime.acquireRelease( diff --git a/packages/effect/src/internal/schedule.ts b/packages/effect/src/internal/schedule.ts index 524d884549..17aef3a5dd 100644 --- a/packages/effect/src/internal/schedule.ts +++ b/packages/effect/src/internal/schedule.ts @@ -45,24 +45,24 @@ export const ScheduleDriverTypeId: Schedule.ScheduleDriverTypeId = Symbol.for( const scheduleVariance = { /* c8 ignore next */ - _Env: (_: never) => _, + _Out: (_: never) => _, /* c8 ignore next */ _In: (_: unknown) => _, /* c8 ignore next */ - _Out: (_: never) => _ + _R: (_: never) => _ } const scheduleDriverVariance = { /* c8 ignore next */ - _Env: (_: never) => _, + _Out: (_: never) => _, /* c8 ignore next */ _In: (_: unknown) => _, /* c8 ignore next */ - _Out: (_: never) => _ + _R: (_: never) => _ } /** @internal */ -class ScheduleImpl implements Schedule.Schedule { +class ScheduleImpl implements Schedule.Schedule { [ScheduleTypeId] = scheduleVariance constructor( readonly initial: S, @@ -70,7 +70,7 @@ class ScheduleImpl implements Schedule.Schedule { now: number, input: In, state: S - ) => Effect.Effect + ) => Effect.Effect ) { } pipe() { @@ -79,11 +79,11 @@ class ScheduleImpl implements Schedule.Schedule { } /** @internal */ -class ScheduleDriverImpl implements Schedule.ScheduleDriver { +class ScheduleDriverImpl implements Schedule.ScheduleDriver { [ScheduleDriverTypeId] = scheduleDriverVariance constructor( - readonly schedule: Schedule.Schedule, + readonly schedule: Schedule.Schedule, readonly ref: Ref.Ref, any]> ) {} @@ -108,7 +108,7 @@ class ScheduleDriverImpl implements Schedule.ScheduleDriver, Env> { + next(input: In): Effect.Effect, R> { return pipe( core.map(ref.get(this.ref), (tuple) => tuple[1]), core.flatMap((state) => @@ -141,35 +141,35 @@ class ScheduleDriverImpl implements Schedule.ScheduleDriver( +export const makeWithState = ( initial: S, step: ( now: number, input: In, state: S - ) => Effect.Effect -): Schedule.Schedule => new ScheduleImpl(initial, step) + ) => Effect.Effect +): Schedule.Schedule => new ScheduleImpl(initial, step) /** @internal */ export const addDelay = dual< ( f: (out: Out) => Duration.DurationInput - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, f: (out: Out) => Duration.DurationInput - ) => Schedule.Schedule + ) => Schedule.Schedule >(2, (self, f) => addDelayEffect(self, (out) => core.sync(() => f(out)))) /** @internal */ export const addDelayEffect = dual< - ( - f: (out: Out) => Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - f: (out: Out) => Effect.Effect - ) => Schedule.Schedule + ( + f: (out: Out) => Effect.Effect + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + f: (out: Out) => Effect.Effect + ) => Schedule.Schedule >(2, (self, f) => modifyDelayEffect(self, (out, duration) => core.map( @@ -179,48 +179,38 @@ export const addDelayEffect = dual< /** @internal */ export const andThen = dual< - ( - that: Schedule.Schedule - ) => (self: Schedule.Schedule) => Schedule.Schedule< - Env | Env1, - In & In1, - Out | Out2 + ( + that: Schedule.Schedule + ) => (self: Schedule.Schedule) => Schedule.Schedule< + Out | Out2, + In & In2, + R | R2 >, - ( - self: Schedule.Schedule, - that: Schedule.Schedule + ( + self: Schedule.Schedule, + that: Schedule.Schedule ) => Schedule.Schedule< - Env | Env1, - In & In1, - Out | Out2 + Out | Out2, + In & In2, + R | R2 > >(2, (self, that) => map(andThenEither(self, that), Either.merge)) /** @internal */ export const andThenEither = dual< - ( - that: Schedule.Schedule - ) => (self: Schedule.Schedule) => Schedule.Schedule< - Env | Env2, - In & In2, - Either.Either - >, - ( - self: Schedule.Schedule, - that: Schedule.Schedule - ) => Schedule.Schedule< - Env | Env2, - In & In2, - Either.Either - > ->(2, ( - self: Schedule.Schedule, - that: Schedule.Schedule -): Schedule.Schedule< - Env | Env2, - In & In2, - Either.Either -> => + ( + that: Schedule.Schedule + ) => ( + self: Schedule.Schedule + ) => Schedule.Schedule, In & In2, R | R2>, + ( + self: Schedule.Schedule, + that: Schedule.Schedule + ) => Schedule.Schedule, In & In2, R | R2> +>(2, ( + self: Schedule.Schedule, + that: Schedule.Schedule +): Schedule.Schedule, In & In2, R | R2> => makeWithState( [self.initial, that.initial, true as boolean] as const, (now, input, state) => @@ -252,32 +242,26 @@ export const andThenEither = dual< /** @internal */ export const as = dual< - (out: Out2) => (self: Schedule.Schedule) => Schedule.Schedule, - (self: Schedule.Schedule, out: Out2) => Schedule.Schedule + (out: Out2) => (self: Schedule.Schedule) => Schedule.Schedule, + (self: Schedule.Schedule, out: Out2) => Schedule.Schedule >(2, (self, out) => map(self, () => out)) /** @internal */ -export const asUnit = ( - self: Schedule.Schedule -): Schedule.Schedule => map(self, constVoid) +export const asUnit = ( + self: Schedule.Schedule +): Schedule.Schedule => map(self, constVoid) /** @internal */ export const bothInOut = dual< - ( - that: Schedule.Schedule - ) => (self: Schedule.Schedule) => Schedule.Schedule< - Env | Env2, - readonly [In, In2], - [Out, Out2] - >, - ( - self: Schedule.Schedule, - that: Schedule.Schedule - ) => Schedule.Schedule< - Env | Env2, - readonly [In, In2], - [Out, Out2] - > + ( + that: Schedule.Schedule + ) => ( + self: Schedule.Schedule + ) => Schedule.Schedule<[Out, Out2], readonly [In, In2], R | R2>, + ( + self: Schedule.Schedule, + that: Schedule.Schedule + ) => Schedule.Schedule<[Out, Out2], readonly [In, In2], R | R2> >(2, (self, that) => makeWithState([self.initial, that.initial], (now, [in1, in2], state) => core.zipWith( @@ -300,22 +284,22 @@ export const bothInOut = dual< export const check = dual< ( test: (input: In, output: Out) => boolean - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, test: (input: In, output: Out) => boolean - ) => Schedule.Schedule + ) => Schedule.Schedule >(2, (self, test) => checkEffect(self, (input, out) => core.sync(() => test(input, out)))) /** @internal */ export const checkEffect = dual< - ( - test: (input: In, output: Out) => Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - test: (input: In, output: Out) => Effect.Effect - ) => Schedule.Schedule + ( + test: (input: In, output: Out) => Effect.Effect + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + test: (input: In, output: Out) => Effect.Effect + ) => Schedule.Schedule >(2, (self, test) => makeWithState( self.initial, @@ -331,41 +315,41 @@ export const checkEffect = dual< }) )) /** @internal */ -export const collectAllInputs = (): Schedule.Schedule> => collectAllOutputs(identity()) +export const collectAllInputs = (): Schedule.Schedule, A> => collectAllOutputs(identity()) /** @internal */ -export const collectAllOutputs = ( - self: Schedule.Schedule -): Schedule.Schedule> => +export const collectAllOutputs = ( + self: Schedule.Schedule +): Schedule.Schedule, In, R> => reduce(self, Chunk.empty(), (outs, out) => pipe(outs, Chunk.append(out))) /** @internal */ -export const collectUntil = (f: Predicate): Schedule.Schedule> => +export const collectUntil = (f: Predicate): Schedule.Schedule, A> => collectAllOutputs(recurUntil(f)) /** @internal */ -export const collectUntilEffect = ( - f: (a: A) => Effect.Effect -): Schedule.Schedule> => collectAllOutputs(recurUntilEffect(f)) +export const collectUntilEffect = ( + f: (a: A) => Effect.Effect +): Schedule.Schedule, A, R> => collectAllOutputs(recurUntilEffect(f)) /** @internal */ -export const collectWhile = (f: Predicate): Schedule.Schedule> => +export const collectWhile = (f: Predicate): Schedule.Schedule, A> => collectAllOutputs(recurWhile(f)) /** @internal */ -export const collectWhileEffect = ( - f: (a: A) => Effect.Effect -): Schedule.Schedule> => collectAllOutputs(recurWhileEffect(f)) +export const collectWhileEffect = ( + f: (a: A) => Effect.Effect +): Schedule.Schedule, A, R> => collectAllOutputs(recurWhileEffect(f)) /** @internal */ export const compose = dual< - ( - that: Schedule.Schedule - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - that: Schedule.Schedule - ) => Schedule.Schedule + ( + that: Schedule.Schedule + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + that: Schedule.Schedule + ) => Schedule.Schedule >(2, (self, that) => makeWithState( [self.initial, that.initial] as const, @@ -390,22 +374,22 @@ export const compose = dual< export const mapInput = dual< ( f: (in2: In2) => In - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, f: (in2: In2) => In - ) => Schedule.Schedule + ) => Schedule.Schedule >(2, (self, f) => mapInputEffect(self, (input2) => core.sync(() => f(input2)))) /** @internal */ export const mapInputContext = dual< - ( - f: (env0: Context.Context) => Context.Context - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - f: (env0: Context.Context) => Context.Context - ) => Schedule.Schedule + ( + f: (env0: Context.Context) => Context.Context + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + f: (env0: Context.Context) => Context.Context + ) => Schedule.Schedule >(2, (self, f) => makeWithState( self.initial, @@ -414,13 +398,13 @@ export const mapInputContext = dual< /** @internal */ export const mapInputEffect = dual< - ( - f: (in2: In2) => Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - f: (in2: In2) => Effect.Effect - ) => Schedule.Schedule + ( + f: (in2: In2) => Effect.Effect + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + f: (in2: In2) => Effect.Effect + ) => Schedule.Schedule >(2, (self, f) => makeWithState(self.initial, (now, input2, state) => core.flatMap( @@ -429,9 +413,9 @@ export const mapInputEffect = dual< ))) /** @internal */ -export const cron = (expression: string | Cron.Cron): Schedule.Schedule => { +export const cron = (expression: string | Cron.Cron): Schedule.Schedule<[number, number]> => { const parsed = Cron.isCron(expression) ? Either.right(expression) : Cron.parse(expression) - return makeWithState<[boolean, [number, number, number]], never, unknown, [number, number]>( + return makeWithState<[boolean, [number, number, number]], unknown, [number, number]>( [true, [Number.MIN_SAFE_INTEGER, 0, 0]], (now, _, [initial, previous]) => { if (now < previous[0]) { @@ -470,8 +454,8 @@ export const cron = (expression: string | Cron.Cron): Schedule.Schedule => { - return makeWithState<[number, number], never, unknown, number>( +export const dayOfMonth = (day: number): Schedule.Schedule => { + return makeWithState<[number, number], unknown, number>( [Number.NEGATIVE_INFINITY, 0], (now, _, state) => { if (!Number.isInteger(day) || day < 1 || 31 < day) { @@ -499,8 +483,8 @@ export const dayOfMonth = (day: number): Schedule.Schedule => { - return makeWithState<[number, number], never, unknown, number>( +export const dayOfWeek = (day: number): Schedule.Schedule => { + return makeWithState<[number, number], unknown, number>( [Number.MIN_SAFE_INTEGER, 0], (now, _, state) => { if (!Number.isInteger(day) || day < 1 || 7 < day) { @@ -531,33 +515,33 @@ export const dayOfWeek = (day: number): Schedule.Schedule Duration.DurationInput - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, f: (duration: Duration.Duration) => Duration.DurationInput - ) => Schedule.Schedule + ) => Schedule.Schedule >(2, (self, f) => delayedEffect(self, (duration) => core.sync(() => f(duration)))) /** @internal */ export const delayedEffect = dual< - ( - f: (duration: Duration.Duration) => Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - f: (duration: Duration.Duration) => Effect.Effect - ) => Schedule.Schedule + ( + f: (duration: Duration.Duration) => Effect.Effect + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + f: (duration: Duration.Duration) => Effect.Effect + ) => Schedule.Schedule >(2, (self, f) => modifyDelayEffect(self, (_, delay) => f(delay))) /** @internal */ -export const delayedSchedule = ( - schedule: Schedule.Schedule -): Schedule.Schedule => addDelay(schedule, (x) => x) +export const delayedSchedule = ( + schedule: Schedule.Schedule +): Schedule.Schedule => addDelay(schedule, (x) => x) /** @internal */ -export const delays = ( - self: Schedule.Schedule -): Schedule.Schedule => +export const delays = ( + self: Schedule.Schedule +): Schedule.Schedule => makeWithState(self.initial, (now, input, state) => pipe( self.step(now, input, state), @@ -579,42 +563,42 @@ export const delays = ( /** @internal */ export const mapBoth = dual< - ( + ( options: { readonly onInput: (in2: In2) => In readonly onOutput: (out: Out) => Out2 } - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, options: { readonly onInput: (in2: In2) => In readonly onOutput: (out: Out) => Out2 } - ) => Schedule.Schedule + ) => Schedule.Schedule >(2, (self, { onInput, onOutput }) => map(mapInput(self, onInput), onOutput)) /** @internal */ export const mapBothEffect = dual< - ( + ( options: { - readonly onInput: (input: In2) => Effect.Effect - readonly onOutput: (out: Out) => Effect.Effect + readonly onInput: (input: In2) => Effect.Effect + readonly onOutput: (out: Out) => Effect.Effect } - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, options: { - readonly onInput: (input: In2) => Effect.Effect - readonly onOutput: (out: Out) => Effect.Effect + readonly onInput: (input: In2) => Effect.Effect + readonly onOutput: (out: Out) => Effect.Effect } - ) => Schedule.Schedule + ) => Schedule.Schedule >(2, (self, { onInput, onOutput }) => mapEffect(mapInputEffect(self, onInput), onOutput)) /** @internal */ -export const driver = ( - self: Schedule.Schedule -): Effect.Effect> => +export const driver = ( + self: Schedule.Schedule +): Effect.Effect> => pipe( ref.make, any]>([Option.none(), self.initial]), core.map((ref) => new ScheduleDriverImpl(self, ref)) @@ -623,7 +607,7 @@ export const driver = ( /** @internal */ export const duration = ( durationInput: Duration.DurationInput -): Schedule.Schedule => { +): Schedule.Schedule => { const duration = Duration.decode(durationInput) const durationMillis = Duration.toMillis(duration) return makeWithState(true as boolean, (now, _, state) => @@ -640,53 +624,37 @@ export const duration = ( /** @internal */ export const either = dual< - ( - that: Schedule.Schedule - ) => (self: Schedule.Schedule) => Schedule.Schedule< - Env | Env2, - In & In2, - [Out, Out2] - >, - ( - self: Schedule.Schedule, - that: Schedule.Schedule - ) => Schedule.Schedule< - Env | Env2, - In & In2, - [Out, Out2] - > + ( + that: Schedule.Schedule + ) => (self: Schedule.Schedule) => Schedule.Schedule<[Out, Out2], In & In2, R | R2>, + ( + self: Schedule.Schedule, + that: Schedule.Schedule + ) => Schedule.Schedule<[Out, Out2], In & In2, R | R2> >(2, (self, that) => union(self, that)) /** @internal */ export const eitherWith = dual< - ( - that: Schedule.Schedule, + ( + that: Schedule.Schedule, f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals - ) => (self: Schedule.Schedule) => Schedule.Schedule< - Env | Env2, - In & In2, - [Out, Out2] - >, - ( - self: Schedule.Schedule, - that: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Schedule.Schedule<[Out, Out2], In & In2, R | R2>, + ( + self: Schedule.Schedule, + that: Schedule.Schedule, f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals - ) => Schedule.Schedule< - Env | Env2, - In & In2, - [Out, Out2] - > + ) => Schedule.Schedule<[Out, Out2], In & In2, R | R2> >(3, (self, that, f) => unionWith(self, that, f)) /** @internal */ export const ensuring = dual< ( finalizer: Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, finalizer: Effect.Effect - ) => Schedule.Schedule + ) => Schedule.Schedule >(2, (self, finalizer) => makeWithState( self.initial, @@ -701,13 +669,13 @@ export const ensuring = dual< export const exponential = ( baseInput: Duration.DurationInput, factor = 2.0 -): Schedule.Schedule => { +): Schedule.Schedule => { const base = Duration.decode(baseInput) return delayedSchedule(map(forever, (i) => Duration.times(base, Math.pow(factor, i)))) } /** @internal */ -export const fibonacci = (oneInput: Duration.DurationInput): Schedule.Schedule => { +export const fibonacci = (oneInput: Duration.DurationInput): Schedule.Schedule => { const one = Duration.decode(oneInput) return delayedSchedule( pipe( @@ -721,10 +689,10 @@ export const fibonacci = (oneInput: Duration.DurationInput): Schedule.Schedule => { +export const fixed = (intervalInput: Duration.DurationInput): Schedule.Schedule => { const interval = Duration.decode(intervalInput) const intervalMillis = Duration.toMillis(interval) - return makeWithState<[Option.Option<[number, number]>, number], never, unknown, number>( + return makeWithState<[Option.Option<[number, number]>, number], unknown, number>( [Option.none(), 0], (now, _, [option, n]) => core.sync(() => { @@ -756,14 +724,13 @@ export const fixed = (intervalInput: Duration.DurationInput): Schedule.Schedule< } /** @internal */ -export const fromDelay = (delay: Duration.DurationInput): Schedule.Schedule => - duration(delay) +export const fromDelay = (delay: Duration.DurationInput): Schedule.Schedule => duration(delay) /** @internal */ export const fromDelays = ( delay: Duration.DurationInput, ...delays: Array -): Schedule.Schedule => +): Schedule.Schedule => makeWithState( [[delay, ...delays].map((_) => Duration.decode(_)) as Array, true as boolean] as const, (now, _, [durations, cont]) => @@ -790,11 +757,11 @@ export const fromDelays = ( ) /** @internal */ -export const fromFunction = (f: (a: A) => B): Schedule.Schedule => map(identity(), f) +export const fromFunction = (f: (a: A) => B): Schedule.Schedule => map(identity(), f) /** @internal */ -export const hourOfDay = (hour: number): Schedule.Schedule => - makeWithState<[number, number], never, unknown, number>( +export const hourOfDay = (hour: number): Schedule.Schedule => + makeWithState<[number, number], unknown, number>( [Number.NEGATIVE_INFINITY, 0], (now, _, state) => { if (!Number.isInteger(hour) || hour < 0 || 23 < hour) { @@ -821,7 +788,7 @@ export const hourOfDay = (hour: number): Schedule.Schedule(): Schedule.Schedule => +export const identity = (): Schedule.Schedule => makeWithState(void 0, (now, input, state) => core.succeed( [ @@ -833,52 +800,32 @@ export const identity = (): Schedule.Schedule => /** @internal */ export const intersect = dual< - ( - that: Schedule.Schedule - ) => (self: Schedule.Schedule) => Schedule.Schedule< - Env | Env2, - In & In2, - [Out, Out2] - >, - ( - self: Schedule.Schedule, - that: Schedule.Schedule - ) => Schedule.Schedule< - Env | Env2, - In & In2, - [Out, Out2] - > + ( + that: Schedule.Schedule + ) => (self: Schedule.Schedule) => Schedule.Schedule<[Out, Out2], In & In2, R | R2>, + ( + self: Schedule.Schedule, + that: Schedule.Schedule + ) => Schedule.Schedule<[Out, Out2], In & In2, R | R2> >(2, (self, that) => intersectWith(self, that, Intervals.intersect)) /** @internal */ export const intersectWith = dual< - ( - that: Schedule.Schedule, + ( + that: Schedule.Schedule, f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals - ) => (self: Schedule.Schedule) => Schedule.Schedule< - Env | Env2, - In & In2, - [Out, Out2] - >, - ( - self: Schedule.Schedule, - that: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Schedule.Schedule<[Out, Out2], In & In2, R | R2>, + ( + self: Schedule.Schedule, + that: Schedule.Schedule, f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals - ) => Schedule.Schedule< - Env | Env2, - In & In2, - [Out, Out2] - > + ) => Schedule.Schedule<[Out, Out2], In & In2, R | R2> >(3, ( - self: Schedule.Schedule, - that: Schedule.Schedule, + self: Schedule.Schedule, + that: Schedule.Schedule, f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals -): Schedule.Schedule< - Env | Env2, - In & In2, - [Out, Out2] -> => - makeWithState<[any, any], Env | Env2, In & In2, [Out, Out2]>( +): Schedule.Schedule<[Out, Out2], In & In2, Env | Env2> => + makeWithState<[any, any], In & In2, [Out, Out2], Env | Env2>( [self.initial, that.initial], (now, input: In & In2, state) => pipe( @@ -918,8 +865,8 @@ export const intersectWith = dual< /** @internal */ const intersectWithLoop = ( - self: Schedule.Schedule, - that: Schedule.Schedule, + self: Schedule.Schedule, + that: Schedule.Schedule, input: In & In1, lState: State, out: Out, @@ -989,18 +936,18 @@ const intersectWithLoop = ( } /** @internal */ -export const jittered = (self: Schedule.Schedule): Schedule.Schedule => +export const jittered = (self: Schedule.Schedule): Schedule.Schedule => jitteredWith(self, { min: 0.8, max: 1.2 }) /** @internal */ export const jitteredWith = dual< - (options: { min?: number; max?: number }) => ( - self: Schedule.Schedule - ) => Schedule.Schedule, - ( - self: Schedule.Schedule, - options: { min?: number; max?: number } - ) => Schedule.Schedule + (options: { min?: number | undefined; max?: number | undefined }) => ( + self: Schedule.Schedule + ) => Schedule.Schedule, + ( + self: Schedule.Schedule, + options: { min?: number | undefined; max?: number | undefined } + ) => Schedule.Schedule >(2, (self, options) => { const { max, min } = Object.assign({ min: 0.8, max: 1.2 }, options) return delayedEffect(self, (duration) => @@ -1012,7 +959,7 @@ export const jitteredWith = dual< }) /** @internal */ -export const linear = (baseInput: Duration.DurationInput): Schedule.Schedule => { +export const linear = (baseInput: Duration.DurationInput): Schedule.Schedule => { const base = Duration.decode(baseInput) return delayedSchedule(map(forever, (i) => Duration.times(base, i + 1))) } @@ -1021,22 +968,22 @@ export const linear = (baseInput: Duration.DurationInput): Schedule.Schedule( f: (out: Out) => Out2 - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, f: (out: Out) => Out2 - ) => Schedule.Schedule + ) => Schedule.Schedule >(2, (self, f) => mapEffect(self, (out) => core.sync(() => f(out)))) /** @internal */ export const mapEffect = dual< - ( - f: (out: Out) => Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - f: (out: Out) => Effect.Effect - ) => Schedule.Schedule + ( + f: (out: Out) => Effect.Effect + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + f: (out: Out) => Effect.Effect + ) => Schedule.Schedule >(2, (self, f) => makeWithState( self.initial, @@ -1049,8 +996,8 @@ export const mapEffect = dual< )) /** @internal */ -export const minuteOfHour = (minute: number): Schedule.Schedule => - makeWithState<[number, number], never, unknown, number>( +export const minuteOfHour = (minute: number): Schedule.Schedule => + makeWithState<[number, number], unknown, number>( [Number.MIN_SAFE_INTEGER, 0], (now, _, state) => { if (!Number.isInteger(minute) || minute < 0 || 59 < minute) { @@ -1080,22 +1027,22 @@ export const minuteOfHour = (minute: number): Schedule.Schedule( f: (out: Out, duration: Duration.Duration) => Duration.DurationInput - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, f: (out: Out, duration: Duration.Duration) => Duration.DurationInput - ) => Schedule.Schedule + ) => Schedule.Schedule >(2, (self, f) => modifyDelayEffect(self, (out, duration) => core.sync(() => f(out, duration)))) /** @internal */ export const modifyDelayEffect = dual< - ( - f: (out: Out, duration: Duration.Duration) => Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - f: (out: Out, duration: Duration.Duration) => Effect.Effect - ) => Schedule.Schedule + ( + f: (out: Out, duration: Duration.Duration) => Effect.Effect + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + f: (out: Out, duration: Duration.Duration) => Effect.Effect + ) => Schedule.Schedule >(2, (self, f) => makeWithState( self.initial, @@ -1120,13 +1067,13 @@ export const modifyDelayEffect = dual< /** @internal */ export const onDecision = dual< - ( - f: (out: Out, decision: ScheduleDecision.ScheduleDecision) => Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - f: (out: Out, decision: ScheduleDecision.ScheduleDecision) => Effect.Effect - ) => Schedule.Schedule + ( + f: (out: Out, decision: ScheduleDecision.ScheduleDecision) => Effect.Effect + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + f: (out: Out, decision: ScheduleDecision.ScheduleDecision) => Effect.Effect + ) => Schedule.Schedule >(2, (self, f) => makeWithState( self.initial, @@ -1138,9 +1085,9 @@ export const onDecision = dual< )) /** @internal */ -export const passthrough = ( - self: Schedule.Schedule -): Schedule.Schedule => +export const passthrough = ( + self: Schedule.Schedule +): Schedule.Schedule => makeWithState(self.initial, (now, input, state) => pipe( self.step(now, input, state), @@ -1149,13 +1096,13 @@ export const passthrough = ( /** @internal */ export const provideContext = dual< - ( - context: Context.Context - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - context: Context.Context - ) => Schedule.Schedule + ( + context: Context.Context + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + context: Context.Context + ) => Schedule.Schedule >(2, (self, context) => makeWithState(self.initial, (now, input, state) => core.provideContext( @@ -1168,19 +1115,19 @@ export const provideService = dual< >( tag: T, service: Context.Tag.Service - ) => ( - self: Schedule.Schedule - ) => Schedule.Schedule>, In, Out>, - >( - self: Schedule.Schedule, + ) => ( + self: Schedule.Schedule + ) => Schedule.Schedule>>, + >( + self: Schedule.Schedule, tag: T, service: Context.Tag.Service - ) => Schedule.Schedule>, In, Out> ->(3, >( - self: Schedule.Schedule, + ) => Schedule.Schedule>> +>(3, >( + self: Schedule.Schedule, tag: T, service: Context.Tag.Service -): Schedule.Schedule>, In, Out> => +): Schedule.Schedule>> => makeWithState(self.initial, (now, input, state) => core.contextWithEffect((env) => core.provideContext( @@ -1191,60 +1138,60 @@ export const provideService = dual< ))) /** @internal */ -export const recurUntil = (f: Predicate): Schedule.Schedule => untilInput(identity(), f) +export const recurUntil = (f: Predicate): Schedule.Schedule => untilInput(identity(), f) /** @internal */ -export const recurUntilEffect = ( - f: (a: A) => Effect.Effect -): Schedule.Schedule => untilInputEffect(identity(), f) +export const recurUntilEffect = ( + f: (a: A) => Effect.Effect +): Schedule.Schedule => untilInputEffect(identity(), f) /** @internal */ -export const recurUntilOption = (pf: (a: A) => Option.Option): Schedule.Schedule> => +export const recurUntilOption = (pf: (a: A) => Option.Option): Schedule.Schedule, A> => untilOutput(map(identity(), pf), Option.isSome) /** @internal */ export const recurUpTo = ( durationInput: Duration.DurationInput -): Schedule.Schedule => { +): Schedule.Schedule => { const duration = Duration.decode(durationInput) return whileOutput(elapsed, (elapsed) => Duration.lessThan(elapsed, duration)) } /** @internal */ -export const recurWhile = (f: Predicate): Schedule.Schedule => whileInput(identity(), f) +export const recurWhile = (f: Predicate): Schedule.Schedule => whileInput(identity(), f) /** @internal */ -export const recurWhileEffect = ( - f: (a: A) => Effect.Effect -): Schedule.Schedule => whileInputEffect(identity(), f) +export const recurWhileEffect = ( + f: (a: A) => Effect.Effect +): Schedule.Schedule => whileInputEffect(identity(), f) /** @internal */ -export const recurs = (n: number): Schedule.Schedule => whileOutput(forever, (out) => out < n) +export const recurs = (n: number): Schedule.Schedule => whileOutput(forever, (out) => out < n) /** @internal */ export const reduce = dual< ( zero: Z, f: (z: Z, out: Out) => Z - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, zero: Z, f: (z: Z, out: Out) => Z - ) => Schedule.Schedule + ) => Schedule.Schedule >(3, (self, zero, f) => reduceEffect(self, zero, (z, out) => core.sync(() => f(z, out)))) /** @internal */ export const reduceEffect = dual< - ( + ( zero: Z, - f: (z: Z, out: Out) => Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, + f: (z: Z, out: Out) => Effect.Effect + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, zero: Z, - f: (z: Z, out: Out) => Effect.Effect - ) => Schedule.Schedule + f: (z: Z, out: Out) => Effect.Effect + ) => Schedule.Schedule >(3, (self, zero, f) => makeWithState( [self.initial, zero] as const, @@ -1256,7 +1203,7 @@ export const reduceEffect = dual< )) /** @internal */ -export const repeatForever = (self: Schedule.Schedule): Schedule.Schedule => +export const repeatForever = (self: Schedule.Schedule): Schedule.Schedule => makeWithState(self.initial, (now, input, state) => { const step = ( now: number, @@ -1274,20 +1221,20 @@ export const repeatForever = (self: Schedule.Schedule(self: Schedule.Schedule): Schedule.Schedule => +export const repetitions = (self: Schedule.Schedule): Schedule.Schedule => reduce(self, 0, (n, _) => n + 1) /** @internal */ export const resetAfter = dual< ( duration: Duration.DurationInput - ) => ( - self: Schedule.Schedule - ) => Schedule.Schedule, - ( - self: Schedule.Schedule, + ) => ( + self: Schedule.Schedule + ) => Schedule.Schedule, + ( + self: Schedule.Schedule, duration: Duration.DurationInput - ) => Schedule.Schedule + ) => Schedule.Schedule >(2, (self, durationInput) => { const duration = Duration.decode(durationInput) return pipe( @@ -1300,8 +1247,8 @@ export const resetAfter = dual< /** @internal */ export const resetWhen = dual< - (f: Predicate) => (self: Schedule.Schedule) => Schedule.Schedule, - (self: Schedule.Schedule, f: Predicate) => Schedule.Schedule + (f: Predicate) => (self: Schedule.Schedule) => Schedule.Schedule, + (self: Schedule.Schedule, f: Predicate) => Schedule.Schedule >(2, (self, f) => makeWithState( self.initial, @@ -1317,12 +1264,12 @@ export const run = dual< ( now: number, input: Iterable - ) => (self: Schedule.Schedule) => Effect.Effect, never, Env>, - ( - self: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Effect.Effect, never, R>, + ( + self: Schedule.Schedule, now: number, input: Iterable - ) => Effect.Effect, never, Env> + ) => Effect.Effect, never, R> >(3, (self, now, input) => pipe( runLoop(self, now, Chunk.fromIterable(input), self.initial, Chunk.empty()), @@ -1331,7 +1278,7 @@ export const run = dual< /** @internal */ const runLoop = ( - self: Schedule.Schedule, + self: Schedule.Schedule, now: number, inputs: Chunk.Chunk, state: any, @@ -1357,8 +1304,8 @@ const runLoop = ( } /** @internal */ -export const secondOfMinute = (second: number): Schedule.Schedule => - makeWithState<[number, number], never, unknown, number>( +export const secondOfMinute = (second: number): Schedule.Schedule => + makeWithState<[number, number], unknown, number>( [Number.NEGATIVE_INFINITY, 0], (now, _, state) => { if (!Number.isInteger(second) || second < 0 || 59 < second) { @@ -1385,24 +1332,23 @@ export const secondOfMinute = (second: number): Schedule.Schedule => - addDelay(forever, () => duration) +export const spaced = (duration: Duration.DurationInput): Schedule.Schedule => addDelay(forever, () => duration) /** @internal */ -export const succeed = (value: A): Schedule.Schedule => map(forever, () => value) +export const succeed = (value: A): Schedule.Schedule => map(forever, () => value) /** @internal */ -export const sync = (evaluate: LazyArg): Schedule.Schedule => map(forever, evaluate) +export const sync = (evaluate: LazyArg): Schedule.Schedule => map(forever, evaluate) /** @internal */ export const tapInput = dual< - ( - f: (input: In2) => Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - f: (input: In2) => Effect.Effect - ) => Schedule.Schedule + ( + f: (input: In2) => Effect.Effect + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + f: (input: In2) => Effect.Effect + ) => Schedule.Schedule >(2, (self, f) => makeWithState(self.initial, (now, input, state) => core.zipRight( @@ -1412,13 +1358,13 @@ export const tapInput = dual< /** @internal */ export const tapOutput = dual< - ( - f: (out: XO) => Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - f: (out: XO) => Effect.Effect - ) => Schedule.Schedule + ( + f: (out: XO) => Effect.Effect + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + f: (out: XO) => Effect.Effect + ) => Schedule.Schedule >(2, (self, f) => makeWithState(self.initial, (now, input, state) => core.tap( @@ -1427,7 +1373,7 @@ export const tapOutput = dual< ))) /** @internal */ -export const unfold = (initial: A, f: (a: A) => A): Schedule.Schedule => +export const unfold = (initial: A, f: (a: A) => A): Schedule.Schedule => makeWithState(initial, (now, _, state) => core.sync(() => [ @@ -1439,42 +1385,26 @@ export const unfold = (initial: A, f: (a: A) => A): Schedule.Schedule( - that: Schedule.Schedule - ) => (self: Schedule.Schedule) => Schedule.Schedule< - Env | Env2, - In & In2, - [Out, Out2] - >, - ( - self: Schedule.Schedule, - that: Schedule.Schedule - ) => Schedule.Schedule< - Env | Env2, - In & In2, - [Out, Out2] - > + ( + that: Schedule.Schedule + ) => (self: Schedule.Schedule) => Schedule.Schedule<[Out, Out2], In & In2, R | R2>, + ( + self: Schedule.Schedule, + that: Schedule.Schedule + ) => Schedule.Schedule<[Out, Out2], In & In2, R | R2> >(2, (self, that) => unionWith(self, that, Intervals.union)) /** @internal */ export const unionWith = dual< - ( - that: Schedule.Schedule, + ( + that: Schedule.Schedule, f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals - ) => (self: Schedule.Schedule) => Schedule.Schedule< - Env | Env2, - In & In2, - [Out, Out2] - >, - ( - self: Schedule.Schedule, - that: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Schedule.Schedule<[Out, Out2], In & In2, R | R2>, + ( + self: Schedule.Schedule, + that: Schedule.Schedule, f: (x: Intervals.Intervals, y: Intervals.Intervals) => Intervals.Intervals - ) => Schedule.Schedule< - Env | Env2, - In & In2, - [Out, Out2] - > + ) => Schedule.Schedule<[Out, Out2], In & In2, R | R2> >(3, (self, that, f) => makeWithState([self.initial, that.initial], (now, input, state) => core.zipWith( @@ -1514,88 +1444,88 @@ export const unionWith = dual< /** @internal */ export const untilInput = dual< - (f: Predicate) => (self: Schedule.Schedule) => Schedule.Schedule, - (self: Schedule.Schedule, f: Predicate) => Schedule.Schedule + (f: Predicate) => (self: Schedule.Schedule) => Schedule.Schedule, + (self: Schedule.Schedule, f: Predicate) => Schedule.Schedule >(2, (self, f) => check(self, (input, _) => !f(input))) /** @internal */ export const untilInputEffect = dual< - ( - f: (input: In) => Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - f: (input: In) => Effect.Effect - ) => Schedule.Schedule + ( + f: (input: In) => Effect.Effect + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + f: (input: In) => Effect.Effect + ) => Schedule.Schedule >(2, (self, f) => checkEffect(self, (input, _) => effect.negate(f(input)))) /** @internal */ export const untilOutput = dual< - (f: Predicate) => (self: Schedule.Schedule) => Schedule.Schedule, - (self: Schedule.Schedule, f: Predicate) => Schedule.Schedule + (f: Predicate) => (self: Schedule.Schedule) => Schedule.Schedule, + (self: Schedule.Schedule, f: Predicate) => Schedule.Schedule >(2, (self, f) => check(self, (_, out) => !f(out))) /** @internal */ export const untilOutputEffect = dual< - ( - f: (out: Out) => Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - f: (out: Out) => Effect.Effect - ) => Schedule.Schedule + ( + f: (out: Out) => Effect.Effect + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + f: (out: Out) => Effect.Effect + ) => Schedule.Schedule >(2, (self, f) => checkEffect(self, (_, out) => effect.negate(f(out)))) /** @internal */ export const upTo = dual< - (duration: Duration.DurationInput) => ( - self: Schedule.Schedule - ) => Schedule.Schedule, - ( - self: Schedule.Schedule, + (duration: Duration.DurationInput) => ( + self: Schedule.Schedule + ) => Schedule.Schedule, + ( + self: Schedule.Schedule, duration: Duration.DurationInput - ) => Schedule.Schedule + ) => Schedule.Schedule >(2, (self, duration) => zipLeft(self, recurUpTo(duration))) /** @internal */ export const whileInput = dual< - (f: Predicate) => (self: Schedule.Schedule) => Schedule.Schedule, - (self: Schedule.Schedule, f: Predicate) => Schedule.Schedule + (f: Predicate) => (self: Schedule.Schedule) => Schedule.Schedule, + (self: Schedule.Schedule, f: Predicate) => Schedule.Schedule >(2, (self, f) => check(self, (input, _) => f(input))) /** @internal */ export const whileInputEffect = dual< - ( - f: (input: In) => Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - f: (input: In) => Effect.Effect - ) => Schedule.Schedule + ( + f: (input: In) => Effect.Effect + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + f: (input: In) => Effect.Effect + ) => Schedule.Schedule >(2, (self, f) => checkEffect(self, (input, _) => f(input))) /** @internal */ export const whileOutput = dual< - (f: Predicate) => (self: Schedule.Schedule) => Schedule.Schedule, - (self: Schedule.Schedule, f: Predicate) => Schedule.Schedule + (f: Predicate) => (self: Schedule.Schedule) => Schedule.Schedule, + (self: Schedule.Schedule, f: Predicate) => Schedule.Schedule >(2, (self, f) => check(self, (_, out) => f(out))) /** @internal */ export const whileOutputEffect = dual< - ( - f: (out: Out) => Effect.Effect - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - f: (out: Out) => Effect.Effect - ) => Schedule.Schedule + ( + f: (out: Out) => Effect.Effect + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + f: (out: Out) => Effect.Effect + ) => Schedule.Schedule >(2, (self, f) => checkEffect(self, (_, out) => f(out))) /** @internal */ -export const windowed = (intervalInput: Duration.DurationInput): Schedule.Schedule => { +export const windowed = (intervalInput: Duration.DurationInput): Schedule.Schedule => { const interval = Duration.decode(intervalInput) const millis = Duration.toMillis(interval) - return makeWithState<[Option.Option, number], never, unknown, number>( + return makeWithState<[Option.Option, number], unknown, number>( [Option.none(), 0], (now, _, [option, n]) => { switch (option._tag) { @@ -1626,37 +1556,37 @@ export const windowed = (intervalInput: Duration.DurationInput): Schedule.Schedu /** @internal */ export const zipLeft = dual< - ( - that: Schedule.Schedule - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - that: Schedule.Schedule - ) => Schedule.Schedule + ( + that: Schedule.Schedule + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + that: Schedule.Schedule + ) => Schedule.Schedule >(2, (self, that) => map(intersect(self, that), (out) => out[0])) /** @internal */ export const zipRight = dual< - ( - that: Schedule.Schedule - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - that: Schedule.Schedule - ) => Schedule.Schedule + ( + that: Schedule.Schedule + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + that: Schedule.Schedule + ) => Schedule.Schedule >(2, (self, that) => map(intersect(self, that), (out) => out[1])) /** @internal */ export const zipWith = dual< - ( - that: Schedule.Schedule, + ( + that: Schedule.Schedule, f: (out: Out, out2: Out2) => Out3 - ) => (self: Schedule.Schedule) => Schedule.Schedule, - ( - self: Schedule.Schedule, - that: Schedule.Schedule, + ) => (self: Schedule.Schedule) => Schedule.Schedule, + ( + self: Schedule.Schedule, + that: Schedule.Schedule, f: (out: Out, out2: Out2) => Out3 - ) => Schedule.Schedule + ) => Schedule.Schedule >(3, (self, that, f) => map(intersect(self, that), ([out, out2]) => f(out, out2))) // ----------------------------------------------------------------------------- @@ -1860,30 +1790,30 @@ const scheduleDefectRefail = (self: Effect.Effect) => /** @internal */ export const repeat_Effect = dual< ( - schedule: Schedule.Schedule + schedule: Schedule.Schedule ) => (self: Effect.Effect) => Effect.Effect, ( self: Effect.Effect, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ) => Effect.Effect >(2, (self, schedule) => repeatOrElse_Effect(self, schedule, (e, _) => core.fail(e))) /** @internal */ export const repeat_combined = dual<{ - >( + , A>( options: O ): (self: Effect.Effect) => Effect.Repeat.Return - ( - schedule: Schedule.Schedule + ( + schedule: Schedule.Schedule ): (self: Effect.Effect) => Effect.Effect }, { >( self: Effect.Effect, options: O ): Effect.Repeat.Return - ( + ( self: Effect.Effect, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ): Effect.Effect }>( 2, @@ -1922,12 +1852,12 @@ export const repeat_combined = dual<{ /** @internal */ export const repeatOrElse_Effect = dual< ( - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, orElse: (error: E, option: Option.Option) => Effect.Effect ) => (self: Effect.Effect) => Effect.Effect, ( self: Effect.Effect, - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, orElse: (error: E, option: Option.Option) => Effect.Effect ) => Effect.Effect >(3, (self, schedule, orElse) => @@ -1940,7 +1870,7 @@ export const repeatOrElse_Effect = dual< /** @internal */ const repeatOrElseEffectLoop = ( self: Effect.Effect, - driver: Schedule.ScheduleDriver, + driver: Schedule.ScheduleDriver, orElse: (error: E, option: Option.Option) => Effect.Effect, value: A ): Effect.Effect => { @@ -1957,11 +1887,11 @@ const repeatOrElseEffectLoop = ( /** @internal */ export const retry_Effect = dual< ( - policy: Schedule.Schedule + policy: Schedule.Schedule ) => (self: Effect.Effect) => Effect.Effect, ( self: Effect.Effect, - policy: Schedule.Schedule + policy: Schedule.Schedule ) => Effect.Effect >(2, (self, policy) => retryOrElse_Effect(self, policy, (e, _) => core.fail(e))) @@ -1972,16 +1902,16 @@ export const retry_combined: { ): ( self: Effect.Effect ) => Effect.Retry.Return - ( - policy: Schedule.Schedule, B> + ( + policy: Schedule.Schedule, R1> ): (self: Effect.Effect) => Effect.Effect >( self: Effect.Effect, options: O ): Effect.Retry.Return - ( + ( self: Effect.Effect, - policy: Schedule.Schedule + policy: Schedule.Schedule ): Effect.Effect } = dual( 2, @@ -2018,13 +1948,13 @@ export const retry_combined: { /** @internal */ export const retryOrElse_Effect = dual< - ( - policy: Schedule.Schedule, A1>, + ( + policy: Schedule.Schedule, R1>, orElse: (e: Types.NoInfer, out: A1) => Effect.Effect ) => (self: Effect.Effect) => Effect.Effect, ( self: Effect.Effect, - policy: Schedule.Schedule, A1>, + policy: Schedule.Schedule, R1>, orElse: (e: Types.NoInfer, out: A1) => Effect.Effect ) => Effect.Effect >(3, (self, policy, orElse) => @@ -2036,7 +1966,7 @@ export const retryOrElse_Effect = dual< /** @internal */ const retryOrElse_EffectLoop = ( self: Effect.Effect, - driver: Schedule.ScheduleDriver, + driver: Schedule.ScheduleDriver, orElse: (e: E, out: A1) => Effect.Effect ): Effect.Effect => { return core.catchAll( @@ -2057,27 +1987,27 @@ const retryOrElse_EffectLoop = ( /** @internal */ export const schedule_Effect = dual< ( - schedule: Schedule.Schedule + schedule: Schedule.Schedule ) => (self: Effect.Effect) => Effect.Effect, ( self: Effect.Effect, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ) => Effect.Effect >(2, ( self: Effect.Effect, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ) => scheduleFrom_Effect(self, void 0, schedule)) /** @internal */ export const scheduleFrom_Effect = dual< ( initial: In, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ) => (self: Effect.Effect) => Effect.Effect, ( self: Effect.Effect, initial: In, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ) => Effect.Effect >(3, (self, initial, schedule) => core.flatMap( @@ -2089,7 +2019,7 @@ export const scheduleFrom_Effect = dual< const scheduleFrom_EffectLoop = ( self: Effect.Effect, initial: In, - driver: Schedule.ScheduleDriver + driver: Schedule.ScheduleDriver ): Effect.Effect => core.matchEffect(driver.next(initial), { onFailure: () => core.orDie(driver.last), @@ -2097,10 +2027,10 @@ const scheduleFrom_EffectLoop = ( }) /** @internal */ -export const count: Schedule.Schedule = unfold(0, (n) => n + 1) +export const count: Schedule.Schedule = unfold(0, (n) => n + 1) /** @internal */ -export const elapsed: Schedule.Schedule = makeWithState( +export const elapsed: Schedule.Schedule = makeWithState( Option.none() as Option.Option, (now, _, state) => { switch (state._tag) { @@ -2127,10 +2057,10 @@ export const elapsed: Schedule.Schedule = mak ) /** @internal */ -export const forever: Schedule.Schedule = unfold(0, (n) => n + 1) +export const forever: Schedule.Schedule = unfold(0, (n) => n + 1) /** @internal */ -export const once: Schedule.Schedule = asUnit(recurs(1)) +export const once: Schedule.Schedule = asUnit(recurs(1)) /** @internal */ -export const stop: Schedule.Schedule = asUnit(recurs(0)) +export const stop: Schedule.Schedule = asUnit(recurs(0)) diff --git a/packages/effect/src/internal/stream.ts b/packages/effect/src/internal/stream.ts index 92bd26e688..64d609be4c 100644 --- a/packages/effect/src/internal/stream.ts +++ b/packages/effect/src/internal/stream.ts @@ -133,21 +133,21 @@ export const aggregate = dual< /** @internal */ export const aggregateWithin = dual< - ( + ( sink: Sink.Sink, - schedule: Schedule.Schedule, C> + schedule: Schedule.Schedule, R3> ) => (self: Stream.Stream) => Stream.Stream, - ( + ( self: Stream.Stream, sink: Sink.Sink, - schedule: Schedule.Schedule, C> + schedule: Schedule.Schedule, R3> ) => Stream.Stream >( 3, - ( + ( self: Stream.Stream, sink: Sink.Sink, - schedule: Schedule.Schedule, C> + schedule: Schedule.Schedule, R3> ): Stream.Stream => filterMap( aggregateWithinEither(self, sink, schedule), @@ -161,21 +161,21 @@ export const aggregateWithin = dual< /** @internal */ export const aggregateWithinEither = dual< - ( + ( sink: Sink.Sink, - schedule: Schedule.Schedule, C> + schedule: Schedule.Schedule, R3> ) => (self: Stream.Stream) => Stream.Stream, E2 | E, R2 | R3 | R>, - ( + ( self: Stream.Stream, sink: Sink.Sink, - schedule: Schedule.Schedule, C> + schedule: Schedule.Schedule, R3> ) => Stream.Stream, E2 | E, R2 | R3 | R> >( 3, - ( + ( self: Stream.Stream, sink: Sink.Sink, - schedule: Schedule.Schedule, C> + schedule: Schedule.Schedule, R3> ): Stream.Stream, E2 | E, R2 | R3 | R> => { const layer = Effect.all([ Handoff.make>(), @@ -3017,7 +3017,7 @@ export const fromQueue = ( ) /** @internal */ -export const fromSchedule = (schedule: Schedule.Schedule): Stream.Stream => +export const fromSchedule = (schedule: Schedule.Schedule): Stream.Stream => pipe( Schedule.driver(schedule), Effect.map((driver) => repeatEffectOption(driver.next(void 0))), @@ -4805,18 +4805,18 @@ export const refineOrDieWith = dual< /** @internal */ export const repeat = dual< - ( - schedule: Schedule.Schedule + ( + schedule: Schedule.Schedule ) => (self: Stream.Stream) => Stream.Stream, - ( + ( self: Stream.Stream, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ) => Stream.Stream >( 2, - ( + ( self: Stream.Stream, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ): Stream.Stream => filterMap( repeatEither(self, schedule), @@ -4855,18 +4855,18 @@ export const repeatEffectOption = (effect: Effect.Effect( - schedule: Schedule.Schedule + ( + schedule: Schedule.Schedule ) => (self: Stream.Stream) => Stream.Stream, E, R2 | R>, - ( + ( self: Stream.Stream, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ) => Stream.Stream, E, R2 | R> >( 2, - ( + ( self: Stream.Stream, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ): Stream.Stream, E, R2 | R> => repeatWith(self, schedule, { onElement: (a): Either.Either => Either.right(a), @@ -4876,18 +4876,18 @@ export const repeatEither = dual< /** @internal */ export const repeatElements = dual< - ( - schedule: Schedule.Schedule + ( + schedule: Schedule.Schedule ) => (self: Stream.Stream) => Stream.Stream, - ( + ( self: Stream.Stream, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ) => Stream.Stream >( 2, - ( + ( self: Stream.Stream, - schedule: Schedule.Schedule + schedule: Schedule.Schedule ): Stream.Stream => filterMap( repeatElementsWith(self, schedule, { onElement: (a) => Option.some(a), onSchedule: Option.none }), @@ -4897,16 +4897,16 @@ export const repeatElements = dual< /** @internal */ export const repeatElementsWith = dual< - ( - schedule: Schedule.Schedule, + ( + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C readonly onSchedule: (b: B) => C } - ) => (self: Stream.Stream) => Stream.Stream, - ( + ) => (self: Stream.Stream) => Stream.Stream, + ( self: Stream.Stream, - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C readonly onSchedule: (b: B) => C @@ -4914,9 +4914,9 @@ export const repeatElementsWith = dual< ) => Stream.Stream >( 3, - ( + ( self: Stream.Stream, - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C readonly onSchedule: (b: B) => C @@ -4986,16 +4986,16 @@ export const repeatValue = (value: A): Stream.Stream => /** @internal */ export const repeatWith = dual< - ( - schedule: Schedule.Schedule, + ( + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C readonly onSchedule: (b: B) => C } - ) => (self: Stream.Stream) => Stream.Stream, - ( + ) => (self: Stream.Stream) => Stream.Stream, + ( self: Stream.Stream, - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C readonly onSchedule: (b: B) => C @@ -5003,9 +5003,9 @@ export const repeatWith = dual< ) => Stream.Stream >( 3, - ( + ( self: Stream.Stream, - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C readonly onSchedule: (b: B) => C @@ -5039,16 +5039,15 @@ export const repeatWith = dual< } ) -/** @internal */ -export const repeatWithSchedule = ( +const repeatWithSchedule = ( value: A, - schedule: Schedule.Schedule + schedule: Schedule.Schedule<_, A, R> ): Stream.Stream => repeatEffectWithSchedule(Effect.succeed(value), schedule) /** @internal */ -export const repeatEffectWithSchedule = ( +export const repeatEffectWithSchedule = ( effect: Effect.Effect, - schedule: Schedule.Schedule + schedule: Schedule.Schedule<_, A0, R2> ): Stream.Stream => flatMap( fromEffect(Effect.zip(effect, Schedule.driver(schedule))), @@ -5065,18 +5064,18 @@ export const repeatEffectWithSchedule = ( /** @internal */ export const retry = dual< - ( - schedule: Schedule.Schedule - ) => (self: Stream.Stream) => Stream.Stream, - ( + ( + schedule: Schedule.Schedule<_, E0, R2> + ) => (self: Stream.Stream) => Stream.Stream, + ( self: Stream.Stream, - schedule: Schedule.Schedule + schedule: Schedule.Schedule<_, E0, R2> ) => Stream.Stream >( 2, - ( + ( self: Stream.Stream, - schedule: Schedule.Schedule + schedule: Schedule.Schedule<_, E0, R2> ): Stream.Stream => unwrap( Effect.map(Schedule.driver(schedule), (driver) => { @@ -5512,18 +5511,18 @@ export const scanReduceEffect = dual< /** @internal */ export const schedule = dual< - ( - schedule: Schedule.Schedule - ) => (self: Stream.Stream) => Stream.Stream, - ( + <_, A0 extends A, R2, A>( + schedule: Schedule.Schedule<_, A0, R2> + ) => (self: Stream.Stream) => Stream.Stream, + ( self: Stream.Stream, - schedule: Schedule.Schedule + schedule: Schedule.Schedule<_, A0, R2> ) => Stream.Stream >( 2, - ( + ( self: Stream.Stream, - schedule: Schedule.Schedule + schedule: Schedule.Schedule<_, A0, R2> ): Stream.Stream => filterMap( scheduleWith(self, schedule, { onElement: Option.some, onSchedule: Option.none }), @@ -5533,16 +5532,16 @@ export const schedule = dual< /** @internal */ export const scheduleWith = dual< - ( - schedule: Schedule.Schedule, + ( + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C readonly onSchedule: (b: B) => C } - ) => (self: Stream.Stream) => Stream.Stream, - ( + ) => (self: Stream.Stream) => Stream.Stream, + ( self: Stream.Stream, - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C readonly onSchedule: (b: B) => C @@ -5550,16 +5549,16 @@ export const scheduleWith = dual< ) => Stream.Stream >( 3, - ( + ( self: Stream.Stream, - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, options: { readonly onElement: (a: A) => C readonly onSchedule: (b: B) => C } ): Stream.Stream => { const loop = ( - driver: Schedule.ScheduleDriver, + driver: Schedule.ScheduleDriver, iterator: Iterator ): Channel.Channel, Chunk.Chunk, E, E, unknown, unknown, R2> => { const next = iterator.next() diff --git a/packages/effect/test/Schedule.test.ts b/packages/effect/test/Schedule.test.ts index 83a93fc6a7..6d442b52a4 100644 --- a/packages/effect/test/Schedule.test.ts +++ b/packages/effect/test/Schedule.test.ts @@ -797,7 +797,7 @@ const failOn0 = (ref: Ref.Ref): Effect.Effect => { const alwaysFail = (ref: Ref.Ref): Effect.Effect => { return Ref.updateAndGet(ref, (n) => n + 1).pipe(Effect.flatMap((n) => Effect.fail(`Error: ${n}`))) } -const repeat = (schedule: Schedule.Schedule): Effect.Effect => { +const repeat = (schedule: Schedule.Schedule): Effect.Effect => { return Ref.make(0).pipe( Effect.flatMap((ref) => ref.pipe(Ref.updateAndGet((n) => n + 1), Effect.repeat(schedule))) ) @@ -808,7 +808,7 @@ const roundToNearestHour = (date: Date): number => { return date.getMilliseconds() } const checkDelays = ( - schedule: Schedule.Schedule + schedule: Schedule.Schedule ): Effect.Effect< readonly [ Chunk.Chunk, @@ -825,7 +825,7 @@ const checkDelays = ( return [actual, expected] as const }) } -const checkRepetitions = (schedule: Schedule.Schedule): Effect.Effect< +const checkRepetitions = (schedule: Schedule.Schedule): Effect.Effect< readonly [ Chunk.Chunk, Chunk.Chunk @@ -850,7 +850,7 @@ export const run = ( ) } export const runCollect = ( - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, input: Iterable ): Effect.Effect, never, Env> => { return run( @@ -860,7 +860,7 @@ export const runCollect = ( ) } const runCollectLoop = ( - driver: Schedule.ScheduleDriver, + driver: Schedule.ScheduleDriver, input: Chunk.Chunk, acc: Chunk.Chunk ): Effect.Effect, never, Env> => { @@ -883,7 +883,7 @@ const runCollectLoop = ( ) } const runManually = ( - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, inputs: Iterable< readonly [ number, @@ -906,7 +906,7 @@ const runManually = ( return runManuallyLoop(schedule, schedule.initial, Chunk.fromIterable(inputs), Chunk.empty()) } const runManuallyLoop = ( - schedule: Schedule.Schedule, + schedule: Schedule.Schedule, state: unknown, inputs: Chunk.Chunk< readonly [ diff --git a/packages/effect/test/TReentrantLock.test.ts b/packages/effect/test/TReentrantLock.test.ts index dea4d971d5..d9d9849255 100644 --- a/packages/effect/test/TReentrantLock.test.ts +++ b/packages/effect/test/TReentrantLock.test.ts @@ -11,11 +11,7 @@ import * as STM from "effect/STM" import * as TReentrantLock from "effect/TReentrantLock" import { assert, describe } from "vitest" -const pollSchedule = (): Schedule.Schedule< - never, - Option.Option>, - Option.Option> -> => +const pollSchedule = (): Schedule.Schedule>, Option.Option>> => pipe( Schedule.recurs(100), Schedule.zipRight( diff --git a/packages/platform/src/Http/Client.ts b/packages/platform/src/Http/Client.ts index 7e6838b309..43c74cd67a 100644 --- a/packages/platform/src/Http/Client.ts +++ b/packages/platform/src/Http/Client.ts @@ -365,8 +365,8 @@ export const mapInputRequestEffect: { * @category error handling */ export const retry: { - (policy: Schedule.Schedule): (self: Client) => Client - (self: Client, policy: Schedule.Schedule): Client + (policy: Schedule.Schedule): (self: Client) => Client + (self: Client, policy: Schedule.Schedule): Client } = internal.retry /** diff --git a/packages/platform/src/internal/http/client.ts b/packages/platform/src/internal/http/client.ts index ab1e117c91..ac4a84822c 100644 --- a/packages/platform/src/internal/http/client.ts +++ b/packages/platform/src/internal/http/client.ts @@ -531,17 +531,17 @@ export const mapInputRequestEffect = dual< /** @internal */ export const retry: { ( - policy: Schedule.Schedule + policy: Schedule.Schedule ): (self: Client.Client) => Client.Client ( self: Client.Client, - policy: Schedule.Schedule + policy: Schedule.Schedule ): Client.Client } = dual( 2, ( self: Client.Client, - policy: Schedule.Schedule + policy: Schedule.Schedule ): Client.Client => transformResponse(self, Effect.retry(policy)) )