Refactoring CLI Code with Layers: Seeking Simplification

Layer's related question - I refactored some code in a small cli i wrote to use Layers. And it works as is, but i want to make sure i'm understanding (which I dont think I am).

I have a fetch layer with no requirements.

I then have two layers with requirements of Fetch.

So thats all fine and dandy.

In my app layer, I am providing the layers. and the fetch service like so

cli(process.argv).pipe(
  Effect.provide(Layer.merge(fetchLive, LocationLive)),
  Effect.provide(Layer.merge(fetchLive, GeocoderLive)),
  Effect.provide(fetchLive),
  Effect.provide(NodeContext.layer),
  NodeRuntime.runMain,
);


But because cli is an
effect
and not a layer, i have to merge the layers, and then provide that merge to the effect. Then I also need to provide the fetch service?

I think this is more complicated than it may have to be?
Was this page helpful?