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 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).
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 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).