Skip to Content
Mastering Functional Programming
book

Mastering Functional Programming

by Anatolii Kmetiuk
August 2018
Intermediate to advanced
380 pages
10h 2m
English
Packt Publishing
Content preview from Mastering Functional Programming

Bracket

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Functional Programming

Learning Functional Programming

Jack Widman

Publisher Resources

ISBN: 9781788620796Supplemental Content