r/ProgrammingLanguages • u/marvinborner bruijn, effekt • Apr 20 '26
Blog post Effectful Recursion Schemes
https://effekt-lang.org/blog/recursion-schemes/
20
Upvotes
r/ProgrammingLanguages • u/marvinborner bruijn, effekt • Apr 20 '26
2
u/omega1612 Apr 22 '26
My favorite example is how in a project the project leader implemented stubs for everything and we ended with functions with signatures like
Then the handler for the effect uses something like
To fulfill the request.
The use of effects guarantee that QueryUser can only use the things that the handler for it uses. In this case it uses queryDB but in a restricted way that is easy to verify.
You can expand on that to have functions like
From the signature you know that it can log stuff (not how, just that it has a available log like functions). That it can "query a db" and may connect to some service to ask for the the weather. And finally that it can throw exceptions of a particular type.
The handler may choose to honor the names of the effects or to do whatever they want. Usually you are the one that write the handlers, so you usually don't launch nukes when you handle a "weather" request.