Closure-based type erasure