def bracket[A, T](ctor: () -> A, next: (a: A) -> T): T = val a = ctor(); try { return next(a) } finally { a.dispose() }