Hostname: page-component-78c5997874-4rdpn Total loading time: 0 Render date: 2024-11-16T01:27:00.576Z Has data issue: false hasContentIssue false

Generic programming with C++ concepts and Haskell type classes—a comparison

Published online by Cambridge University Press:  29 September 2010

JEAN-PHILIPPE BERNARDY
Affiliation:
Department of Computer Science and Engineering, Chalmers University of Technology and University of Gothenburg, SE-412 96 Göteborg, Sweden (e-mail: bernardy@chalmers.se, patrikj@chalmers.se)
PATRIK JANSSON
Affiliation:
Department of Computer Science and Engineering, Chalmers University of Technology and University of Gothenburg, SE-412 96 Göteborg, Sweden (e-mail: bernardy@chalmers.se, patrikj@chalmers.se)
MARCIN ZALEWSKI
Affiliation:
Open Systems Lab, Indiana University, Lindley Hall 215, Bloomington, IN 47405, USA (e-mail: zalewski@osl.iu.edu)
SIBYLLE SCHUPP
Affiliation:
Institute for Software Systems, Hamburg University of Technology, Schwarzenbergstraße 95 (E), D-21073 Hamburg, Germany (e-mail: schupp@tuhh.de)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

Earlier studies have introduced a list of high-level evaluation criteria to assess how well a language supports generic programming. Languages that meet all criteria include Haskell because of its type classes and C++ with the concept feature. We refine these criteria into a taxonomy that captures commonalities and differences between type classes in Haskell and concepts in C++ and discuss which differences are incidental and which ones are due to other language features. The taxonomy allows for an improved understanding of language support for generic programming, and the comparison is useful for the ongoing discussions among language designers and users of both languages.

Type
Articles
Copyright
Copyright © Cambridge University Press 2010

References

