Loading...
Loading...
Implement, debug, refactor, migrate, review, or explain Effect TypeScript code. Use when a task touches `effect` or `@effect/*` APIs, especially services, layers, schemas, runtime wiring, platform or CLI packages, Effect testing, or Promise-to-Effect migration.
npx skill4agent add uinaf/skills effect-tspackage.jsontsconfig*effect@effect/*effect-solutionseffect-solutions listeffect-solutions show <topic>...effect-solutions show project-setup tsconfigeffect-solutions show basics services-and-layers data-modeling error-handling config testingeffect-solutions show http-clients cli use-patterneffect.website/docsEffect.genEffect.fn("Name")Effect.run*Schema@effect/vitestconst loadUser = Effect.fn("loadUser")(function* (id: UserId) {
const repo = yield* UserRepo
return yield* repo.get(id)
})
const program = Effect.gen(function* () {
const input = yield* Schema.decodeUnknown(UserInput)(payload)
return yield* loadUser(input.id)
})effect-solutionseffect.websiteclass UserRepo extends Context.Tag("UserRepo")<
UserRepo,
{ readonly get: (id: UserId) => Effect.Effect<User, UserNotFound> }
>() {}
const UserRepoLive = Layer.succeed(UserRepo, {
get: (id) => Effect.gen(function* () {
const sql = yield* SqlClient.SqlClient
const rows = yield* sql`SELECT * FROM users WHERE id = ${id}`
if (rows.length === 0) return yield* new UserNotFound({ id })
return rows[0] as User
}),
})PromiseEffect.runPromise