Idiomatic way to choose implementations at runtime

Hi there!, I think I'm seriously screwing up how I'm thinking about dependencies. I created a custom layer for KeyValueStore so it uses DyamoDB. That part works, it typechecks, so far so good.

But I tried providing either my custom dynamodb layer, or the file system layer (that's already provided by the effect platform) based on a configuration file. This is where everything started to get screwed up and I did not manage to get something to correctly type check.

Now, my question is: is there an idiomatic way to do that? or should I instead create a service that abstracts what I need from the key value store, and provide different implementations? If so, what's the idiomatic way to choose an implementation at runtime?
Thx!
Was this page helpful?