We've started to think about alternative evaluation strategies (e.g. #594) that take advantage of sharing in terms to avoid redundant work. As part of this work, we should clarify and document the semantics of effectful programs.
We should respect the following equation:
handler(i)(evaluate)(p()) == handler(i)(p)() # delaying evaluation preserves semantics
Consider a program with two effects f and g:
def p():
x = f()
y = g(x, x)
return y
Our current implementation of evaluate respects this equation only when i is pure, because f is handled twice on the LHS and once on the RHS.
We've started to think about alternative evaluation strategies (e.g. #594) that take advantage of sharing in terms to avoid redundant work. As part of this work, we should clarify and document the semantics of effectful programs.
We should respect the following equation:
Consider a program with two effects
fandg:Our current implementation of
evaluaterespects this equation only wheniis pure, becausefis handled twice on the LHS and once on the RHS.