jacobdweightman / allium

The Allium Programming Language
MIT License
2 stars 1 forks source link

Groundness Analysis for Handlers #13

Open jacobdweightman opened 2 years ago

jacobdweightman commented 2 years ago

This issue is related to the effects and handlers design document.

Handle effect handlers in groundness analysis.

I see two conceptually simple solutions to this — we probably want something in the middle.

  1. Effects should be transparent to groundness analysis. The analysis should look up each effect's handler and infer information as if the handler is a sub-proof.
  2. Effects should be opaque to groundness analysis. Effect constructor arguments have their groundness unchanged.

The first will complicate working with multiple compilation units in the future, because groundness information will be necessary for predicates and handlers defined in other libraries. This might eventually require storing the "groundness cache" in a file for libraries that do not make their source code available.

The second will probably be unwieldy for Allium programmers. Data which is retrieved by an effect will only be ground if it is subsequently unified with a ground value; this means, for example, data which is read from a file cannot immediately be printed as output. One long-term solution might be to add an out keyword which guarantees the argument value is ground afterwards.

Realistically, we probably want something between the two options for now: look up effect handlers within the compilation unit, and infer nothing from effects handled in other compilation units. We can always add that in later.