<Self, S extends Spec, R>(
_tag: HyperlinkTag<Self, S>,
impl: WithRequirement<ImplOf<S>, R>,
workerContext: Context.Context<R>
): Driver<S, R>export const const driver: <Self, S extends Spec, R>(
_tag: HyperlinkTag<Self, S>,
impl: WithRequirement<ImplOf<S>, R>,
workerContext: Context.Context<R>
) => Driver<S, R>
driver = <function (type parameter) Self in <Self, S extends Spec, R>(_tag: HyperlinkTag<Self, S>, impl: WithRequirement<ImplOf<S>, R>, workerContext: Context.Context<R>): Driver<S, R>Self, function (type parameter) S in <Self, S extends Spec, R>(_tag: HyperlinkTag<Self, S>, impl: WithRequirement<ImplOf<S>, R>, workerContext: Context.Context<R>): Driver<S, R>S extends Spec, function (type parameter) R in <Self, S extends Spec, R>(_tag: HyperlinkTag<Self, S>, impl: WithRequirement<ImplOf<S>, R>, workerContext: Context.Context<R>): Driver<S, R>R>(
_tag: HyperlinkTag<Self, S>(parameter) _tag: {
description: string | undefined;
key: Identifier;
of: (this: void, self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends DefaultMethod<infer F> ? F : S[K] extends …;
context: (self: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends DefaultMethod<infer F> ? F : S[K] extends { readonly _…;
use: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends DefaultMethod<infer F> ? F : S[K] extends { rea…;
useSync: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<T, never, Self> : S[K] extends DefaultMethod<infer F> ? F : S[K] extends { rea…;
Identifier: Identifier;
Service: Shape;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
_tag: interface HyperlinkTag<Self, S extends Spec, Svc = Simplify<{ readonly [K in keyof S]: S[K] extends FromLocalMethod<infer M> ? InjectLocal<M, Self> : S[K] extends LocalMethod<infer T> ? LocalEffect<...> : S[K] extends DefaultMethod<...> ? F : S[K] extends { ...; } ? SuccessOf<...> : S[K] extends { ...; } ? Subscribable<...> : S[K] extends { ...; } ? ClientMethod<...> : S[K] extends Spec ? Simplify<...> : never; }>>The type of a HyperService tag carrying spec S — what
Hyperlink.Tag
produces
(and what you extend). Lets a consumer write
<S extends Spec>(tag: HyperlinkTag<Self, S>) and read the spec through named types
(
specOf
/
groupOf
) instead of a Parameters<typeof specOf> workaround.
HyperlinkTag<function (type parameter) Self in <Self, S extends Spec, R>(_tag: HyperlinkTag<Self, S>, impl: WithRequirement<ImplOf<S>, R>, workerContext: Context.Context<R>): Driver<S, R>Self, function (type parameter) S in <Self, S extends Spec, R>(_tag: HyperlinkTag<Self, S>, impl: WithRequirement<ImplOf<S>, R>, workerContext: Context.Context<R>): Driver<S, R>S>,
impl: WithRequirement<ImplOf<S>, R>impl: type WithRequirement<T, Req> = T extends Subscribable<infer A> ? Subscribable<A> : T extends Stream.Stream<infer A, infer E, infer R> ? Stream.Stream<A, E, R> : T extends (...args: infer Args) => Effect.Effect<infer S, infer E, infer R> ? (...args: Args) => Effect.Effect<S, E, R | Req> : T extends Effect.Effect<infer S, infer E, infer R> ? Effect.Effect<S, E, Req | R> : T extends (...args: ReadonlyArray<never>) => unknown ? T : T extends object ? { readonly [K in keyof T]: WithRequirement<...>; } : TAdd Req to the requirement channel of every Effect method in an impl shape — the inverse of
ProvidedContext
, and a parameterized cousin of Store.AddStorageReq. Use it to annotate a
pre-provide impl (each worker method still carrying its requirement Req) so every method's
destructured params still get their contextual types from the spec, before
provideContext
strips Req back off to yield the
ImplOf
shape. A method (...a) => Effect<S, E, R> →
(...a) => Effect<S, E, R | Req>; a bare Effect<S, E, R> → Effect<S, E, R | Req>; a
Subscribable
/
Stream
member passes through untouched; a nested group recurses.
WithRequirement<type ImplOf<S extends Spec> = {
readonly [K in keyof S as S[K] extends AnyDefaultMethod
? never
: K]: S[K] extends FromLocalMethod<infer M>
? M
: S[K] extends LocalMethod<infer T>
? T
: S[K] extends {
readonly _tag: "ref"
}
? Subscribable<SuccessOf<AsMethod<S[K]>>>
: S[K] extends {
readonly kind: MethodKind
}
? ServiceMethod<AsMethod<S[K]>>
: S[K] extends Spec
? ImplOf<S[K]>
: never
}
The implementation a
localLayer
/
serve
expects: wire members are their
Effect/Stream/function, and each
LocalMethod
is its raw value T (the toolkit wraps
it to require the
Local
). When an impl needs a capability (e.g.
peers
) to
build, provide it via the Effect form of
Hyperlink.layer
/
Hyperlink.serve
— resolve it once, and the members close over it.
A
value
field's impl is the Effect<A, E> resolved once at acquire — that differs from how
it surfaces in
ServiceOf
(a plain A), so annotate an impl with ImplOf, not
ServiceOf. A
ref
's impl is the
Subscribable
(not the consumer shape alone).
default
members are Tag-baked — omitted from the impl. A nested group that is only
default members still appears as {} (pass an empty object). Piped
defaults
keys may
be overridden via
ImplWithDefaultOverrides
.
ImplOf<function (type parameter) S in <Self, S extends Spec, R>(_tag: HyperlinkTag<Self, S>, impl: WithRequirement<ImplOf<S>, R>, workerContext: Context.Context<R>): Driver<S, R>S>, function (type parameter) R in <Self, S extends Spec, R>(_tag: HyperlinkTag<Self, S>, impl: WithRequirement<ImplOf<S>, R>, workerContext: Context.Context<R>): Driver<S, R>R>,
workerContext: Context.Context<R>(parameter) workerContext: {
mapUnsafe: ReadonlyMap<string, any>;
mutable: boolean;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
workerContext: import ContextContext.interface Context<in Services>Immutable collection of service implementations used for dependency
injection in Effect programs.
Details
The type parameter tracks the service identifiers available in the context.
At runtime, services are stored by each key's string key.
Example (Creating a context with multiple services)
import { Context } from "effect"
// Create a context with multiple services
const Logger = Context.Service<{ log: (msg: string) => void }>("Logger")
const Database = Context.Service<{ query: (sql: string) => string }>(
"Database"
)
const context = Context.make(Logger, {
log: (msg: string) => console.log(msg)
})
.pipe(Context.add(Database, { query: (sql) => `Result: ${sql}` }))
Context<function (type parameter) R in <Self, S extends Spec, R>(_tag: HyperlinkTag<Self, S>, impl: WithRequirement<ImplOf<S>, R>, workerContext: Context.Context<R>): Driver<S, R>R>,
): interface Driver<S extends Spec, R>A HyperService impl before worker-context discharge — the impl still carries requirement R on its
Effect methods, paired with the
Context.Context
captured at build time. Used by
WorkPool
,
Gate
, and
Daemon
(any toolkit HyperService that builds
its driver under ambient R).
layer
/
serve
grant locally via
grantLocal
;
serveRemote
defers discharge to each wire call via
invokeWireMethodWithContext
so
one materialization backs both paths.
Driver<function (type parameter) S in <Self, S extends Spec, R>(_tag: HyperlinkTag<Self, S>, impl: WithRequirement<ImplOf<S>, R>, workerContext: Context.Context<R>): Driver<S, R>S, function (type parameter) R in <Self, S extends Spec, R>(_tag: HyperlinkTag<Self, S>, impl: WithRequirement<ImplOf<S>, R>, workerContext: Context.Context<R>): Driver<S, R>R> => ({
[const driverSym: typeof driverSymRuntime marker for a
Driver
bundle.
driverSym]: true as type const = trueconst,
Driver<S, R>.impl: WithRequirement<ImplOf<S>, R>impl,
Driver<S, R>.workerContext: Context.Context<R>(property) Driver<S, R>.workerContext: {
mapUnsafe: ReadonlyMap<string, any>;
mutable: boolean;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
workerContext,
});