Effect CommunityEC
Effect Community3y ago
41 replies
danielo515

Issue with first flatMap in program

Am I misunderstanding something or the first flatMap does not make sense here?:
import { Effect, Console } from "effect"
import { Random } from "./service"
 
// $ExpectType Effect<Random, never, void>
const program = Random.pipe(
  Effect.flatMap((random) => random.next),
  Effect.flatMap((randomNumber) =>
    Console.log(`random number: ${randomNumber}`)
  ),
  Effect.flatMap(() => Console.log(`another random number: ???`)) // <= I can't access the random service here
)
Was this page helpful?