Abstract
Modular languages support generative type abstraction, ensuring that an abstract type is distinct from its representation, except inside the implementation where the two are synonymous. We show that this well-established feature is in tension with the non-parametric features of newer type systems, such as indexed type families and GADTs. In this paper we solve the problem by using kinds to distinguish between parametric and non-parametric contexts. The result is directly applicable to Haskell, which is rapidly developing support for type-level computation, but the same issues should arise whenever generativity and non-parametric features are combined.
Supplemental Material
- M. Benke, P. Dybjer, and P. Jansson. Universes for generic programs and proofs in dependent type theory. Nordic J. of Computing, 10(4):265--289, 2003. ISSN 1236--6064. Google Scholar
Digital Library
- A. Bove, P. Dybjer, and U. Norell. A brief overview of agda -- a functional language with dependent types. In TPHOLs '09: Proceedings of the 22nd International Conference on Theorem Proving in Higher Order Logics, pages 73--78, Berlin, Heidelberg, 2009. Springer-Verlag. Google Scholar
Digital Library
- V. Breazu-Tannen, T. Coquand, C. A. Gunter, and A. Scedrov. Inheritance as implicit coercion. Information and Computation, 93:172--221, 1991. Google Scholar
Digital Library
- M. M. T. Chakravarty, G. Keller, and S. Peyton Jones. Associated type synonyms. In ICFP '05: Proceedings of the Tenth ACM SIGPLAN International Conference on Functional Programming, pages 241--253, New York, NY, USA, 2005. ACM. Google Scholar
Digital Library
- M. M. T. Chakravarty, G. Keller, S. Peyton Jones, and S. Marlow. Associated types with class. SIGPLAN Not., 40(1):1--13, 2005b. ISSN 0362--1340. Google Scholar
Digital Library
- J.Chapman,P.Evariste Dagand,C.McBride,and P.Morris.The gentleart of levitation. In Proceedings of the Fifteenth ACM SIGPLAN International Conference on Functional Programming (ICFP '10), Baltimore, MD, USA, September 2010. To appear. Google Scholar
Digital Library
- J. Cheney and R. Hinze. First-class phantom types. CUCIS TR2003--1901, Cornell University, 2003.Google Scholar
- R. L. Constable. Intensional analysis of functions and types. Technical Report CSR-118--82, Department of Computer Science, University of Edinburgh, June 1982.Google Scholar
- R. L. Constable and D. R. Zlatin. The type theory of PL/CV3. ACM Transactions on Programming Languages and Systems, 6(1):94--117, Jan. 1984. Google Scholar
Digital Library
- K. Crary and S. Weirich. Flexible type analysis. In Proceedings of the Fourth ACM SIGPLAN International Conference on Functional Pro- gramming, pages 233--248, Paris, France, Sept. 1999. Google Scholar
Digital Library
- N. G. de Bruijn. Telescopic mappings in typed lambda calculus. Inf. Comput., 91(2):189--204, 1991. ISSN 0890--5401. Google Scholar
Digital Library
- D. Dreyer. Recursive type generativity. In ICFP '05: Proceedings of the Tenth ACM SIGPLAN International Conference on Functional Programming, pages 41--53, New York, NY, USA, 2005. ACM. Google Scholar
Digital Library
- P. Dybjer. A general formulation of simultaneous inductive-recursive definitions in type theory. Journal of Symbolic Logic, 65(2):525--549, 2000.Google Scholar
Cross Ref
- C. V. Hall, K. Hammond, S. L. Peyton Jones, and P. L. Wadler. Type classes in Haskell. ACM Transactions on Programming Languages and Systems, 18(2):109--138, Mar. 1996. Google Scholar
Digital Library
- R. Harper and G. Morrisett. Compiling polymorphism using intensional type analysis. In POPL '95: Proceedings of the 22nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 130--141, New York, NY, USA, 1995. ACM. ISBN 0--89791--692--1. Google Scholar
Digital Library
- R. Hinze, J. Jeuring, and A. Loeh. Type-indexed data types. In B. M. Eerke Boiten, editor, Proceedings of the Sixth International Conference on Mathematics of Program Construction (MPC 2002), pages 148--174, Dagstuhl, Germany, July 2002. Google Scholar
Digital Library
- O. Kiselyov, S. Peyton Jones, and C. Shan. Springer, 2010.Google Scholar
- Fun with type functions.Google Scholar
- D. R. Licata and R. Harper. A formulation of dependent ML with explicit equality proofs. Technical Report Carnegie Mellon University-CS-05--178, Carnegie Mellon University Department of Computer Science, 2005.Google Scholar
- P. Martin-Löf. An intuitionistic theory of types: Predicative part. In Proceedings of the Logic Colloquium, 1973, volume 80 of Studies in Logic and the Foundations of Mathematics, pages 73--118. North-Holland, 1975.Google Scholar
- R. Milner, M. Tofte, and D. Macqueen. The Definition of Standard ML. MIT Press, Cambridge, MA, USA, 1997. ISBN 0262631814. Google Scholar
Digital Library
- B. Montagu and D. Rémy.Modeling abstract types in modules with open existential types.In POPL '09: Proceedings of the 36th annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 354--365, New York, NY, USA, 2009. ACM. Google Scholar
Digital Library
- G. Neis, D. Dreyer, and A. Rossberg. Non-parametric parametricity. In ICFP '09: Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming, pages 135--148, New York, NY, USA, 2009. ACM. ISBN 978--1--60558--332--7. Google Scholar
Digital Library
- S. Peyton Jones et al. The Haskell 98 language and libraries: The revised report. Journal of Functional Programming, 13(1):0--255, Jan 2003. http://www.haskell.org/definition/. Google Scholar
Digital Library
- S. L. Peyton Jones, D. Vytiniotis, S. Weirich, and G. Washburn. Simple unification-based type inference for GADTs. In International Confer- ence on Functional Programming (ICFP), Portland, OR, USA, Sept. 2006. Google Scholar
Digital Library
- B. C. Pierce, editor. Advanced Topics in Types and Programming Lan-guages. MIT Press, 2005. Google Scholar
Digital Library
- A. Rossberg. Dynamic translucency with abstraction kinds and higher-order coercions. Electr. Notes Theor. Comput. Sci., 218:313--336, 2008. Google Scholar
Digital Library
- A. Rossberg. Generativity and dynamic opacity for abstract types. In PPDP '03: Proceedings of the 5th ACM SIGPLAN International Conference on Principles and Practice of Declaritive Programming, pages 241--252, NewYork,NY,USA,2003.ACM.ISBN1--58113--705--2. Google Scholar
Digital Library
- C. V. Russo. Non-dependent types for Standard ML modules. In PPDP '99: Proceedings of the International Conference PPDP'99 on Principles and Practice of Declarative Programming, pages 80--97, London, UK, 1999. Springer-Verlag. ISBN 3--540--66540--4. Google Scholar
Digital Library
- T. Schrijvers, S. Peyton Jones, M. Chakravarty, and M. Sulzmann. Type checking with open type functions. In ICFP '08: Proceeding of the 13th ACM SIGPLAN international conference on Functional programming, pages 51--62, New York, NY, USA, 2008. ACM. Google Scholar
Digital Library
- Z. Shao, V. Trifonov, B. Saha, and N. Papaspyrou. A type system for certified binaries. ACM Trans. Program. Lang. Syst., 27(1):1--45, 2005. Google Scholar
Digital Library
- M. Sulzmann, M. M. T. Chakravarty, S. Peyton Jones, and K. Donnelly. System F with type equality coercions. In TLDI '07: Proceedings of the 2007 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, pages 53--66, New York, NY, USA, 2007. ACM. Google Scholar
Digital Library
- The Coq Team. Coq. URL http://coq.inria.fr.Google Scholar
- D. Vytiniotis, G. Washburn, and S. Weirich. An open and shut typecase. I.Google Scholar
- ACM SIGPLAN Workshop in Types in Language Design and Implementation, Long Beach, CA, USA, Jan. 2005.Google Scholar
- H. Xi, C. Chen, and G. Chen. Guarded recursive datatype constructors. In POPL, pages 224--235, 2003.. Google Scholar
Digital Library
Index Terms
Generative type abstraction and type-level computation
Recommendations
Generative type abstraction and type-level computation
POPL '11: Proceedings of the 38th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languagesModular languages support generative type abstraction, ensuring that an abstract type is distinct from its representation, except inside the implementation where the two are synonymous. We show that this well-established feature is in tension with the ...
Type invariants for Haskell
PLPV '09: Proceedings of the 3rd workshop on Programming languages meets program verificationMulti-parameter type classes, functional dependencies, and recently GADTs and open type families open up opportunities to use complex type-level programming to let GHC's type checker verify various properties of your programs. But type-level code is ...
Type Class Instances for Type-Level Lambdas in Haskell
TFP 2015: Revised Selected Papers of the 16th International Symposium on Trends in Functional Programming - Volume 9547Haskell 2010 lacks flexibility in creating instances of type classes for type constructors with multiple type arguments. We would like to make the order of type arguments to a type constructor irrelevant to how type class instances can be specified. ...







Comments