# 用 Continuations 统一异步与错误处理

Original title: Abstracting Effects with Continuations

> Hacker News story 48932722 · language: zh · submitted 2026-07-16
> Web version: https://zeli.app/zh/story/48932722
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 73 · by [crowdhailer](<https://news.ycombinator.com/user?id=crowdhailer>) · 💬 6
[original](<https://crowdhailer.me/2026-07-15/abstracting-effects-with-continuations/>) · [HN discussion](<https://news.ycombinator.com/item?id=48932722>)

## Summary

在 Gleam 中，我们常为同步、异步或可能失败的场景重复编写相似的业务逻辑。本文展示了如何利用 Continuations 将业务逻辑与计算效果彻底解耦。通过定义一个通用的 task 函数，我们可以让 fetch 操作灵活适配 Result、Promise 或混合场景，而无需修改核心代码。这种模式不仅减少了代码重复，还让 Runner 能够自由决定如何处理数据获取的细节。无论是构建可靠的后端服务还是处理复杂的异步流，Continuations 都能提供强大的抽象能力，让代码更简洁、更易于维护。

## Key quote

> 使用 Continuation 意味着：'我完全不知道你将如何获取值，但当你拿到它时，接下来该做什么我已经告诉你了。'

---

## Cite

- Page: https://zeli.app/zh/story/48932722
- Date: 2026-07-16
- Source: crowdhailer.me (https://crowdhailer.me/2026-07-15/abstracting-effects-with-continuations/)
- Hacker News: https://news.ycombinator.com/item?id=48932722

## Other languages

- en: https://zeli.app/story/48932722 · markdown: https://zeli.app/story/48932722.md
- ja: https://zeli.app/ja/story/48932722 · markdown: https://zeli.app/ja/story/48932722.md
- ko: https://zeli.app/ko/story/48932722 · markdown: https://zeli.app/ko/story/48932722.md
- de: https://zeli.app/de/story/48932722 · markdown: https://zeli.app/de/story/48932722.md
- es: https://zeli.app/es/story/48932722 · markdown: https://zeli.app/es/story/48932722.md
