Advertisement

Disjoint Polymorphism

  • João Alpuim
  • Bruno C. d. S. Oliveira
  • Zhiyuan Shi
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10201)

Abstract

The combination of intersection types, a merge operator and parametric polymorphism enables important applications for programming. However, such combination makes it hard to achieve the desirable property of a coherent semantics: all valid reductions for the same expression should have the same value. Recent work proposed disjoint intersections types as a means to ensure coherence in a simply typed setting. However, the addition of parametric polymorphism was not studied. This paper presents Open image in new window : a calculus with disjoint intersection types, a variant of parametric polymorphism and a merge operator. Open image in new window is both type-safe and coherent. The key difficult occurs in an intersection type, it is not statically known whether the instantiated type will be disjoint to other components of the intersection. To address this problem we propose disjoint polymorphism: a constrained form of parametric polymorphism, which allows disjointness constraints for type variables. With disjoint polymorphism the calculus remains very flexible in terms of programs that can be written, while retaining coherence.

Keywords

Type Variable Intersection Type Record Type Algorithmic Rule Subtyping Relation 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Notes

Acknowledgments

We would like to thank the ESOP reviewers for their helpful comments. This work has been sponsored by the Hong Kong Research Grant Council Early Career Scheme project number 27200514.

References

  1. 1.
  2. 2.
    The Coq Proof Assistant. https://coq.inria.fr/
  3. 3.
  4. 4.
  5. 5.
    Ancona, D., Lagorio, G., Zucca, E.: Jam-designing a Java extension with mixins. ACM Trans. Program. Lang. Syst. 25(5), 641–712 (2003)CrossRefGoogle Scholar
  6. 6.
    Ancona, D., Zucca, E.: An algebraic approach to mixins and modularity. In: Hanus, M., Rodríguez-Artalejo, M. (eds.) ALP 1996. LNCS, vol. 1139, pp. 179–193. Springer, Heidelberg (1996). doi: 10.1007/3-540-61735-3_12 CrossRefGoogle Scholar
  7. 7.
    Aydemir, B.E., Charguéraud, A., Pierce, B.C., Pollack, R., Weirich, S.: Engineering formal metatheory. In: POPL 2008 (2008)Google Scholar
  8. 8.
    Bettini, L., Bono, V., Likavec, S.: A core calculus of higher-order mixins and classes. In: SAC 2004 (2004)Google Scholar
  9. 9.
    Black, A.P., Bruce, K.B., Homer, M., Noble, J.: Grace: the absence of (inessential) difficulty. In: Onward! 2012 (2012)Google Scholar
  10. 10.
    Blume, M., Acar, U.A., Chae, W.: Extensible programming with first-class cases. In: ICFP 2006 (2006)Google Scholar
  11. 11.
    Bracha, G., Cook, W.: Mixin-based inheritance. In: OOPSLA/ECOOP 1990 (1990)Google Scholar
  12. 12.
    Canning, P., Cook, W., Hill, W., Olthoff, W., Mitchell, J.C.: F-bounded polymorphism for object-oriented programming. In: FPCA 1989 (1989)Google Scholar
  13. 13.
    Cardelli, L.: Extensible records in a pure calculus of subtyping. In: Theoretical Aspects of Object-oriented Programming. MIT Press, Cambridge (1994)Google Scholar
  14. 14.
    Cardelli, L., Martini, S., Mitchell, J.C., Scedrov, A.: An extension of system F with subtyping. Inf. Comput. 109(1–2), 4–56 (1994)MathSciNetCrossRefMATHGoogle Scholar
  15. 15.
    Cardelli, L., Mitchell, J.C.: Operations on records. In: Main, M., Melton, A., Mislove, M., Schmidt, D. (eds.) MFPS 1989. LNCS, vol. 442, pp. 22–52. Springer, Heidelberg (1990). doi: 10.1007/BFb0040253 CrossRefGoogle Scholar
  16. 16.
    Cardelli, L., Wegner, P.: On understanding types, data abstraction, and polymorphism. ACM Comput. Surv. 17(4), 471–522 (1985)CrossRefGoogle Scholar
  17. 17.
    Castagna, G., Ghelli, G., Longo, G.: A calculus for overloaded functions with subtyping. Inf. Comput. 117(1), 115–135 (1995)MathSciNetCrossRefMATHGoogle Scholar
  18. 18.
    Castagna, G., Nguyen, K., Xu, Z., Im, H., Lenglet, S., Padovani, L.: Polymorphic functions with set-theoretic types: part 1: syntax, semantics, and evaluation. In: POPL 2014 (2014)Google Scholar
  19. 19.
    Compagnoni, A.B., Pierce, B.C.: Higher-order intersection types and multiple inheritance. Math. Struct. Comput. Sci. 6(5), 469–501 (1996)MathSciNetMATHGoogle Scholar
  20. 20.
    Coppo, M., Dezani-Ciancaglini, M., Venneri, B.: Functional characters of solvable terms. Math. Logic Q. 27(2–6), 45–58 (1981)MathSciNetCrossRefMATHGoogle Scholar
  21. 21.
    Crary, K.: Simple, efficient object encoding using intersection types. Technical report, CMU-CS-99-100, Cornell University (1998)Google Scholar
  22. 22.
    Davies, R., Pfenning, F.: Intersection types and computational effects. In: ICFP 2000 (2000)Google Scholar
  23. 23.
    Ducasse, S., Nierstrasz, O., Schärli, N., Wuyts, R., Black, A.P.: Traits: a mechanism for fine-grained reuse. ACM Trans. Program. Lang. Syst. 28(2), 331–388 (2006)CrossRefGoogle Scholar
  24. 24.
    Dunfield, J.: Elaborating intersection and union types. In: ICFP 2012 (2012)Google Scholar
  25. 25.
    Findler, R.B., Flatt, M.: Modular object-oriented programming with units and mixins. In: ICFP 1998 (1998)Google Scholar
  26. 26.
    Fisher, K.: A typed calculus of traits. In: FOOL 2011 (2004)Google Scholar
  27. 27.
    Flatt, M., Krishnamurthi, S., Felleisen, M.: Classes and mixins. In: POPL 1998 (1998)Google Scholar
  28. 28.
    Gaster, B.R., Jones, M.P.: A polymorphic type system for extensible records and variants. Technical report, NOTTCS-TR-96-3, University of Nottingham (1996)Google Scholar
  29. 29.
    Harper, R., Pierce, B.: A record calculus based on symmetric concatenation. In: POPL 1991 (1991)Google Scholar
  30. 30.
    Harper, R.W., Pierce, B.C.: Extensible records without subsumption. Technical report, CMU-C5-90-102 (1990)Google Scholar
  31. 31.
    Jones, M., Jones, S.P.: Lightweight extensible records for Haskell. Technical report, UU-CS-1999-28, Haskell Workshop (1999)Google Scholar
  32. 32.
    Jones, M.P.: Qualified Types: Theory and Practice. Cambridge University Press, Cambridge (1994)CrossRefMATHGoogle Scholar
  33. 33.
    Leijen, D.: First-class labels for extensible rows. Technical report, UU-CS-2004-051, Utrecht University (2004)Google Scholar
  34. 34.
    Leijen, D.: Extensible records with scoped labels. In: Trends in Functional Programming (2005)Google Scholar
  35. 35.
    Makholm, H., Wells, J.B.: Type inference, principal typings, and let-polymorphism for first-class mixin modules. In: ICFP 2005 (2005)Google Scholar
  36. 36.
    Odersky, M., Zenger, M.: Scalable component abstractions. In: OOPSLA 2005 (2005)Google Scholar
  37. 37.
    Odersky, M., et al.: An overview of the Scala programming language. Technical report, IC/2004/64, EPFL Lausanne, Switzerland (2004)Google Scholar
  38. 38.
    Oliveira, B.C.S., Shi, Z., Alpuim, J.: Disjoint intersection types. In: ICFP 2016 (2016)Google Scholar
  39. 39.
    Oliveira, B.C.S., Storm, T., Loh, A., Cook, W.R.: Feature-oriented programming with object algebras. In: Castagna, G. (ed.) ECOOP 2013. LNCS, vol. 7920, pp. 27–51. Springer, Heidelberg (2013). doi: 10.1007/978-3-642-39038-8_2 CrossRefGoogle Scholar
  40. 40.
    Pierce, B.C.: Programming with intersection types and bounded polymorphism. Ph.D. thesis, Carnegie Mellon University (1991)Google Scholar
  41. 41.
    Pierce, B.C., Turner, D.N.: Simple type-theoretic foundations for object-oriented programming. J. Funct. Program. 4(2), 207–247 (1994)CrossRefMATHGoogle Scholar
  42. 42.
    Pottier, F.: A constraint-based presentation and generalization of rows. In: LICS 2003 (2003)Google Scholar
  43. 43.
    Pottinger, G.: A type assignment for the strongly normalizable \(\lambda \)-terms. In: To H. B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism (1980)Google Scholar
  44. 44.
    Rémy, D.: Typing record concatenation for free. In: POPL 1992 (1992)Google Scholar
  45. 45.
    Rémy, D.: Type inference for records in natural extension of ML. In: Theoretical Aspects of Object-Oriented Programming. MIT Press, Cambridge (1994)Google Scholar
  46. 46.
    Rendel, T., Brachthäuser, J.I., Ostermann, K.: From object algebras to attribute grammars. In: OOPSLA 2014 (2014)Google Scholar
  47. 47.
    Reynolds, J.C.: The coherence of languages with intersection types. In: Ito, T., Meyer, A.R. (eds.) TACS 1991. LNCS, vol. 526, pp. 675–700. Springer, Heidelberg (1991). doi: 10.1007/3-540-54415-1_70 CrossRefGoogle Scholar
  48. 48.
    Reynolds, J.C.: Design of the programming language Forsythe. In: Algol-like languages, Birkhäuser Boston (1997)Google Scholar
  49. 49.
    Rompf, T., Amin, N.: Type soundness for dependent object types. In: OOPSLA 2016 (2016)Google Scholar
  50. 50.
    Schärli, N., Ducasse, S., Nierstrasz, O., Black, A.P.: Traits: composable units of behaviour. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743, pp. 248–274. Springer, Heidelberg (2003). doi: 10.1007/978-3-540-45070-2_12 CrossRefGoogle Scholar
  51. 51.
    Sulzmann, M.: Designing record systems. Technical report, YALEU/DCS/RR-1128, Yale University (1997)Google Scholar
  52. 52.
    Wand, M.: Complete type inference for simple objects. In: LICS 1987 (1987)Google Scholar
  53. 53.
    Wand, M.: Type inference for record concatenation and multiple inheritance. In: LICS 1989 (1989)Google Scholar

Copyright information

© Springer-Verlag GmbH Germany 2017

Authors and Affiliations

  • João Alpuim
    • 1
  • Bruno C. d. S. Oliveira
    • 1
  • Zhiyuan Shi
    • 1
  1. 1.The University of Hong KongPokfulamHong Kong

Personalised recommendations