ts-typeclasses
TypeScript Typeclasses
This skill builds typeclass abstractions in TypeScript on Effect's higher-kinded
type encoding. A typeclass — Functor, Monad, Traversable — is an interface
abstracted over a type constructor (Array, Option, a custom Tree), not
over a plain type. TypeScript cannot quantify over type constructors directly,
so the abstraction is recovered through an encoding: a brand (Effect calls it
a TypeLambda) names the constructor, and Kind applies it. The background and
the theory live in references/hkt-encoding.md; this file is the workflow.
The work splits into four steps, preceded by a gate. Do not skip the gate — most requests for "HKTs" do not actually need them, and the encoding has a real cost.
Step 0 — Gate: are HKTs needed at all?
The encoding is a powerful tool with a standing cost: every call site that
routes through Kind pays an inference-annotation tax and surfaces dense error
messages (see references/troubleshooting.md). Adopt it only when it earns its
place.