TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: JavaScript Proposal – Algebraic Effects?

7 pointsby macabeusover 5 years ago
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 comments

haecceityover 5 years ago
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 未加载
pickdenisover 5 years ago
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 未加载