TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: JavaScript Proposal – Algebraic Effects?

7 点作者 macabeus超过 5 年前
Hey guys, I&#x27;m writing a Babel plugin to be able to use algebraic effects in JS https:&#x2F;&#x2F;github.com&#x2F;macabeus&#x2F;js-proposal-algebraic-effects<p>No more function color! Yes one-shot delimited continuation!<p>What the hell?! Well... I really recommend that you read this blog post by Dan Abramov explaining algebraic effects - and how it could be very useful on our JavaScript code: https:&#x2F;&#x2F;overreacted.io&#x2F;algebraic-effects-for-the-rest-of-us&#x2F;<p>This project is a runnable POC with a Babel&#x27;s &quot;plugin&quot;, so you could write some code and taste this new concept in JavaScript. Its features, syntax, and goals are very inspired by Dan Abramov&#x27;s blog post mentioned above. In short, with algebraic effects, you could separate what from the how and have fewer refactors.<p>What do you think? Would that be a good feature for JS?

2 条评论

haecceity超过 5 年前
So instead of requiring the callee to be async or not you have to make sure your caller is executing in the right effect handler context? Sounds like we replaced the coloring problem with another one? I can see how it benefits the language designer because you could implement try catch and async with this but how does it benefit the user?
评论 #21870738 未加载
pickdenis超过 5 年前
Since JS lacks a static type system, isn&#x27;t it a bit misleading to call these &quot;algebraic&quot; effects, when algebraic is referring to the type system? I&#x27;m still not clear where the &quot;algebraic&quot; part comes in here.
评论 #21879918 未加载
评论 #21870810 未加载