MCPcopy Create free account
hub / github.com/effect-app/libs / MergedContextProvider

Function MergedContextProvider

packages/infra/src/ContextProvider.ts:137–163  ·  view source on GitHub ↗
(
  // long life to reverse mapped types
  ...deps: TDepsArr<TDeps>
)

Source from the content-addressed store, hash-verified

135
136// Note: the type here must be aligned with mergeContextProviders
137export const MergedContextProvider = <
138 TDeps extends ReadonlyArray<any>
139>(
140 // long life to reverse mapped types
141 ...deps: TDepsArr<TDeps>
142) =>
143 pipe(
144 deps as [Parameters<typeof mergeContextProviders>[0]],
145 (_) => mergeContextProviders(..._),
146 (_) => ContextProvider(_ as any)
147 ) as unknown as ContextTagWithDefault<
148 ContextProviderId,
149 Effect.Effect<
150 // we need to merge all contexts into one
151 // v4: Service.Shape extracts the service value type (v3's Tag.Identifier)
152 Context.Context<GetContext<EffectGenUtils.Success<Context.Service.Shape<TDeps[number]>>>>,
153 never,
154 EffectGenUtils.Context<Context.Service.Shape<TDeps[number]>>
155 >,
156 LayerUtils.GetLayersError<{ [K in keyof TDeps]: TDeps[K]["Default"] }>,
157 // v4: Identifier here is correct — it's the nominal service identity for layer provide/exclude
158 | Exclude<
159 Context.Service.Identifier<TDeps[number]>,
160 LayerUtils.GetLayersSuccess<{ [K in keyof TDeps]: TDeps[K]["Default"] }>
161 >
162 | LayerUtils.GetLayersContext<{ [K in keyof TDeps]: TDeps[K]["Default"] }>
163 >
164
165export const EmptyContextProvider = ContextProvider({ effect: Effect.succeed(Effect.succeed(Context.empty())) })

Callers 1

Calls 3

mergeContextProvidersFunction · 0.85
ContextProviderFunction · 0.85
pipeFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…