Open Access
- 23 January 2013
- journal article
- conference paper
- Published by Association for Computing Machinery (ACM) in ACM SIGPLAN Notices
- Vol. 48 (1) , 27-38
Abstract
Inductive datatypes provide mechanisms to define finite data such as finite lists and trees via constructors and allow programmers to analyze and manipulate finite data via pattern matching. In this paper, we develop a dual approach for working with infinite data structures such as streams. Infinite data inhabits coinductive datatypes which denote greatest fixpoints. Unlike finite data which is defined by constructors we define infinite data by observations. Dual to pattern matching, a tool for analyzing finite data, we develop the concept of copattern matching, which allows us to synthesize infinite data. This leads to a symmetric language design where pattern matching on finite and infinite data can be mixed. We present a core language for programming with infinite structures by observations together with its operational semantics based on (co)pattern matching and describe coverage of copatterns. Our language naturally supports both call-by-name and call-by-value interpretations and can be seamlessly integrated into existing languages like Haskell and ML. We prove type soundness for our language and sketch how copatterns open new directions for solving problems in the interaction of coinductive and dependent types.Keywords
This publication has 35 references indexed in Scilit:
- Focusing on pattern matchingACM SIGPLAN Notices, 2009
- On the unity of dualityAnnals of Pure and Applied Logic, 2008
- Type-based termination of recursive definitionsMathematical Structures in Computer Science, 2004
- Semantic typesACM SIGPLAN Notices, 2004
- Call-by-value is dual to call-by-nameACM SIGPLAN Notices, 2003
- The duality of computationACM SIGPLAN Notices, 2000
- Proofs of strong normalisation for second order classical natural deductionThe Journal of Symbolic Logic, 1997
- A term calculus for Intuitionistic Linear Logic1993
- Logic Programming with Focusing Proofs in Linear LogicJournal of Logic and Computation, 1992
- A theory of type polymorphism in programmingJournal of Computer and System Sciences, 1978