@@ -446,24 +446,27 @@ export const mapErrorRead: {
|
||||
/**
|
||||
* Transforms modify errors of a `Lens`.
|
||||
*
|
||||
* Applies to the `modify` effect. Since `modify` may also fail with errors coming from the
|
||||
* user-supplied callback, the handler receives `unknown`.
|
||||
* Applies to the commit/rebuild portion of `modifyEffect` while leaving failures from the
|
||||
* user-supplied callback unchanged.
|
||||
*/
|
||||
export const mapErrorWrite: {
|
||||
<A, ER, EW, RR, RW, E2>(
|
||||
self: Lens<A, ER, EW, RR, RW>,
|
||||
f: (error: unknown) => E2,
|
||||
f: (error: NoInfer<EW>) => E2,
|
||||
): Lens<A, ER, E2, RR, RW>
|
||||
<A, ER, EW, RR, RW, E2>(
|
||||
f: (error: unknown) => E2,
|
||||
f: (error: NoInfer<EW>) => E2,
|
||||
): (self: Lens<A, ER, EW, RR, RW>) => Lens<A, ER, E2, RR, RW>
|
||||
} = Function.dual(2, <A, ER, EW, RR, RW, E2>(
|
||||
self: Lens<A, ER, EW, RR, RW>,
|
||||
f: (error: unknown) => E2,
|
||||
f: (error: NoInfer<EW>) => E2,
|
||||
): Lens<A, ER, E2, RR, RW> => derive(self, {
|
||||
resolve: parent => Effect.map(parent, frame => ({
|
||||
value: frame.value,
|
||||
commit: next => Effect.mapError(frame.commit(next), f),
|
||||
commit: next => Effect.flatMap(
|
||||
next,
|
||||
value => Effect.mapError(frame.commit(Effect.succeed(value)), f),
|
||||
),
|
||||
})),
|
||||
transformStream: identity,
|
||||
}))
|
||||
@@ -471,26 +474,29 @@ export const mapErrorWrite: {
|
||||
/**
|
||||
* Transforms all errors of a `Lens`.
|
||||
*
|
||||
* Applies to `get`, `changes`, and `modify`. Since `modify` may also fail with errors coming
|
||||
* from the user-supplied callback, the handler receives `unknown`.
|
||||
* Applies to `get`, `changes`, and the commit/rebuild portion of `modifyEffect` while leaving
|
||||
* failures from the user-supplied callback unchanged.
|
||||
*/
|
||||
export const mapError: {
|
||||
<A, ER, EW, RR, RW, E2>(
|
||||
self: Lens<A, ER, EW, RR, RW>,
|
||||
f: (error: unknown) => E2,
|
||||
f: (error: NoInfer<ER | EW>) => E2,
|
||||
): Lens<A, E2, E2, RR, RW>
|
||||
<A, ER, EW, RR, RW, E2>(
|
||||
f: (error: unknown) => E2,
|
||||
f: (error: NoInfer<ER | EW>) => E2,
|
||||
): (self: Lens<A, ER, EW, RR, RW>) => Lens<A, E2, E2, RR, RW>
|
||||
} = Function.dual(2, <A, ER, EW, RR, RW, E2>(
|
||||
self: Lens<A, ER, EW, RR, RW>,
|
||||
f: (error: unknown) => E2,
|
||||
f: (error: NoInfer<ER | EW>) => E2,
|
||||
): Lens<A, E2, E2, RR, RW> => derive(self, {
|
||||
resolve: parent => Effect.map(
|
||||
Effect.mapError(parent, f),
|
||||
frame => ({
|
||||
value: frame.value,
|
||||
commit: next => Effect.mapError(frame.commit(next), f),
|
||||
commit: next => Effect.flatMap(
|
||||
next,
|
||||
value => Effect.mapError(frame.commit(Effect.succeed(value)), f),
|
||||
),
|
||||
}),
|
||||
),
|
||||
transformStream: Stream.mapError(f),
|
||||
@@ -528,18 +534,21 @@ export const catchAllRead: {
|
||||
export const catchAllWrite: {
|
||||
<A, ER, EW, RR, RW, E2, R2>(
|
||||
self: Lens<A, ER, EW, RR, RW>,
|
||||
f: (error: unknown) => Effect.Effect<void, E2, R2>,
|
||||
f: (error: NoInfer<EW>) => Effect.Effect<void, E2, R2>,
|
||||
): Lens<A, ER, E2, RR, RW | R2>
|
||||
<A, ER, EW, RR, RW, E2, R2>(
|
||||
f: (error: unknown) => Effect.Effect<void, E2, R2>,
|
||||
f: (error: NoInfer<EW>) => Effect.Effect<void, E2, R2>,
|
||||
): (self: Lens<A, ER, EW, RR, RW>) => Lens<A, ER, E2, RR, RW | R2>
|
||||
} = Function.dual(2, <A, ER, EW, RR, RW, E2, R2>(
|
||||
self: Lens<A, ER, EW, RR, RW>,
|
||||
f: (error: unknown) => Effect.Effect<void, E2, R2>,
|
||||
f: (error: NoInfer<EW>) => Effect.Effect<void, E2, R2>,
|
||||
): Lens<A, ER, E2, RR, RW | R2> => derive(self, {
|
||||
resolve: parent => Effect.map(parent, frame => ({
|
||||
value: frame.value,
|
||||
commit: next => Effect.catchAll(frame.commit(next), f),
|
||||
commit: next => Effect.flatMap(
|
||||
next,
|
||||
value => Effect.catchAll(frame.commit(Effect.succeed(value)), f),
|
||||
),
|
||||
})),
|
||||
transformStream: identity,
|
||||
}))
|
||||
@@ -552,14 +561,14 @@ export const catchAllWrite: {
|
||||
export const tapErrorRead: {
|
||||
<A, ER, EW, RR, RW, E2, R2>(
|
||||
self: Lens<A, ER, EW, RR, RW>,
|
||||
f: (error: NoInfer<ER>) => Effect.Effect<any, E2, R2>,
|
||||
f: (error: NoInfer<ER>) => Effect.Effect<unknown, E2, R2>,
|
||||
): Lens<A, ER | E2, EW, RR | R2, RW>
|
||||
<A, ER, EW, RR, RW, E2, R2>(
|
||||
f: (error: NoInfer<ER>) => Effect.Effect<any, E2, R2>,
|
||||
f: (error: NoInfer<ER>) => Effect.Effect<unknown, E2, R2>,
|
||||
): (self: Lens<A, ER, EW, RR, RW>) => Lens<A, ER | E2, EW, RR | R2, RW>
|
||||
} = Function.dual(2, <A, ER, EW, RR, RW, E2, R2>(
|
||||
self: Lens<A, ER, EW, RR, RW>,
|
||||
f: (error: NoInfer<ER>) => Effect.Effect<any, E2, R2>,
|
||||
f: (error: NoInfer<ER>) => Effect.Effect<unknown, E2, R2>,
|
||||
): Lens<A, ER | E2, EW, RR | R2, RW> => derive(self, {
|
||||
resolve: Effect.tapError(f),
|
||||
transformStream: Stream.tapError(f),
|
||||
@@ -568,24 +577,27 @@ export const tapErrorRead: {
|
||||
/**
|
||||
* Runs an effect when modify failures occur.
|
||||
*
|
||||
* Applies to the `modify` effect. Since `modify` may also fail with errors coming from the
|
||||
* user-supplied callback, the handler receives `unknown`.
|
||||
* Applies to the commit/rebuild portion of `modifyEffect` while leaving failures from the
|
||||
* user-supplied callback unchanged.
|
||||
*/
|
||||
export const tapErrorWrite: {
|
||||
<A, ER, EW, RR, RW, E2, R2>(
|
||||
self: Lens<A, ER, EW, RR, RW>,
|
||||
f: (error: unknown) => Effect.Effect<any, E2, R2>,
|
||||
f: (error: NoInfer<EW>) => Effect.Effect<unknown, E2, R2>,
|
||||
): Lens<A, ER, EW | E2, RR, RW | R2>
|
||||
<A, ER, EW, RR, RW, E2, R2>(
|
||||
f: (error: unknown) => Effect.Effect<any, E2, R2>,
|
||||
f: (error: NoInfer<EW>) => Effect.Effect<unknown, E2, R2>,
|
||||
): (self: Lens<A, ER, EW, RR, RW>) => Lens<A, ER, EW | E2, RR, RW | R2>
|
||||
} = Function.dual(2, <A, ER, EW, RR, RW, E2, R2>(
|
||||
self: Lens<A, ER, EW, RR, RW>,
|
||||
f: (error: unknown) => Effect.Effect<any, E2, R2>,
|
||||
f: (error: NoInfer<EW>) => Effect.Effect<unknown, E2, R2>,
|
||||
): Lens<A, ER, EW | E2, RR, RW | R2> => derive(self, {
|
||||
resolve: parent => Effect.map(parent, frame => ({
|
||||
value: frame.value,
|
||||
commit: next => Effect.tapError(frame.commit(next), f),
|
||||
commit: next => Effect.flatMap(
|
||||
next,
|
||||
value => Effect.tapError(frame.commit(Effect.succeed(value)), f),
|
||||
),
|
||||
})),
|
||||
transformStream: identity,
|
||||
}))
|
||||
@@ -593,26 +605,29 @@ export const tapErrorWrite: {
|
||||
/**
|
||||
* Runs an effect when any `Lens` failure occurs.
|
||||
*
|
||||
* Applies to `get`, `changes`, and `modify`. Since `modify` may also fail with errors coming
|
||||
* from the user-supplied callback, the handler receives `unknown`.
|
||||
* Applies to `get`, `changes`, and the commit/rebuild portion of `modifyEffect` while leaving
|
||||
* failures from the user-supplied callback unchanged.
|
||||
*/
|
||||
export const tapError: {
|
||||
<A, ER, EW, RR, RW, E2, R2>(
|
||||
self: Lens<A, ER, EW, RR, RW>,
|
||||
f: (error: unknown) => Effect.Effect<any, E2, R2>,
|
||||
f: (error: NoInfer<ER | EW>) => Effect.Effect<unknown, E2, R2>,
|
||||
): Lens<A, ER | E2, EW | E2, RR | R2, RW | R2>
|
||||
<A, ER, EW, RR, RW, E2, R2>(
|
||||
f: (error: unknown) => Effect.Effect<any, E2, R2>,
|
||||
f: (error: NoInfer<ER | EW>) => Effect.Effect<unknown, E2, R2>,
|
||||
): (self: Lens<A, ER, EW, RR, RW>) => Lens<A, ER | E2, EW | E2, RR | R2, RW | R2>
|
||||
} = Function.dual(2, <A, ER, EW, RR, RW, E2, R2>(
|
||||
self: Lens<A, ER, EW, RR, RW>,
|
||||
f: (error: unknown) => Effect.Effect<any, E2, R2>,
|
||||
f: (error: NoInfer<ER | EW>) => Effect.Effect<unknown, E2, R2>,
|
||||
): Lens<A, ER | E2, EW | E2, RR | R2, RW | R2> => derive(self, {
|
||||
resolve: parent => Effect.map(
|
||||
Effect.tapError(parent, f),
|
||||
frame => ({
|
||||
value: frame.value,
|
||||
commit: next => Effect.tapError(frame.commit(next), f),
|
||||
commit: next => Effect.flatMap(
|
||||
next,
|
||||
value => Effect.tapError(frame.commit(Effect.succeed(value)), f),
|
||||
),
|
||||
}),
|
||||
),
|
||||
transformStream: Stream.tapError(f),
|
||||
|
||||
Reference in New Issue
Block a user