skip to main content
10.1145/1040305.1040306acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
Article

Associated types with class

Published: 12 January 2005 Publication History

Abstract

Haskell's type classes allow ad-hoc overloading, or type-indexing, of functions. A natural generalisation is to allow type-indexing of data types as well. It turns out that this idea directly supports a powerful form of abstraction called associated types, which are available in C++ using traits classes. Associated types are useful in many applications, especially for self-optimising libraries that adapt their data representations and algorithms in a type-directed manner.In this paper, we introduce and motivate associated types as a rather natural generalisation of Haskell's existing type classes. Formally, we present a type system that includes a type-directed translation into an explicitly typed target language akin to System F; the existence of this translation ensures that the addition of associated data types to an existing Haskell compiler only requires changes to the front end.

References

[1]
Artem Alimarine and Rinus Plasmeijer. A generic programming extension for Clean. In International Workshop on the Implementation of Functional Languages, number 2312 in Lecture Notes in Computer Science, pages 168--185. Springer-Verlag, 2001.]]
[2]
Manuel M. T. Chakravarty and Gabriele Keller. An approach to fast arrays in Haskell. In Johan Jeuring and Simon~Peyton Jones, editors, Lecture notes for The Summer School and Workshop on Advanced Functional Programming 2002, number 2638 in Lecture Notes in Computer Science, 2003.]]
[3]
Kung Chen, Paul Hudak, and Martin Odersky. Parametric type classes. In ACM Conference on Lisp and Functional Programming. ACM Press, 1992.]]
[4]
James Cheney and Ralf Hinze. First-class phantom types. CUCIS TR2003-1901, Cornell University, 2003.]]
[5]
Karl Crary and Stephanie Weirich. Flexible type analysis. In International Conference on Functional Programming, 1999.]]
[6]
Karl Crary, Stephanie Weirich, and Greg Morrisett. Intensional polymorphism in type-erasure semantics. In ACM SIGPLAN International Conference on Functional Programming, pages 301--312. ACM Press, 1998.]]
[7]
Derek Dreyer, Karl Crary, and Robert Harper. A type system for higher-order modules. In Proceedings of the 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 236--249, 2003.]]
[8]
Gregory J. Duck, Simon Peyton Jones, Peter J. Stuckey, and Martin Sulzmann. Sound and decidable type inference for functional dependencies. In ESOP;04, LNCS. Springer-Verlag, 2004.]]
[9]
Dominic Duggan. Dynamic typing for distributed programming in polymorphic languages. Transactions on Programming Languages and Systems, 21(1):11--45, 1999.]]
[10]
Karl-Filip Faxén. A static semantics for Haskell. Journal of Functional Programming, 12(4+5), 2002.]]
[11]
Ronald Garcia, Jaakko Jarvi, Andrew Lumsdaine, Jeremy Siek, and Jeremiah Willcock. A comparative study of language support for generic programming. In Proceedings of the 18th ACM SIGPLAN Conference on Object-Oriented Programing, Systems, Languages, and Applications, pages 115--134. ACM Press, 2003.]]
[12]
Cordelia Hall, Kevin Hammond, Simon Peyton Jones, and Philip Wadler. Type classes in Haskell. In European Symposium On Programming, number 788 in LNCS, pages 241--256. Springer-Verlag, 1994.]]
[13]
Robert Harper and John C. Mitchell. Parametricity and variants of Girard's J operator. Information Processing Letters, 70(1):1--5, 1999.]]
[14]
Robert Harper, John C. Mitchell, and Eugenio Moggi. Higher-order modules and the phase distinction. In Proceedings of the 17th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 341--354. ACM Press, 1989.]]
[15]
Robert Harper and Greg Morrisett. Compiling polymorphism using intensional type analysis. In 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 130--141. ACM Press, 1995.]]
[16]
Ralf Hinze. Generalizing generalized tries. Journal of Functional Programming, 10(4):327--351, 2000.]]
[17]
Ralf Hinze and Johan Jeuring. Generic Haskell: Applications. In Roland Backhouse and Jeremy Gibbons, editors, Lecture notes for The Summer School and Workshop on Generic Programming 2002, number 2793 in Lecture Notes in Computer Science, 2003.]]
[18]
Ralf Hinze, Johan Jeuring, and Andres Löh. Type-indexed data types. In Eerke Boiten and Bernhard Möller, editors, Proceedings of the Sixth International Conference on Mathematics of Program Construction (MPC 2002), number 2386 in Lecture Notes in Computer Science, pages 148--174. Springer-Verlag, 2002.]]
[19]
Ralf Hinze and Simon Peyton Jones. Derivable type classes. In Graham Hutton, editor, Proceedings of the 2000 ACM SIGPLAN Haskell Workshop, volume 41.1 of Electronic Notes in Theoretical Computer Science. Elsevier Science, 2001.]]
[20]
Mark P. Jones. Simplifying and improving qualified types. In FPCA '95: Conference on Functional Programming Languages and Computer Architecture. ACM Press, 1995.]]
[21]
Mark P. Jones. A system of constructor classes: Overloading and implicit higher-order polymorphism. Journal of Functional Programming, 5(1), 1995.]]
[22]
Mark P. Jones. Type classes with functional dependencies. In Proceedings of the 9th European Symposium on Programming (ESOP 2000), number 1782 in Lecture Notes in Computer Science. Springer-Verlag, 2000.]]
[23]
Ralf Lämmel. The sketch of a polymorphic symphony. In 2nd International Workshop on Reduction Strategies in Rewriting and Programming (WRS 2002), volume 70 of ENTCS. Elsevier Science, 2002.]]
[24]
Ralf Lämmel and Simon Peyton Jones. Scrap your boilerplate: a practical approach to generic programming. In Proceedings of the ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI 2003), pages 26--37, 2003.]]
[25]
Xavier Leroy. Manifest types, modules, and separate compilation. In 21st Symposium Principles of Programming Languages, pages 109--122. ACM Press, 1994.]]
[26]
Andres Löh, Dave Clarke, and Johan Jeuring. Dependency-style Generic Haskell. In Proceedings of the Eighth ACM SIGPLAN International Conference on Functional Programming, pages 141--152. ACM Press, 2003.]]
[27]
Nathan C. Myers. Traits: a new and useful template technique. C++ Report, June 1995.]]
[28]
Matthias Neubauer, Peter Thiemann, Martin Gasbichler, and Michael Sperber. A functional notation for functional dependencies. In 2001 ACM SIGPLAN Haskell Workshop, 2001.]]
[29]
Matthias Neubauer, Peter Thiemann, Martin Gasbichler, and Michael Sperber. Functional logic overloading. In Proceedings of the 29th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. ACM Press, 2002.]]
[30]
Martin Odersky, Martin Sulzmann, and Martin Wehr. Type inference with constrained types. Theory and Practice of Object Systems, 5(1), 1999.]]
[31]
Chris Okasaki and Andy Gill. Fast mergeable integer maps. In Workshop on ML, pages 77--86, 1998.]]
[32]
Zhong Shao. Flexible representation analysis. In Proceedings ACM SIGPLAN International Conference on Functional Programming, pages 85--98, 1997.]]
[33]
Jeremy G. Siek, Lie-Quan Lee, and Andrew Lumsdaine. The Boost Graph Library User Guide and Reference Manual. Addison-Wesley, 2001.]]
[34]
Jeremy G. Siek and Andrew Lumsdaine. The matrix template library: Generic components for high-performance scientific computing. Computing in Science and Engineering, 1(6):70--78, 1999.]]
[35]
A. A. Stepanov and M. Lee. The standard template library. Technical Report X3J16/94-0095, WG21/N0482, ISO Programming Language C++ Project, 1994.]]
[36]
Peter J. Stuckey and Martin Sulzmann. A theory of overloading. ACM Transaction on Programming Languages and Systems, 2004. To appear.]]
[37]
Stephanie Weirich. Type-safe cast: Functional pearl. In Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming (ICFP '00). ACM Press, 2000.]]
[38]
Stephanie Weirich. Higher-order intensional type analysis. In European Symposium on Programming (ESOP02), 2002.]]
[39]
Hongwei Xi, Chiyan Chen, and Gang Chen. Guarded recursive datatype constructors. In Proceedings of the 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 224--235. ACM Press, 2003.]]

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
POPL '05: Proceedings of the 32nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages
January 2005
402 pages
ISBN:158113830X
DOI:10.1145/1040305
  • General Chair:
  • Jens Palsberg,
  • Program Chair:
  • Martín Abadi
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 40, Issue 1
    Proceedings of the 32nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages
    January 2005
    391 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/1047659
    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]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 12 January 2005

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. associated types
  2. self-optimising libraries
  3. type classes
  4. type-directed translation
  5. type-indexed types

