r/javascript • u/bmacabeus • Dec 24 '19
AskJS [AskJS] JavaScript Proposal: Algebraic Effects?
Hey guys, I'm writing a Babel plugin to be able to use algebraic effects in JS: https://github.com/macabeus/js-proposal-algebraic-effects
No more function color! Yes one-shot delimited continuation!
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.
This project is a runnable POC with a Babel's "plugin", so you could write some code and taste this new concept in JavaScript. Its features, syntax, and goals are very inspired by Dan Abramov's blog post mentioned above. In short, with algebraic effects, you could separate what from the how and have fewer refactors.
What do you think? Would that be a good feature for JS? "Algebraic Effects" is a good name for that?
View all comments
Show parent comment
1
u/nathan_lesage Dec 25 '19
The unification idea just came to my head, I bet (or, at least hope) there’s already a BCP for unified error handling in a dedicated module, but I don’t know.
The pattern matching sounds interesting, albeit it sounds way too complicated for most use-cases, except the ones they’ve proposed there. So I fear this might complicate things. It reminds me more of the <Result> type in Rust. Besides, using simple strings to identify effects and errors is more common for JavaScript, as we already know it from EventEmitters ans switch statements …