This PR is an implementation and subsequent generalization of the SHandle region construction from the paper 'Freer Monads, More Extensible Effects'.
It provides a function handleRegionRelay which can be used to implement regions which are capable of acquiring resources, and automatically releasing them at the end of its scope. The type system guarantees that these resources cannot escape their scope, and can also limit which effects are allowed to be available in the same scope (non-determinism, for example, would break the invariants provided by regions, so we can exclude them by this mechanism). Due to this closed world, handleRegionRelay can deal with short-circuiting interpreters by intercepting their requests before the short-circuiting one would.
This PR is an implementation and subsequent generalization of the
SHandle
region construction from the paper 'Freer Monads, More Extensible Effects'.It provides a function
handleRegionRelay
which can be used to implement regions which are capable of acquiring resources, and automatically releasing them at the end of its scope. The type system guarantees that these resources cannot escape their scope, and can also limit which effects are allowed to be available in the same scope (non-determinism, for example, would break the invariants provided by regions, so we can exclude them by this mechanism). Due to this closed world,handleRegionRelay
can deal with short-circuiting interpreters by intercepting their requests before the short-circuiting one would.I wish I had thought of most of this stuff :)