An experimental Racket library providing an abstraction for values associated with external resources that allows automatic resource pooling, per-thread virtual construction, and monadic composition.
(require disposable)
(define (connect!) (make-connection ...))
(define (disconnect! conn) (close-connection conn ...))
(define disposable-connection (disposable connect! disconnect!))
(with-disposable ([conn disposable-connection])
... use conn ...)
Available from the Racket package catalog. To install:
raco pkg install disposable