Generalize numeric types

This is aimed particularly at supporting DualNumbers