Generalize type conversion