effect
effect copied to clipboard
Effect.retry no longer infer error
When removing lazy from Effect.retry we lost inference of E, make sure arguments where inference should be deferred to be lazy.
export const getTodo = (id: number) =>
pipe(
Http.request(`https://jsonplaceholder.typicode.com/todos/${id}`),
Effect.flatMap(Http.jsonBody),
Effect.retry(
pipe(
Http.defaultRetrySchedule,
Schedule.whileInput((error: Http.FetchError | Http.JsonBodyError) => error._tag !== "JsonBodyError")
)
)
);
vs
export const getTodo = (id: number) =>
pipe(
Http.request(`https://jsonplaceholder.typicode.com/todos/${id}`),
Effect.flatMap(Http.jsonBody),
Effect.retry(() =>
pipe(
Http.defaultRetrySchedule,
Schedule.whileInput((error) => error._tag !== "JsonBodyError")
)
)
);
Also check why the schedule input doesn't appear to be contravariant, i.e. if E = HttpError | JsonError and Schedule accepts { _tag: string } it should work
I wonder if allowing a lazy schedule is a good option still?
I think it's fine as we have it imho