Skip to content

Questions: bracketIO + lifting ValueTask #1402

Answered by louthy
aloslider asked this question in Q&A
Discussion options

You must be logged in to vote

bracketIO with the Acq, Use, and Fin is a more explicit approach to managing resources. It doesn't use the built-in resource-management, so release won't do anything because Acq didn't put the resource into its tracking-map.

So, if you want to use that approach, the Fin part should be: IO.lift(() => res.Dispose()).

This is what it looks like internally:

new IOAsync<C>(async env =>
    {
        var x = await RunAsync(env);
        try
        {
            return IOResponse.Complete(await Use(x).RunAsync(env));
        }
        catch (Exception e)
        {
            return IOResponse.Complete(await Catch(e).RunAsync(env));
        }
        finally
        {
            (await Finally(x)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@aloslider
Comment options

@louthy
Comment options

Answer selected by aloslider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants