<Self, S extends Spec, R>(
_tag: HyperlinkTag<Self, S>,
impl: WithRequirement<ImplOf<S>, R>,
workerContext: Context.Context<R>
): BuiltHyperlink<S, R>Pair a pre-provide impl with the worker context captured at build time. Pass tag so the concrete
Spec S is pinned for BuiltHyperlink typing.
export const const builtHyperlink: <
Self,
S extends Spec,
R
>(
_tag: HyperlinkTag<Self, S>,
impl: WithRequirement<ImplOf<S>, R>,
workerContext: Context.Context<R>
) => BuiltHyperlink<S, R>
Pair a pre-provide impl with the worker context captured at build time. Pass tag so the concrete
Spec
S is pinned for
BuiltHyperlink
typing.
builtHyperlink = <function (type parameter) Self in <Self, S extends Spec, R>(_tag: HyperlinkTag<Self, S>, impl: WithRequirement<ImplOf<S>, R>, workerContext: Context.Context<R>): BuiltHyperlink<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>): BuiltHyperlink<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>): BuiltHyperlink<S, R>R>(
_tag: HyperlinkTag<Self, S>(parameter) _tag: {
groupId: string;
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 { readonly _tag: 'constant'; } ? SuccessOf…;
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 { readonly _tag: 'constant'; } ? SuccessOf<AsMethod<S[…;
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 { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
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 { readonly _tag: 'constant'; } ? SuccessOf<AsMe…;
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 { ...; } ? SuccessOf<...> : S[K] extends { ...; } ? Subscribable<...> : S[K] extends { ...; } ? ClientMethod<...> : S[K] extends Spec ? Simplify<...> : never; }>>The type of a resource tag carrying spec S — what
Hyperlink.Tag
/ a
Hyperlink.tagFor
factory produce (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>): BuiltHyperlink<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>): BuiltHyperlink<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]: 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 Stream that feeds it (typically a SubscriptionRef's .changes),
and a constant's is the Effect<A> resolved once — both differ from how they surface in
ServiceOf
(a plain A), so annotate an impl with ImplOf, not ServiceOf.
ImplOf<function (type parameter) S in <Self, S extends Spec, R>(_tag: HyperlinkTag<Self, S>, impl: WithRequirement<ImplOf<S>, R>, workerContext: Context.Context<R>): BuiltHyperlink<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>): BuiltHyperlink<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>): BuiltHyperlink<S, R>R>,
): interface BuiltHyperlink<S extends Spec, R>A resource 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
QueueHyperlink
,
RunHyperlink
, and
Process
(any toolkit resource 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.
BuiltHyperlink<function (type parameter) S in <Self, S extends Spec, R>(_tag: HyperlinkTag<Self, S>, impl: WithRequirement<ImplOf<S>, R>, workerContext: Context.Context<R>): BuiltHyperlink<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>): BuiltHyperlink<S, R>R> => ({
[const builtHyperlinkSym: typeof builtHyperlinkSymRuntime marker for a
BuiltHyperlink
bundle.
builtHyperlinkSym]: true as type const = trueconst,
BuiltHyperlink<S, R>.impl: WithRequirement<ImplOf<S>, R>impl,
BuiltHyperlink<S, R>.workerContext: Context.Context<R>(property) BuiltHyperlink<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,
});