Austern, M. H. (1998) Generic Programming and the STL: Using and Extending the C++ Standard Template Library. Addison-Wesley Longman Publishing Co., Inc..Google Scholar
Becker, P. (ed) (June 2009) Working Draft, Standard for Programming Language C++. Number N2914=09-0104 in JTC1/SC22/WG21 - C++. ISO/IEC.Google Scholar
Bernardy, J., Jansson, P., Zalewski, M., Schupp, S. & Priesnitz, A. (2008) A comparison of C++ concepts and Haskell type classes. In Proceeding of the ACM SIGPLAN Workshop on Generic Programming (WGP 2008). ACM, pp. 3748.Google Scholar
Boost. (2009). The Boost initiative for free peer-reviewed portable C++ source libraries. Available at: http://www.boost.org.Google Scholar
Brown, W., Jefferson, C., Meredith, A. & Widman, J. (2008) Named Requirements for C++ Concepts. Technical Report N2581=08-0091, ISO/IEC JTC1/SC22/WG21 - C++.Google Scholar
Cardelli, L. & Wegner, P. (1985) On understanding types, data abstraction, and polymorphism, ACM Comput. Surv., 17 (4): 471523. ISSN .CrossRefGoogle Scholar
Chakravarty, M. M. T., Keller, G. & Peyton Jones, S. (September 2005a) Associated type synonyms, SIGPLAN Not., 40 (9): 241253.CrossRefGoogle Scholar
Chakravarty, M. M. T., Keller, G., Peyton Jones, S. & Marlow, S. (2005b) Associated types with class. In Proceedings of the 32nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). ACM, pp. 113.Google Scholar
Dos Reis, G. & Stroustrup, B. (2006) Specifying C++ concepts. In Proceedings of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL). ACM, pp. 295308.Google Scholar
Garcia, R., Jarvi, J., Lumsdaine, A., Siek, J. & Willcock, J. (2007) An extended comparative study of language support for generic programming. J. Funct. Program., 17 (2): 145205.Google Scholar
Gibbons, J. (2007) Datatype-generic programming. In Spring School on Datatype-Generic Programming, volume 4719 of LNCS. Springer, pp. 171.Google Scholar
Gottschling, P. (2008) Concept Implication and Requirement Propagation. Technical Report N2646=08-0156, ISO/IEC JTC1/SC22/WG21 - C++.Google Scholar
Gregor, D. (January 2008a) ConceptGCC — a prototype compiler for C++ concepts [online] Available at: http://www.generic-programming.org/software/ConceptGCC/.Google Scholar
Gregor, D. (2008b) Type-Soundness and Optimization in the Concepts Proposal. Technical Report N2576=08-0086, ISO/IEC JTC1/SC22/WG21 - C++.Google Scholar
Gregor, D. (August 2009) What happened in Frankfurt? C++-Next, The next generation of C++ [online]. Available at: http://cpp-next.com/archive/2009/08/what-happened-in-frankfurt/.Google Scholar
Gregor, D., Järvi, J., Siek, J., Stroustrup, B., Dos Reis, G. & Lumsdaine, A. (2006) Concepts: Linguistic support for generic programming in C++. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages & Applications (OOPSLA), pp. 291–310.Google Scholar
Gregor, D. & Siek, J. (August 2005) Implementing Concepts. Technical Report N1848=05-0108, ISO/IEC JTC1/SC22/WG21 - C++.Google Scholar
Hinze, R. & Peyton Jones, S. (2001) Derivable type classes. In Proceedings of the 2000 ACM SIGPLAN Haskell Workshop, Hutton, G. (ed), vol. 41.1 of Electronic Notes in Theoretical Computer Science. Elsevier Science.Google Scholar
Jansson, P. & Jeuring, J. (1997) PolyP — a polytypic programming language extension. In Proceedings of the Principles of Programming Languages (POPL 1997:). ACM Press, pp. 470482.Google Scholar
Jazayeri, M., Loos, R. & Musser, D., (eds) (2000) In Generic Programming: International Seminar, Dagstuhl Castle, Germany, 1998, Selected Papers, vol. 1766 of. Springer.Google Scholar
Jones, M. P. (1993) A system of constructor classes: overloading and implicit higher-order polymorphism. In Proceedings of the Conference on Functional Programming Languages and Computer Architecture (FPCA). ACM, pp. 5261.Google Scholar
Jones, M. P. (1995) Dictionary-free overloading by partial evaluation. LISP Symb. Comput., 8 (3): 229248.Google Scholar
Jones, M. P. (2000) Type classes with functional dependencies. In Programming Languages and Systems, vol. 1782 of LNCS. Springer, pp. 230244.Google Scholar
Kahl, W. & Scheffczyk, J. (2001) Named instances for Haskell type classes. In Proceedings of the 2001 ACM SIGPLAN Haskell Workshop, Hinze, R. (ed), Elsevier Science, pp. 7799.Google Scholar
Kapur, D. & Musser, D. (1992) Tecton: A Framework for Specifying and Verifying Generic System Components. Technical Report, Rensselaer Polytechnic Institute [online]. Available at: URL http://www.cs.rpi.edu/musser/gp/tecton/tpcd-tecton.ps.Google Scholar
Kiselyov, O. & Peyton Jones, S. (April 2008) Choosing a type-class instance based on the context [online]. Available at: http://haskell.org/haskellwiki/GHC/AdvancedOverlap.Google Scholar
Kiselyov, O. & Shan, C.-C. (2007) Lightweight static resources, for safe embedded and systems programming. In Draft Proceedings of Trends in Functional Programming. Seton Hall University.Google Scholar
Lincke, D., Jansson, P., Zalewski, M. & Ionescu, C. (July 2009) Generic libraries in C++ with concepts from High-Level domain descriptions in Haskell. In IFIP TC 2 Working Conference on Domain-Specific Languages, pp. 236–261.CrossRefGoogle Scholar
McBride, C. (2010) She's faking it [online]. Available at: http://personal.cis.strath.ac.uk/~conor/pub/she/faking.html.Google Scholar
Meacham, J. (2006) Class alias proposal for Haskell [online]. Available at: http://repetae.net/recent/out/classalias.html.Google Scholar
Mitchell, N. (2007) Deriving Generic Functions by Example. Technical Report, Dept. of Computer Science, University of York, UK. Tech. Report YCS-2007-421.Google Scholar
Munkby, G., Priesnitz, A., Schupp, S. & Zalewski, M.Scrap++: Scrap your boilerplate in C++. (2010) In Proceedings of the 2006 ACM SIGPLAN Workshop on Generic Programming (WGP 2006). ACM Press, pp. 6675.Google Scholar
Orchard, D. & Schrijvers, T. (2010) Haskell type constraints unleashed. In Proceedings of the 2010 International Symposium on Functional and Logic Programming (FLOPS 2010:). Springer.Google Scholar
Peyton Jones, S. (2003) Haskell 98 Language and Libraries: the Revised Report. Cambridge University Press.Google Scholar
Peyton Jones, S., Jones, M. & Meijer, E. (1997) Type classes: an exploration of the design space. In Haskell Workshop [online]. Available at: http://research.microsoft.com/en-us/um/people/simonpj/papers/type-class-design-space/.Google Scholar
Rodriguez, A., Jeuring, J., Jansson, P., Gerdes, A., Kiselyov, O. & Oliveira, B. C. d. S. (2008) Comparing libraries for generic programming in Haskell. In Haskell 2008. ACM, pp. 111122.Google Scholar
Schrijvers, T., Peyton Jones, S., Chakravarty, M. & Sulzmann, M. (2008) Type checking with open type functions. In Proceedings of the 13th ACM SIGPLAN International Conference on Functional Programming (ICFP 2008). ACM Press.Google Scholar
Schrijvers, T., Stuckey, P. & Wadler, P. (2009) Monadic constraint programming, J. Funct. Program., 19 (6): 135.Google Scholar
Sheard, T.Generic Programming in Ωmega. (2007) In Datatype-Generic Programming, vol. 4719 of LNCS. Springer, pp. 258284.CrossRefGoogle Scholar
Sheard, T. & Peyton Jones, S. (December 2002) Template meta-programming for Haskell. SIGPLAN Not., 37 (12): 6075.CrossRefGoogle Scholar
Siek, J. G. & Lumsdaine, A. (June 2005) Essential language support for generic programming. In Proceedings of the ACM SIGPLAN 2005 Conference on Programming Language Design and Implementation (PLDI 2005). ACM Press.Google Scholar
Stepanov, A. A. & Lee, M. (November 1995) The Standard Template Library. Technical Report HPL-95-11(R.1), Hewlett Packard Laboratories, Palo Alto, CA, USA.Google Scholar
Stroustrup, B. (June 2009a) Simplifying the Use of Concepts. Technical Report N2906=09-0096, ISO/IEC JTC1/SC22/WG21 - C++.Google Scholar
Stroustrup, B. (July 2009b) The C++0x “Remove Concepts” Decision. Dr. Dobb's.Google Scholar
Sulzmann, M., Chakravarty, M. M. T., Peyton Jones, S. & Donnelly, K. (2007a) System F with type equality coercions. In Proceedings of the 2007 ACM SIGPLAN international Workshop on Types in Languages Design and Implementation (TLDI 2007). ACM Press, pages 5366.Google Scholar
Sulzmann, M., Duck, G. J., Peyton-Jones, S. & Stuckey, P. J. (2007b) Understanding functional dependencies via constraint handling rules, J. Funct. Program., 17 (1): 83129.CrossRefGoogle Scholar
Vandevoorde, D. & Josuttis, N. M. (November 2002) C++ Templates: The Complete Guide. Addison-Wesley Professional.Google Scholar
Wadler, P. & Blott, S. (1989) How to make ad-hoc polymorphism less ad hoc. In Proceedings of the 16th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL 1989:). ACM Press, pp. 6076.Google Scholar
Willcock, J., Järvi, J., Lumsdaine, A. & Musser, D. (April 2004) A formalization of concepts for generic programming. In Concepts: a Linguistic Foundation of Generic Programming at Adobe Tech Summit. Adobe Systems.Google Scholar
Zalewski, M., Priesnitz, A., Ionescu, C., Botta, N. & Schupp, S. (2007) Multi-language library development: From Haskell type classes to C++ concepts. In Multiparadigm Programming with Object-Oriented Languages: MPOOL 2007.Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.