TS Typeclasses

Implement typeclasses and their instances in TypeScript — Functor, Applicative, Monad, Traversable, Foldable — and the higher-kinded type (HKT) encoding they require. Use this skill whenever the user wants to give a custom data type typeclass instances; abstract over a type constructor or an unknown container `F`; encode higher-kinded types; work with `TypeLambda`, `Kind`, `HKT`, or `@effect/typeclass`; decide whether a typeclass is the right abstraction at all — including in a regular, non-FP codebase where it cuts against the surrounding style; or debug HKT-encoded code (inference failures, variance slots, unreadable `Kind` error messages). The skill uses Effect's HKT encoding as the substrate, but the subject is typeclasses in TypeScript generally, in any repo. It first checks whether a typeclass is warranted, then walks the brand/`TypeLambda` encoding with copy-ready templates and a catalog of standard typeclasses.

synapseradio 0ef0ecc 8 files · 55.6 KB Updated

File contents

synapseradio/ai-skills/tree/main/skills/tech/ts-typeclasses commit 0ef0ecc661

Frequently asked questions

npx skillmds@latest add synapseradio/ts-typeclasses