Creating a generic `Context.Tag` in the Effect Typescript library can indeed be a bit challenging...

Is it possible to create a generic Context.Tag? I'm making an ORM where developers can define tables and relations, so obviously we need to be able to have a generic, but I'm just struggling to figure out how to make generic Layer:s etc.

Here's my code for making the ORM object:

export const makeORM = <
  Tables extends Record<string, TableDefinitionAny>,
  Relations extends Array<RelationDefinitionAny>,
>({ tables, relations }: { tables: Tables; relations: Relations }) => Effect.gen(function*() {
  const sql = yield* SqlClient.SqlClient
  // ... etc ...
})


Now it just hurts my soul to have this code like this, so help is much appreciated!!
Was this page helpful?