Hacker News new | ask | show | jobs
by yen223 2230 days ago
Algebraic effects is very interesting to me.

A try...catch block allows one to define how an exception is handled within a given block. You can take the same function, and wrap it in a different try...catch block, and have the exception handled in a different manner.

Algebraic effects would allow one to define how a side effect (e.g. database queries, logging, etc) is performed within a given block. You can take the same function, wrap it in a different block, and have its side effects handled differently. You could have Logging effects write out to stdout in tests, and write to Splunk in production code, for example.

This would give a nice language-level, type-safe construct for implementing dependency injection, without the usual kludges of traditional DI frameworks.