Total validation with match() + Exception
// Multi-capability type: validation with logging and error handling
// Demonstrates record-based capabilities for clean composition
type ConfigProgramCaps = Readonly<{
console: typeof Console.spec;
exception: typeof Exception.spec;
}>;
const config = (): Eff<ConfigSnapshot, ConfigProgramCaps> =>
seq()
.let(() => configInput) // ctx.v1
.tap((input) => Console.op.log(`Validating ${input.label}`))
.let((input) => ensureFlag(input.featureFlag)) // ctx.v2
.let((_, ctx) => ensureThrottle((ctx!["v1"] as ConfigInput).throttle)) // ctx.v3
.return((throttle, ctx) => ({
feature: ctx!["v2"] as FeatureMode,
throttle,
label: (ctx!["v1"] as ConfigInput).label,
}));
Console output, timeline events will render here after you run the program.
Handlers: Console.capture() ยท Exception.tryCatch()