<Self, S extends Spec>(
tag: HyperlinkTag<Self, S>,
impl: ImplOf<S>
): ImplOf<S>
<Self, S extends Spec, R>(
tag: HyperlinkTag<Self, S>,
impl: Effect.Effect<ImplOf<S>, never, R>
): Effect.Effect<ImplOf<S>, never, R>Anchor a reusable impl to its contract at the definition site. Inline impls are already typed by
layer / serve; but the moment you hoist one to a const (to share it across the
local layer and a served entry, or across several serves) it loses that typing — the mistake then
surfaces far away at the serve call, with no autocomplete as you write it. Hyperlink.make(tag, impl)
infers the tag's spec and constrains impl to its ImplOf, returning it typed. Runtime identity.
const scoresImpl = Hyperlink.make(ScoresDb, { read: … }); // typed here — autocomplete + errors at the def
Hyperlink.layer(ScoresDb, scoresImpl); // local
Node.httpServer([Hyperlink.serve(ScoresDb, scoresImpl)]); // served — same impl, both typedexport function function make<Self, S extends Spec>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S>): ImplOf<S> (+1 overload)Anchor a reusable impl to its contract at the definition site. Inline impls are already typed by
layer / serve; but the moment you hoist one to a const (to share it across the
local layer and a served entry, or across several serves) it loses that typing — the mistake then
surfaces far away at the serve call, with no autocomplete as you write it. Hyperlink.make(tag, impl)
infers the tag's spec and constrains impl to its
ImplOf
, returning it typed. Runtime identity.
const scoresImpl = Hyperlink.make(ScoresDb, { read: … }); // typed here — autocomplete + errors at the def
Hyperlink.layer(ScoresDb, scoresImpl); // local
Node.httpServer([Hyperlink.serve(ScoresDb, scoresImpl)]); // served — same impl, both typed
make<function (type parameter) Self in make<Self, S extends Spec>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S>): ImplOf<S>Self, function (type parameter) S in make<Self, S extends Spec>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S>): ImplOf<S>S extends Spec>(
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 make<Self, S extends Spec>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S>): ImplOf<S>Self, function (type parameter) S in make<Self, S extends Spec>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S>): ImplOf<S>S>,
impl: ImplOf<S>impl: 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 make<Self, S extends Spec>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S>): ImplOf<S>S>,
): 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 make<Self, S extends Spec>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S>): ImplOf<S>S>;
export function function make<Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, impl: Effect.Effect<ImplOf<S>, never, R>): Effect.Effect<ImplOf<S>, never, R> (+1 overload)Anchor a reusable impl to its contract at the definition site. Inline impls are already typed by
layer / serve; but the moment you hoist one to a const (to share it across the
local layer and a served entry, or across several serves) it loses that typing — the mistake then
surfaces far away at the serve call, with no autocomplete as you write it. Hyperlink.make(tag, impl)
infers the tag's spec and constrains impl to its
ImplOf
, returning it typed. Runtime identity.
const scoresImpl = Hyperlink.make(ScoresDb, { read: … }); // typed here — autocomplete + errors at the def
Hyperlink.layer(ScoresDb, scoresImpl); // local
Node.httpServer([Hyperlink.serve(ScoresDb, scoresImpl)]); // served — same impl, both typed
make<function (type parameter) Self in make<Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, impl: Effect.Effect<ImplOf<S>, never, R>): Effect.Effect<ImplOf<S>, never, R>Self, function (type parameter) S in make<Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, impl: Effect.Effect<ImplOf<S>, never, R>): Effect.Effect<ImplOf<S>, never, R>S extends Spec, function (type parameter) R in make<Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, impl: Effect.Effect<ImplOf<S>, never, R>): Effect.Effect<ImplOf<S>, never, 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 make<Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, impl: Effect.Effect<ImplOf<S>, never, R>): Effect.Effect<ImplOf<S>, never, R>Self, function (type parameter) S in make<Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, impl: Effect.Effect<ImplOf<S>, never, R>): Effect.Effect<ImplOf<S>, never, R>S>,
impl: Effect.Effect<ImplOf<S>, never, R>(parameter) impl: {
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;
}
impl: import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<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 make<Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, impl: Effect.Effect<ImplOf<S>, never, R>): Effect.Effect<ImplOf<S>, never, R>S>, never, function (type parameter) R in make<Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, impl: Effect.Effect<ImplOf<S>, never, R>): Effect.Effect<ImplOf<S>, never, R>R>,
): import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<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 make<Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, impl: Effect.Effect<ImplOf<S>, never, R>): Effect.Effect<ImplOf<S>, never, R>S>, never, function (type parameter) R in make<Self, S extends Spec, R>(tag: HyperlinkTag<Self, S>, impl: Effect.Effect<ImplOf<S>, never, R>): Effect.Effect<ImplOf<S>, never, R>R>;
export function function make<Self, S extends Spec>(tag: HyperlinkTag<Self, S>, impl: ImplOf<S>): ImplOf<S> (+1 overload)Anchor a reusable impl to its contract at the definition site. Inline impls are already typed by
layer / serve; but the moment you hoist one to a const (to share it across the
local layer and a served entry, or across several serves) it loses that typing — the mistake then
surfaces far away at the serve call, with no autocomplete as you write it. Hyperlink.make(tag, impl)
infers the tag's spec and constrains impl to its
ImplOf
, returning it typed. Runtime identity.
const scoresImpl = Hyperlink.make(ScoresDb, { read: … }); // typed here — autocomplete + errors at the def
Hyperlink.layer(ScoresDb, scoresImpl); // local
Node.httpServer([Hyperlink.serve(ScoresDb, scoresImpl)]); // served — same impl, both typed
make(_tag: unknown_tag: unknown, impl: unknownimpl: unknown): unknown {
return impl: unknownimpl;
}