I like that with
-style function that controls the library’s init/shutdown lifecycle, especially since you can make it exception-safe. You can also do a runST
-style trick to ensure that library-provided resources cannot escape the with
.
Here’s a recent post about that sort of thing: Bluefin prevents handles leaking - #5 by MangoIV