Effect CommunityEC
Effect Community3y ago
9 replies
bug

Preserving Generics in Flow Control Functions

how should i be writing flow control functions that preserve generics?

// works, but does not preserve `A`
// <R, E>(self: Effect.Effect<R, E, unknown>) => Effect.Effect<R, E, unknown>
export const logEffectValueX = Effect.tap(a => Effect.sync(() => console.log(a)))

// works and preserves `A`, but annoying to write
// <R, E, A>(fa: Effect.Effect<R, E, A>) => Effect.Effect<R, E, A>
export const logEffectValue = <R, E, A>(fa: Effect.Effect<R, E, A>) =>
  pipe(
    fa,
    Effect.tap(a => Effect.sync(() => console.log(a))),
  )
Was this page helpful?