import { Effect as E, Context, Layer, pipe } from "effect"
type A = { a: string }
type AB = A & { b: string }
type ABC = AB & { c: string }
const A = Context.GenericTag<A>('@services/A')
const AB = Context.GenericTag<AB>('@services/AB')
const ABC = Context.GenericTag<ABC>('@services/ABC')
const layerA: Layer.Layer<A> = Layer.succeed(A, { a: "a" })
// requires AB
const effectABC: E.Effect<ABC, never, AB> = pipe(AB, E.map(({ a, b }) => ({ a, b, c: "c" })))
// provide A, not AB yet all requirements are met?
const effectABC_noRequirements: E.Effect<ABC, never, never> = pipe(effectABC, E.provide(layerA))
// Blows up with Error: Service not found: @services/AB
E.runSync(effectABC_noRequirements)
import { Effect as E, Context, Layer, pipe } from "effect"
type A = { a: string }
type AB = A & { b: string }
type ABC = AB & { c: string }
const A = Context.GenericTag<A>('@services/A')
const AB = Context.GenericTag<AB>('@services/AB')
const ABC = Context.GenericTag<ABC>('@services/ABC')
const layerA: Layer.Layer<A> = Layer.succeed(A, { a: "a" })
// requires AB
const effectABC: E.Effect<ABC, never, AB> = pipe(AB, E.map(({ a, b }) => ({ a, b, c: "c" })))
// provide A, not AB yet all requirements are met?
const effectABC_noRequirements: E.Effect<ABC, never, never> = pipe(effectABC, E.provide(layerA))
// Blows up with Error: Service not found: @services/AB
E.runSync(effectABC_noRequirements)