Effect CommunityEC
Effect Community3y ago
6 replies
Jost

Using TaskEither with Effect: Improving Code for Better Integration

Hello! I am still quite new to Effect and have been using fp-ts so far. Both I really like! Thanks for the great work!

Now I have the situation in which I wrote code with Effect and want to use a function from my lib that is returning a TaskEither<IngestError, Result>. I found a way to make an Effect<never, IngestError, Result> from it. But the code looks like it should be improved 😅 . What would your suggested way of achieving that look like?

export const calculate = (stream): Effect.Effect<never, IngestError, Result> =>
  pipe(
    Y2023.main(stream, { inputType: 'stream', firstRow: 6 }),
    TE.matchW(Effect.fail, Effect.succeed),
    Effect.promise,
    Effect.flatMap(identity)
  )
Was this page helpful?