Skip to content

I would like to inquire about the proper usage of Disposable and DisposableAsync #1366

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

You must be logged in to vote

The only disposable 'thing' in the IO monad is the EnvIO. If you pass your own EnvIO to Run or RunAsync then you are expected to dispose it. If you don't pass an EnvIO to Run or RunAsync, then one will be generated for you and it will be disposed automatically.

For Eff, the same is true for the EnvIO. The RT runtime is entirely your responsibility, because you pass it to Run, it's up to you to dispose it.

So, for your functions:

  • Case2() is correct and all resources will be cleaned-up automatically.
  • Case3() is wrong, you need to clean-up the EnvIO that you pass to RunAsync
  • Case4() is correct and all resources will be cleaned-up automatically.
  • Case5() is only correct if your Runtime has no…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by seungyongshim
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