Creating a Requirements Layer for an implementation that uses a library with its own requirements...

How do I create a Requirements Layer for an implementation which uses a library that has its own requirements? I know from the docs how to create a layer that uses a Service definition directly, but I'm not figuring out how to model this properly.
import { Effect, Context, Layer } from 'effect';
import { Prompt } from '@effect/cli';
import { Terminal, QuitException } from '@effect/platform/Terminal';

/**
 * A service abstraction for prompting the user for input.
 */
export class UserPrompt extends Context.Tag("UserPromptService")<
  UserPrompt,
  {
    readonly prompt: (query: string) => Effect.Effect<string, never | QuitException>,
  }
>() {}

/**
 * An implementation of UserPrompt using the `@effect/cli/Prompt` library.
 */
export const EffectPromptService: Context.Tag.Service<UserPrompt> = {
  prompt: (query) => Prompt.text({ message: query }),
};

export const EffectPromptLayer = Layer.effect(
  UserPrompt,
  Terminal.pipe(
    Effect.map(t => ({
      prompt: (query: string) => Prompt.text({ message: query })
    })),
  )
);

I know I shouldn't add the Terminal requirement to my UserPrompt definition so that it says generic and uncoupled. I'm trying to use the @effect/cli's Prompt, which requires a Terminal interface from @effect/platform/Terminal that will eventually be provided by @effect/platform-bun. I know I can get Terminal as a requirement of EffectPromptLayer by referencing it, but I don't know how to provide it to Prompt --
Effect.provideService
is for providing service implementations to an Effect, not definitions.
Was this page helpful?