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.ResourceT
requiredIO
to 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 theIO
monad -- 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:
use
andrelease
are now available in thePrelude
, which makes them easier to work with (no need for any manual generic arguments), everything is inferable from usage.IO
computation (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.IO
computation (repeat(computation)
) - will automatically clean up any resources acquired byuse
in the computation (on each iteration).IO
computation (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 withuse
in the computation. This allows you to create local scopes where you just freely acquire resources and then have a clean-up happen automatically.IO.local
for local cancellation contexts andReader.local
for 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 likelocalResource
orcleanUp
.bracket(Acq, Use, Err, Fin)
andbracket(Acq, Use, Fin)
- these are liketry
\catch
\finally
blocks 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