Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

When I see a new (for me) idea coming from (presumably) category theory I wonder if it really will land in any mainstream language. In my experience having cohesion on the philosophical level of the language is the reason why it is nice to work with it in a team of programmers who are adept in both programming and in the business context. A set of programming patterns to solve a problem usually can be replaced with a possibly disjunct set of patterns where both solutions have all the same ilities in the code and solve the business problem.

My question is - can a mainstream language adopt the algebraic effects (handlers?) without creating deep confusion or a new language should be built from the ground up building on top of these abstractions in some form.




> can a mainstream language adopt the algebraic effects (handlers?) without creating deep confusion or a new language should be built from the ground up building on top of these abstractions in some form.

Algebraic Effect is a variant/enhancement of dependency injection formalized into a language. Dependency injection has massive usage in the wild for a long time with just library implementation.


> Algebraic Effect is a variant/enhancement of dependency injection

Every library so far that has implemented effects e.g. Cats, ZIO, Effects has done so to make concurrency easier and safer.

Not for dependency injection.


A weak form of algebraic effects are already very common: React hooks.

React hooks are different from full-blown algebraic effects in a couple ways:

- The handler for the hooks are already implemented for you, and you can't swap it out for a different handler. For example, the implementation of useState is fixed, and you can't swap it out for a different implementation.

- They're not multishot resumption. When a hook is raised, the handler can only handle it and resume it once. In a full-blown algebraic effect, the handler can resume the same raised effect multiple times.

- Algebraic effects usually come bundled together. Those effects have specific compositional rules with each other. That's how they're algebraic.


React hooks are them, basically. Not at the language level, but widely adopted and understood.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: