cats-effect-io
Installation
SKILL.md
Cats Effect IO (Scala)
Quick start
- Treat every side effect and source of non-determinism as an effect value: return
IO[A],SyncIO[A], orF[A]with the smallest needed Cats Effect capability. - Suspend each side-effectful call, not a precomputed result.
Instant.now(), random/UUID generation, environment reads, and mutable allocation such asnew Array[...]belong insideIO(...),Sync[F].delay,Clock,Random, or an effectful factory. - Initialize shared mutable state through
IO/F/Resourcefactories and pass the resulting reference or service around. Do not hide effects in constructors, top-level vals, or default arguments. - Wrap Java blocking use-phase calls with
IO.interruptibleby default (orSync[F].interruptible); useblockingfor acquisition, finalizers, and operations that must not be interrupted. - Use
Resourceto acquire/release resources andIOAppfor program entry points. - Prefer structured concurrency (
parTraverse,parMapN,background,Supervisor) over manual fiber management. - Do not use
unsafeRun*(unsafeRunSync,unsafeRunAndForget, etc.) in app code or tests; for interop with non-Cats-Effect callback APIs, useDispatcher. - Read
references/cats-effect-io.mdfor concepts, recipes, FAQ guidance, and verified samples. - For deeper
Resourceguidance, use thecats-effect-resourceskill (install:npx skills add https://github.com/alexandru/skills --skill cats-effect-resource).