Qualifiers

  • Article

Conference

POPL05

Acceptance Rates

Overall Acceptance Rate 860 of 4,328 submissions, 20%

Upcoming Conference

POPL '26

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)25
  • Downloads (Last 6 weeks)2
Reflects downloads up to 05 Mar 2025

Other Metrics

Citations

Cited By

View all
  • (2024)Type Checking with Rewriting RulesProceedings of the 17th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3687997.3695640(171-183)Online publication date: 17-Oct-2024
  • (2023)A Haskell-Embedded DSL for Secure Information-FlowFormal Methods: Foundations and Applications10.1007/978-3-031-49342-3_2(20-35)Online publication date: 2-Dec-2023
  • (2021)Taming the Merge OperatorJournal of Functional Programming10.1017/S095679682100018631Online publication date: 2-Nov-2021
  • (2021)AlgorithmicsAdvancing Research in Information and Communication Technology10.1007/978-3-030-81701-5_3(59-98)Online publication date: 4-Aug-2021
  • (2020)Fluent Session Programming in C#Electronic Proceedings in Theoretical Computer Science10.4204/EPTCS.314.6314(61-75)Online publication date: 3-Apr-2020
  • (2019)Partial type constructors: or, making ad hoc datatypes less ad hocProceedings of the ACM on Programming Languages10.1145/33711084:POPL(1-28)Online publication date: 20-Dec-2019
  • (2019)Functional Reactive Programming, restatedProceedings of the 21st International Symposium on Principles and Practice of Declarative Programming10.1145/3354166.3354172(1-14)Online publication date: 7-Oct-2019
  • (2019)Bidirectional type class instancesProceedings of the 12th ACM SIGPLAN International Symposium on Haskell10.1145/3331545.3342596(30-43)Online publication date: 8-Aug-2019
  • (2019)Type-level computations for Ruby librariesProceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation10.1145/3314221.3314630(966-979)Online publication date: 8-Jun-2019
  • (2019)How to prove decidability of equational theories with second-order computation analyser SOLJournal of Functional Programming10.1017/S095679681900015729Online publication date: 24-Dec-2019
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media