Effect CommunityEC
Effect Community2y ago
117 replies
Aaron

Managing Dependencies in Effect.gen Function

I'm trying to return an implementation of an interface as my service, like so:
const make = Effect.gen(function* () {
  return {
    evaluate: (payload: EvalPayload) =>
      Match.value(payload.config.model).pipe(
        Match.when(ModelVersion.AnthropicClaude320240229, () => anthropicEvaluate(payload)),
        Match.when(ModelVersion.OpenAIGPT4, () => openAIEvaluate(payload)),
        Match.exhaustive
      ),
  }
})


The problem is, those modelEvaluate functions each have their own dependencies, but those don't 'roll up' into the make Effect's dependencies. I can see why, I just need to understand the pattern to sorta merge all that up which doesn't require a little throw away layer here (thinking some sort of prosiac code will work)
Was this page helpful?