Removed ResourceT transformer / integrated into IO #1326
louthy
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This release removes the
ResourceT<M, A>monad-transformer from language-ext and instead moves the functionality into theIO<A>monad.ResourceTrequiredIOto be in the transformer stack and so it really was adding complexity to a feature that's closely linked. This adds a tiny overhead to theIOmonad -- the IO monad already carried an environment through its computations, so this doesn't change much -- in the big scheme of things it's likely to bring performance benefits.Some big improvements because of this:
useandreleaseare now available in thePrelude, which makes them easier to work with (no need for any manual generic arguments), everything is inferable from usage.IOcomputation (launching it on a new thread) automatically creates a local resource environment for the fork and cleans it up when the forked operation is complete.IOcomputation (repeat(computation)) - will automatically clean up any resources acquired byusein the computation (on each iteration).IOcomputation (retry(computation)) - will automatically clean up any resources (acquired withuse) when the computation fails, that mean retries don't accumulate resources unnecessarily.local(computation)works as a 'superusing' -- in that it will automatically clean up any resources acquired withusein the computation. This allows you to create local scopes where you just freely acquire resources and then have a clean-up happen automatically.IO.localfor local cancellation contexts andReader.localfor local environments. I'm also open to changing the names of the others. Ideally any name would be a single word so it's easy on the eye. So, nothing likelocalResourceorcleanUp.bracket(Acq, Use, Err, Fin)andbracket(Acq, Use, Fin)- these are liketry\catch\finallyblocks for more explicit resource usage:Acq- acquires the resourceUse- uses the resourceErr- is the catch blockFin- is the finally blockAll the usual caveats apply: this is an alpha, this isn't fully tested, use at your own risk.
This discussion was created from the release Removed ResourceT transformer / integrated into IO.
Beta Was this translation helpful? Give feedback.
All reactions