What exactly are dynamic effects? What does it mean to dynamically create an effect?

In a language with algebraic effects and handlers (such as Eff or Koka) one could already do different operations based on runtime information, for example: if x > 10 then get () else put 10 In this case the actual operation done will only be known at runtime. But in the Frank paper ("Do be do be do") they talk about dynamic effects in the sense of ML-style references. In what sense are references a dynamic effect that cannot be done in Eff (without resources) or Koka? Also why were resources removed again from Eff?

  • $\begingroup$ You will have to be a bit more specific. What sources did you look at that speak about "dynamic" and "generative" effects? This could mean several things. Generative with respect to the types of return values? Dynamic as in "created at runtime"? $\endgroup$ – Andrej Bauer Nov 17 '17 at 15:54
  • $\begingroup$ I updated the question a bit, but I guess it's still not specific enough. I am just unclear what is meant in the Frank paper when they talk about Dynamic effects and I couldn't really find any other paper on it, except for the "Eff directly in OCaml" report. $\endgroup$ – Labbekak Nov 17 '17 at 19:05
  • $\begingroup$ Ok, I think you're talking about resources. It's not clear to me what your question is? You are using the phrase "dynamic effects" which I find to be unclear. I will ask again: where did you get this phrase from? What paper specifically? Then I can have a look to see what you're talking about. If you invented the phrase, then you'll have to explain it. As far as I can tell, you're talking about Eff's instances (not resources). The example you put in your question looks like this question is not research-level. $\endgroup$ – Andrej Bauer Nov 17 '17 at 20:59
  • $\begingroup$ I got the phrase "dynamic effects" from the "Frank" paper (Future work section) and from the "Eff directly in OCaml" (Higher-order effects). I have to think some more before I can formulate a good question. I agree that it's likely not research-level so I will have to post it somewhere else. Sorry to waste your time. $\endgroup$ – Labbekak Nov 17 '17 at 21:41
  • $\begingroup$ Ok, thank you, you're talking about instances in Eff terminology. $\endgroup$ – Andrej Bauer Nov 18 '17 at 10:05

Let us take the example, the input/output effect. Ordinarily, one presents this with two algebraic operations print and read. We can then imagine that things get "printed out" and "read in" from some sort of a communication channel. In fact, that's how I/O works in a typical operating system.

Except that in a typical operating system one can open lots of communication channels: open files, bind to internet sockets, etc. Whenever a new channel opens, something new gets created dynamically (i.e., while the program is running). An operating system typically just creates a new integer, the "file handle", but that's just a cheap version of what we really want: an identifier that is guaranteed to be unique and that cannot be guessed by any part of the program, unless it was already given to it. (Integers can be guessed.) Let us call such a thing an instance. (In cryptography it is often called a nonce, but they cheat and think of it as an "unguessable integer". In programming languages we can make sure that instances are abstract tokens that really are unguessable.)

There are other examples where we need to create new instances. One is state, i.e., a memory location with operations update and lookup. Typical programs want to allocate any amount of memory locations, each of which is then an instance of the state effect. In general, instances allow us to create local effects, such as local exceptions and local references. In many applications it is essential to have such effects, for instance so that we can guarantee that only a certain part of the program is allowed to use a certain effect.

There is a tendency among the theoreticians to ignore effect instances because they complicate the theory. I feel that they should not be ignored because a programming language without dynamic creation of effects is next to useless. Who wants to write programs in which all memory allocations, files, and sockets, have to be specified ahead of time?

| cite | improve this answer | |
  • $\begingroup$ Thanks! So dynamic instances are key here. Surpising then that only Eff has them, they seem like such an important feature. I hope to start my Master thesis in a few months and I am looking to do something with algebraic effects. I think something to do with dynamic instances could be interesting. $\endgroup$ – Labbekak Nov 18 '17 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.