Determining the Order of Statements in a `pipe`

What should I be considering when determining the order of statements in a pipe? Specifically, in terms of the order of providing services/layers, withSpan, etc.

For example:
const nested = Effect.gen(function* () {
  const nestedService = yield* NestedService;
  return nestedService.random();
});

const program = Effect.gen(function* () {
  const _ = yield* nested;
  const service = yield* Service;
  const anotherService = yield* AnotherService;
  return service.do(anotherService.something());
}).pipe(
  Effect.tap(Effect.annotateCurrentSpan),
  Effect.provide(NestedService.Default),
  Effect.provide(Service.Default),
  Effect.provide(AnotherService.Default),
  Effect.tap(Effect.annotateCurrentSpan),
  Effect.withSpan("@project/program"),
)

This is generally the way I would order my pipe expressions but I'm not sure if the order is correct (and how that can determined).
Was this page helpful?