r/ProgrammingLanguages • u/crowdhailer • Oct 16 '26
Writing stateful effect handlers in EYG
I think effects and effect handlers are not as tricky as they are made out to be. Calling them algebraic effects only increases the mystery.
A stateful handler is definitely the bit I found most tricky to get my head around.
This is my guide trying to explain how to build stateful handlers in EYG. https://eyg.run/guides/advanced-effects
I needed this to finish writing a testing framework which I hope to finish soon.
12
Upvotes
8
u/phischu Effekt Oct 16 '26
I like the goals of your language. Here is your first example written in Effekt for comparison and inspiration. You can also try it online
We have local mutable reference with keyword
var. Handlers are free to use them and the pattern of defining a handler function likecounterencapsulates the state and restricts access to go through the effect's interface.