IxpertaSolutions / freer-effects

An implementation of "Freer Monads, More Extensible Effects".
BSD 3-Clause "New" or "Revised" License
65 stars 12 forks source link

Typesafe Region effect for acquiring resources #40

Closed isovector closed 5 years ago

isovector commented 7 years ago

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