Conversation

This has some good "nerd snipe" potential for programming language designers. In grad school, I was poking around possible solutions to this (though sadly didn't go far enough). A possible direction - modules could expose all of their implied imports to configurability.
Quote Tweet
I wrote my thoughts about writing a new type vs adding new functions to change behavior: saturating_add vs. saturating_int – new function vs. new type? foonathan.net/2022/03/behavi #cpp #cplusplus
2
7
I wonder whether you could do this through an effect system. You could have an 'overflow' effect that can be handled in a manner easily and cleanly chosen by the caller.
1
1
Oh, good idea! I guess in practice you'd need an effect system lightweight enough in terms of runtime overhead… which could be a tough ask at the moment? But could be fun to experiment with?
1
1
So this is something I've been thinking about with my effect system which in the process of being born (preliminary codegen & typing works). Right now, I implement it as stack-walking but one of my goals is to monomorphise *everything* (no runtime HKTs) a consequence of... (1/n)
1
...this is that generic effects (i.e: where generic parameters aren't specified in an effect type, such as async/await) codegen doesn't really compose and can only be done at a best-effort level. I am very unhappy with this, so I've been thinking of changing effect types to (2/n)
1
be more akin to impl Trait / existential types, thereby statically promising that monomorphisation (& also inlining) is possible. I need to do a lot more thinking about this though because I think it's going to have far-reaching consequences for effects in general. Any thoughts?
1
Hmm not sure. Pretty interested in what Effekt does with this stuff - I think they compile to a representation where handlers are injected as parameters?
2
Combining that with staging could be interesting. Not sure about runtime reps - it's something I'm interested in with dependent types. But yeah in general I'd hope that the common case for effects is pretty static.
1