Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Effect.tapExit #4555

Open
jessekelly881 opened this issue Mar 5, 2025 · 0 comments
Open

Effect.tapExit #4555

jessekelly881 opened this issue Mar 5, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@jessekelly881
Copy link
Contributor

jessekelly881 commented Mar 5, 2025

What is the problem this feature would solve?

I found myself needing to tap the full Exit<A, E> of an Effect instead of using tapErrorCause and tap separately. I think it would be a useful helper.

What is the feature you are proposing to solve the problem?

export const tapExit = dual<
    <A, E, X, E2, R2>(
        f: (exit: Exit.Exit<A, Types.NoInfer<E>>) => Effect.Effect<X, E2, R2>
    ) => <R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | E2, R | R2>,
    <A, E, R, X, E2, R2>(
        self: Effect.Effect<A, E, R>,
        f: (exit: Exit.Exit<A, E>) => Effect.Effect<X, E2, R2>
    ) => Effect.Effect<A, E | E2, R | R2>
>(2, (self, f) =>
    Effect.matchCauseEffect(self, {
        onFailure: (cause) => Effect.zipRight(f(Exit.failCause(cause)), Effect.failCause(cause)),
        onSuccess: (value) => Effect.zipRight(f(Exit.succeed(value)), Effect.succeed(value)),
    }))

What alternatives have you considered?

No response

@jessekelly881 jessekelly881 added the enhancement New feature or request label Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant