A Functional Approach to Modality