Often, we encounter a situation where we need to access a resource that we need to close afterwards. This can be a file reference, a database session, a HTTP connection, or something else. The Cats effect has a dedicated primitive to allow you to work with such resources securely. In Java, there is a dedicated statement for handling resources, which is try-with-resources. Scala does not have a similar statement. However, the situation changes with the bracket method, which is defined on the IO primitive:
As it says in the documentation, the bracket primitive makes the underlying execution engine treat the result of this IO as a resource ...