Coding 2023-09-10
It's late, but I want to see what I can do quickly to lay the groundwork for working on the effect system later.
The minimal effect system in terms of syntax is to simply have one way to define operations.
This is problematic for two related reasons, both deriving from the fact that I want expressive power on the level of Koka for this: Effects that strong use a continuation that can be called arbitrarily many times, which means that the straightforward implementation would have to basically use "heap frames" instead of stack frames, which would both make performance pretty bad in general, and complicate reasoning about behavior.
(Another issue with having such "simple" syntax is that it doesn't allow for specifying that a particular operation should be handled by a handler other than the nearest one.)
One possible course of action that occurs to me is to try to express this stuff in terms of modular implicits somehow. I'm not totally sure if that makes sense, but let's see...
Doing stuff with "normal" modular implicits means that you're relying on matching up an implicitly available module to the input types, and potentially that module could define functions with effects. One question I need to consider is whether it works to vary the effects in different versions of the module... I think that kind of thing at least needs to be considered with modules in general, so, just as a module can define a type, a module can also define an effect.
Okay, trying to get past that diversion, what matters is that a function that has an effect, is relying on its caller to provide a handler; that handler can be given various abilities to resume the computation. My quick read on what are possible amounts of resumption to allow is that the cases that are meaningfully distinct are "never, once, more than once". These can come together as:
- Resumption is never allowed.
- Resumption is allowed up to once.
- Resumption is allowed an arbitrary number of times.
- Resumption is allowed exactly once.
- Resumption is allowed once or more.
"It must be resumed more than once" doesn't sound sensible, so I'm going to put it aside for now.
One of the things I need to understand here is, what assumptions I need to relax when considering multiple resumption...
And I think I need to read over the Koka documentation again to understand what questions I should even be asking...
Anyway, that's all I have time for right now.
Good night.