A Rich Type System for Quantum Programs