Singleton, Union and Intersection Types for Program Extraction