1import * as Context from "effect/Context";
2
3export const GenericService =
4 <
5 Fn extends (T: { Type: string }) => Context.Service<any, any> = (
6 ...args: any[]
7 ) => Context.Service<any, any>,
8 >() =>
9 <Kind extends string>(Kind: Kind): ReturnType<Fn> & Fn => {
10 const service = Context.Service<any, any>(Kind);
11 const make = (Type: string) => Context.Service(`${Kind}<${Type}>`);
12 return Object.assign(
13 Object.setPrototypeOf(make, service),
14 service,
15 ) as ReturnType<Fn> & Fn;
16 };