Default Services

Effect comes equipped with five pre-built services:

ts
type DefaultServices = Clock | Console | Random | ConfigProvider | Tracer
ts
type DefaultServices = Clock | Console | Random | ConfigProvider | Tracer

When we employ these services, there's no need to explicitly provide their implementations. Effect automatically supplies live versions of these services to our effects, sparing us from manual setup.

ts
import { Effect, Clock, Console } from "effect"
 
const program = Effect.gen(function* (_) {
const now = yield* _(Clock.currentTimeMillis)
yield* _(Console.log(`Application started at ${new Date(now)}`))
})
ts
import { Effect, Clock, Console } from "effect"
 
const program = Effect.gen(function* (_) {
const now = yield* _(Clock.currentTimeMillis)
yield* _(Console.log(`Application started at ${new Date(now)}`))
})

As you can observe, even if our program utilizes both Clock and Console, the R parameter, representing the contextual data required for the effect to execute, remains set to never.

ts
Effect<void, never, never>
ts
Effect<void, never, never>

Effect takes care of handling these services seamlessly for us.