Fixing Performance Leaks at the Type Level