Effect CommunityEC
Effect Community3y ago
120 replies
sign error

Tagging a Generic Service

Hey There … One Question about »generic Dependencies« … In the I can find that example for non genric service:

interface Random {
  readonly next: () => Effect.Effect<never, never, number>
}
 
const Random = Context.Tag<Random>()

But what if I have a service like that:

interface Random<A> {
  readonly next: () => Effect.Effect<never, never, A>
}

So a random service that can produce strings, number, whatever. How could I Tag that?

const Random = Conext.Tag<Random<unknown>>();

kind of does it, but is there any better way?
Was this page helpful?