Effect CommunityEC
Effect Community3y ago
4 replies
hczhang

Understanding the use of flatMap with Either and Effect in TypeScript

Could anyone help me to understand the following code? the flatMap expects the lamda function returns Effect, but this code returned Either, still working, no error. Why?
export const flakyEffect = pipe(
  Effect.sync(() => Math.random()), // Effect.Effect<never, never, number>
  Effect.flatMap(x => Either.right(x)), // Effect.Effect<never, never, number>
);
Was this page helpful?