Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Familia: unifying interfaces, type classes, and family polymorphism

Published: 12 October 2017 Publication History
  • Get Citation Alerts
  • Abstract

    Parametric polymorphism and inheritance are both important, extensively explored language mechanisms for providing code reuse and extensibility. But harmoniously integrating these apparently distinct mechanisms—and powerful recent forms of them, including type classes and family polymorphism—in a single language remains an elusive goal. In this paper, we show that a deep unification can be achieved by generalizing the semantics of interfaces and classes. The payoff is a significant increase in expressive power with little increase in programmer-visible complexity. Salient features of the new programming language include retroactive constraint modeling, underpinning both object-oriented programming and generic programming, and module-level inheritance with further-binding, allowing family polymorphism to be deployed at large scale. The resulting mechanism is syntactically light, and the more advanced features are transparent to the novice programmer. We describe the design of a programming language that incorporates this mechanism; using a core calculus, we show that the type system is sound. We demonstrate that this language is highly expressive by illustrating how to use it to implement highly extensible software and by showing that it can not only concisely model state-of-the-art features for code reuse, but also go beyond them.

    Supplementary Material

    Auxiliary Archive (oopsla17-oopsla15-aux.zip)

    References

    [1]
    M. Abadi and L. Cardelli. On subtyping and matching. ACM Trans. on Programming Languages and Systems, 18(4), July 1996.
    [2]
    M. Abadi, L. Cardelli, and R. Viswanathan. An interpretation of objects and object types. In 23 rd ACM Symp. on Principles of Programming Languages (POPL), 1996.
    [3]
    A. V. Aho, J. E. Hopcroft, and J. Ullman. Data Structures and Algorithms. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1st edition, 1983.
    [4]
    A. V. Aho, M. S. Lam, R. Sethi, and J. D. Ullman. Compilers: Principles, Techniques, and Tools (2nd Edition). Addison-Wesley Longman Publishing Co., Inc., 2006.
    [5]
    I. Aracic, V. Gasiunas, M. Mezini, and K. Ostermann. An overview of CaesarJ. In A. Rashid and M. Aksit, editors, Lecture Notes in Computer Science: Transactions on Aspect-Oriented Software Development I, pages 135–173. Springer-Verlag, 2006.
    [6]
    A. P. Black, K. B. Bruce, and R. J. Noble. The essence of inheritance. In A List of Successes That Can Change the World, volume 9600 of LNCS, pages 73–94. Springer, Mar. 2016.
    [7]
    G. Bracha, P. von der Ahé, V. Bykov, Y. Kashai, W. Maddox, and E. Miranda. Modules as objects in Newspeak. In 24 th European Conf. on Object-Oriented Programming, 2010.
    [8]
    K. Bruce, L. Cardelli, and B. Pierce. Comparing object encodings. Information and Computation, 155(1):108–133, 1999.
    [9]
    K. B. Bruce. A paradigmatic object-oriented programming language: Design, static typing and semantics. Journal of Functional Programming, 4(2):127–206, 1994.
    [10]
    K. B. Bruce and J. N. Foster. LOOJ: Weaving LOOM into Java. In European Conf. on Object-Oriented Programming, 2004.
    [11]
    K. B. Bruce, A. Fiech, and L. Petersen. Subtyping is not a good “match” for object-oriented languages. In Proceedings of 11th European Conference on Object-Oriented Programming (ECOOP’97), number 1241 in Lecture Notes in Computer Science, pages 104–127, June 1997.
    [12]
    K. B. Bruce, M. Odersky, and P. Wadler. A statically safe alternative to virtual types. In 12 th European Conf. on Object-Oriented Programming, number 1445 in Lecture Notes in Computer Science, pages 523–549, July 1998.
    [13]
    K. B. Bruce, A. Schuett, R. van Gent, and A. Fiech. PolyTOIL: A type-safe polymorphic object-oriented language. ACM Trans. on Programming Languages and Systems, 25(2):225–290, Mar. 2003.
    [14]
    P. Canning, W. Cook, W. Hill, J. Mitchell, and W. Olthoff. F-bounded polymorphism for object-oriented programming. In Conf. on Functional Programming Languages and Computer Architecture, pages 273–280, 1989.
    [15]
    L. Cardelli. A semantics of multiple inheritance. Information and Computation, 76(2–3):138–164, 1988. Also in Readings in Object-Oriented Database Systems, S. Zdonik and D. Maier, eds., Morgan Kaufmann, 1990.
    [16]
    M. M. T. Chakravarty, G. Keller, and S. P. Jones. Associated type synonyms. In 10 th ACM SIGPLAN Int’l Conf. on Functional Programming, 2005a.
    [17]
    M. M. T. Chakravarty, G. Keller, S. P. Jones, and S. Marlow. Associated types with class. In 32 nd ACM Symp. on Principles of Programming Languages (POPL), 2005b.
    [18]
    C. Chambers. Object-oriented multi-methods in Cecil. In O. L. Madsen, editor, 20 th European Conf. on Object-Oriented Programming, volume 615, pages 33–56, 1992.
    [19]
    D. Clarke, S. Drossopoulou, J. Noble, and T. Wrigstad. Tribe: A simple virtual class calculus. In AOSD ’07: Proceedings of the 6th International Conference on Aspect-Oriented Software Development, pages 121–134, 2007.
    [20]
    W. Cook and J. Palsberg. A denotational semantics of inheritance and its correctness. In 4 th ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), 1989.
    [21]
    W. R. Cook. On understanding data abstraction, revisited. In 24 th ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pages 557–572, 2009.
    [22]
    W. R. Cook, W. L. Hill, and P. S. Canning. Inheritance is not subtyping. In Conference Record of the Seventeenth Annual ACM Symposium on Principles of Programming Languages, San Francisco, California, pages 125–135, Jan. 1990. Also STL-89-17, Software Technology Laboratory, Hewlett-Packard Laboratories, Palo Alto, CA, July 1989.
    [23]
    D. Devriese and F. Piessens. On the bright side of type classes: Instance arguments in Agda. In 16 th ACM SIGPLAN Int’l Conf. on Functional Programming, 2011.
    [24]
    D. Dreyer, R. Harper, M. M. T. Chakravarty, and G. Keller. Modular type classes. In 34 th ACM Symp. on Principles of Programming Languages (POPL), 2007.
    [25]
    E. Ernst. gbeta—a Language with Virtual Attributes, Block Structure, and Propagating, Dynamic Inheritance. PhD thesis, Department of Computer Science, University of Aarhus, Aarhus, Denmark, 1999.
    [26]
    E. Ernst. Family polymorphism. In 15 th European Conf. on Object-Oriented Programming, LNCS 2072, pages 303–326, 2001.
    [27]
    E. Ernst, K. Ostermann, and W. R. Cook. A virtual class calculus. In 33 rd ACM Symp. on Principles of Programming Languages (POPL), pages 270–282, Jan. 2006.
    [28]
    J. Gosling, B. Joy, G. Steele, and G. Bracha. The Java Language Specification. Addison Wesley, 3nd edition, 2005.
    [29]
    B. Greenman, F. Muehlboeck, and R. Tate. Getting F-bounded polymorphism into shape. In 35 th ACM SIGPLAN Conf. on Programming Language Design and Implementation (PLDI), pages 89–99, 2014.
    [30]
    R. Grigore. Java generics are Turing complete. In 44 th ACM Symp. on Principles of Programming Languages (POPL), 2017.
    [31]
    C. Gunter and J. C. Mitchell, editors. Theoretical aspects of object-oriented programming. MIT Press, 1994.
    [32]
    A. Igarashi and B. Pierce. Foundations for virtual types. In Thirteenth European Conference on Object-Oriented Programming (ECOOP’99), number 1628 in Lecture Notes in Computer Science, pages 161–185, June 1999.
    [33]
    A. Igarashi and M. Viroli. Variant path types for scalable extensibility. In 22 nd ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pages 113–132, 2007.
    [34]
    A. Igarashi, B. Pierce, and P. Wadler. Featherweight Java: A minimal core calculus for Java and GJ. ACM Trans. on Programming Languages and Systems, 23(3):396–450, 2001.
    [35]
    J. Järvi, J. Willcock, and A. Lumsdaine. Associated types and constraint propagation for mainstream object-oriented generics. In 20 th ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), 2005.
    [36]
    P. Jolly, S. Drossopoulou, C. Anderson, and K. Ostermann. Simple dependent types: Concord. In ECOOP Workshop on Formal Techniques for Java Programs (FTfJP), June 2004.
    [37]
    S. P. Jones, M. Jones, and E. Meijer. Type classes: an exploration of the design space. In Haskell Workshop, 1997.
    [38]
    B. Liskov, A. Snyder, R. Atkinson, and J. C. Schaffert. Abstraction mechanisms in CLU. Comm. of the ACM, 20(8):564–576, Aug. 1977. Also in S. Zdonik and D. Maier, eds., Readings in Object-Oriented Database Systems.
    [39]
    B. Liskov, R. Atkinson, T. Bloom, J. E. Moss, J. C. Schaffert, R. Scheifler, and A. Snyder. CLU Reference Manual. Springer-Verlag, 1984. Also published as Lecture Notes in Computer Science 114, G. Goos and J. Hartmanis, Eds., Springer-Verlag, 1981.
    [40]
    D. MacQueen. Modules for Standard ML. In 1984 ACM Symposium on Lisp and Functional Programming, pages 198–204, Aug. 1984.
    [41]
    O. L. Madsen. Semantic analysis of virtual classes and nested classes. In 14 th ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pages 114–131, Nov. 1999.
    [42]
    O. L. Madsen and B. Møller-Pedersen. Virtual classes: A powerful mechanism for object-oriented programming. In 4 th ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pages 397–406, Oct. 1989.
    [43]
    O. L. Madsen, B. Møller-Pedersen, and K. Nygaard. Object Oriented Programming in the BETA Programming Language. Addison-Wesley, June 1993.
    [44]
    R. Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17(3):348–375, 1978.
    [45]
    A. Moors, F. Piessens, and M. Odersky. Generics of a higher kind. In 23 rd ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), 2008.
    [46]
    F. Nielson, H. R. Nielson, and C. Hankin. Principles of Program Analysis. Springer-Verlag New York, Inc., 1999.
    [47]
    N. Nystrom, S. Chong, and A. C. Myers. Scalable extensibility via nested inheritance. In 19 th ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pages 99–115, Oct. 2004.
    [48]
    N. Nystrom, X. Qi, and A. C. Myers. J&: Nested intersection for scalable software composition. In 21 st ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pages 21–36, Oct. 2006.
    [49]
    M. Odersky and M. Zenger. Scalable component abstractions. In 20 th ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pages 41–57, Oct. 2005.
    [50]
    M. Odersky, V. Cremet, C. Röckl, and M. Zenger. A nominal theory of objects with dependent types. In Proceedings of 17th European Conference on Object-Oriented Programming (ECOOP 2003), number 2743 in Lecture Notes in Computer Science, pages 201–224, July 2003.
    [51]
    B. C. Oliveira, A. Moors, and M. Odersky. Type classes as objects and implicits. In 25 th ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pages 341–360, 2010.
    [52]
    K. Ostermann. Dynamically composable collaborations with delegation layers. In 16 th European Conf. on Object-Oriented Programming, volume 2374 of Lecture Notes in Computer Science, pages 89–110, 2002.
    [53]
    L. Palmer. Haskell antipattern: Existential typeclass. https://lukepalmer.wordpress.com/2010/01/24/ haskell- antipattern- existential- typeclass, 2010.
    [54]
    S. Peyton Jones. Classes, Jim, but not as we know them—type classes in Haskell: What, why, and whither. In 23 rd European Conf. on Object-Oriented Programming, 2009.
    [55]
    B. Pierce and M. Steffen. Higher-order subtyping. Theoretical Computer Science, 176(1), 1997.
    [56]
    X. Qi and A. C. Myers. Homogeneous family sharing. In 25 th ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), pages 520–538, Oct. 2010.
    [57]
    J. C. Reynolds. User-defined types and procedural data structures as complementary approaches to data abstraction. In S. A. Schuman, editor, New Directions in Algorithmic Languages, pages 157–168. Institut de Recherche d’Informatique et d’Automatique, Le Chesnay, France, 1975. Reprinted in [ Gunter and Mitchell 1994 ], pages 13–23.
    [58]
    Rust 2014. Rust programming language. http://doc.rust-lang.org/0.11.0/rust.html, 2014.
    [59]
    S. Ryu. ThisType for object-oriented languages: From theory to practice. ACM Trans. on Programming Languages and Systems, 38(3), Apr. 2016.
    [60]
    J. G. Siek and A. Lumsdaine. A language for generic programming in the large. Science of Computer Programming, 76(5): 423–465, 2011.
    [61]
    Y. Smaragdakis and D. Batory. Mixin layers: An object-oriented implementation technique for refinements and collaborationbased designs. ACM Transactions on Software Engineering and Methodology, 11(2):215–255, Apr. 2002.
    [62]
    B. Stroustrup. The C++ Programming Language. Addison-Wesley, 1987.
    [63]
    B. Stroustrup. The C++0x “remove concepts” decision. Dr. Dobbs, July 2009.
    [64]
    Swift 2014. Swift programming language. https://developer.apple.com/swift/resources, 2014.
    [65]
    K. K. Thorup. Genericity in Java with virtual types. In European Conf. on Object-Oriented Programming, number 1241 in Lecture Notes in Computer Science, pages 444–471, 1997.
    [66]
    M. Torgersen. Virtual types are statically safe. In 5th Workshop on Foundations of Object-Oriented Languages (FOOL), Jan. 1998.
    [67]
    M. Torgersen, C. P. Hansen, E. Ernst, P. von der Ahé, G. Bracha, and N. Gafter. Adding wildcards to the Java programming language. In 2004 ACM Symposium on Applied Computing, SAC ’04, pages 1289–1296, 2004.
    [68]
    P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad hoc. In 16 th ACM Symp. on Principles of Programming Languages (POPL), 1989.
    [69]
    P. Wadler et al. The expression problem, Dec. 1998. Discussion on Java-Genericity mailing list.
    [70]
    A. Warth, M. Stanojević, and T. Millstein. Statically scoped object adaptation with expanders. In 21 st ACM SIGPLAN Conf. on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA), Oct. 2006.
    [71]
    S. Wehr and P. Thiemann. JavaGI: The interaction of type classes with interfaces and inheritance. ACM Trans. on Programming Languages and Systems, 33(4):12:1–12:83, July 2011.
    [72]
    M. Weiel, I. Maier, S. Erdweg, M. Eichberg, and M. Mezini. Towards virtual traits in Scala. In Scala ’14, pages 67–75, July 2014.
    [73]
    A. K. Wright and M. Felleisen. A syntactic approach to type soundness. Technical Report TR91-160, Rice University, 1992.
    [74]
    Y. Zhang, M. C. Loring, G. Salvaneschi, B. Liskov, and A. C. Myers. Genus: Making generics object-oriented, expressive, and lightweight. Technical Report 1813–39910, Cornell University Computing and Information Science, June 2015a.
    [75]
    Y. Zhang, M. C. Loring, G. Salvaneschi, B. Liskov, and A. C. Myers. Lightweight, flexible object-oriented generics. In 36 th ACM SIGPLAN Conf. on Programming Language Design and Implementation (PLDI), pages 436–445, June 2015b.

    Cited By

    View all
    • (2024)Persimmon: Nested Family Polymorphism with Extensible Variant TypesProceedings of the ACM on Programming Languages10.1145/36498368:OOPSLA1(698-724)Online publication date: 29-Apr-2024
    • (2023)The Online Pause and Resume Problem: Optimal Algorithms and An Application to Carbon-Aware Load ShiftingProceedings of the ACM on Measurement and Analysis of Computing Systems10.1145/36267767:3(1-32)Online publication date: 12-Dec-2023
    • (2023)Extensible Metatheory Mechanization via Family PolymorphismProceedings of the ACM on Programming Languages10.1145/35912867:PLDI(1608-1632)Online publication date: 6-Jun-2023
    • Show More Cited By

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image Proceedings of the ACM on Programming Languages
    Proceedings of the ACM on Programming Languages  Volume 1, Issue OOPSLA
    October 2017
    1786 pages
    EISSN:2475-1421
    DOI:10.1145/3152284
    Issue’s Table of Contents
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 12 October 2017
    Published in PACMPL Volume 1, Issue OOPSLA

    Permissions

    Request permissions for this article.

    Check for updates

    Badges

    Author Tags

    1. Familia
    2. extensibility
    3. family polymorphism
    4. genericity
    5. language design
    6. type classes
    7. type-safety

    Qualifiers

    • Research-article

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)139
    • Downloads (Last 6 weeks)15

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Persimmon: Nested Family Polymorphism with Extensible Variant TypesProceedings of the ACM on Programming Languages10.1145/36498368:OOPSLA1(698-724)Online publication date: 29-Apr-2024
    • (2023)The Online Pause and Resume Problem: Optimal Algorithms and An Application to Carbon-Aware Load ShiftingProceedings of the ACM on Measurement and Analysis of Computing Systems10.1145/36267767:3(1-32)Online publication date: 12-Dec-2023
    • (2023)Extensible Metatheory Mechanization via Family PolymorphismProceedings of the ACM on Programming Languages10.1145/35912867:PLDI(1608-1632)Online publication date: 6-Jun-2023
    • (2023)Near-optimal Online Algorithms for Joint Pricing and Scheduling in EV Charging NetworksProceedings of the 14th ACM International Conference on Future Energy Systems10.1145/3575813.3576878(72-83)Online publication date: 20-Jun-2023
    • (2022)The Online Knapsack Problem with DeparturesProceedings of the ACM on Measurement and Analysis of Computing Systems10.1145/35706186:3(1-32)Online publication date: 8-Dec-2022
    • (2022)Jointly Predicting Future Content in Multiple Social Media Sites Based on Multi-task LearningACM Transactions on Information Systems10.1145/349553040:4(1-28)Online publication date: 11-Jan-2022
    • (2022)Survey of Approaches for Postprocessing of Static Analysis AlarmsACM Computing Surveys10.1145/349452155:3(1-39)Online publication date: 3-Feb-2022
    • (2021)Competitive Algorithms for Online Multidimensional Knapsack ProblemsProceedings of the ACM on Measurement and Analysis of Computing Systems10.1145/34910425:3(1-30)Online publication date: 15-Dec-2021
    • (2021)Competitive Algorithms for the Online Multiple Knapsack Problem with Application to Electric Vehicle ChargingProceedings of the ACM on Measurement and Analysis of Computing Systems10.1145/34283364:3(1-32)Online publication date: 15-Jun-2021
    • (2021)Optimal VM-to-user mapping in cloud environment based on sustainable strategy space theoryCluster Computing10.1007/s10586-021-03323-224:4(3229-3247)Online publication date: 1-Dec-2021
    • Show More Cited By

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Get Access

    Login options

    Full Access

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media