{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,5,26]],"date-time":"2026-05-26T23:05:34Z","timestamp":1779836734245,"version":"3.53.1"},"reference-count":67,"publisher":"Cambridge University Press (CUP)","issue":"3-4","license":[{"start":{"date-parts":[[2010,10,21]],"date-time":"2010-10-21T00:00:00Z","timestamp":1287619200000},"content-version":"unspecified","delay-in-days":112,"URL":"https:\/\/www.cambridge.org\/core\/terms"}],"content-domain":{"domain":[],"crossmark-restriction":false},"short-container-title":["J. Funct. Prog."],"published-print":{"date-parts":[[2010,7]]},"abstract":"<jats:title>Abstract<\/jats:title>\n                  <jats:p>Datatype-generic programming (DGP) involves parametrization of programs by the shape of data, in the form of type constructors such as \u2018list of\u2019. Most approaches to DGP are developed in pure functional programming languages such as Haskell. We argue that the functional object-oriented language Scala is in many ways a better choice. Not only does Scala provide equivalents of all the necessary functional programming features (such as parametric polymorphism, higher-order functions, higher-kinded type operations, and type- and constructor-classes), but it also provides the most useful features of object-oriented languages (such as subtyping, overriding, traditional single inheritance, and multiple inheritance in the form of traits). Common Haskell techniques for DGP can be conveniently replicated in Scala, whereas the extra expressivity provides some important additional benefits in terms of extensibility and reuse. We illustrate this by comparing two simple approaches in Haskell, pointing out their limitations and showing how equivalent approaches in Scala address some of these limitations. Finally, we present three case studies on how to implement in Scala real DGP approaches from the literature: Hinze's \u2018Generics for the Masses\u2019, L\u00e4mmel and Peyton Jones's \u2018Scrap your Boilerplate with Class\u2019, and Gibbons's \u2018Origami Programming\u2019.<\/jats:p>","DOI":"10.1017\/s0956796810000171","type":"journal-article","created":{"date-parts":[[2010,10,21]],"date-time":"2010-10-21T04:00:33Z","timestamp":1287633633000},"page":"303-352","source":"Crossref","is-referenced-by-count":8,"title":["Scala for generic programmers"],"prefix":"10.1017","volume":"20","author":[{"given":"BRUNO C. D. S.","family":"OLIVEIRA","sequence":"first","affiliation":[],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"JEREMY","family":"GIBBONS","sequence":"additional","affiliation":[],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"56","published-online":{"date-parts":[[2010,10,21]]},"reference":[{"key":"S0956796810000171_ref6","unstructured":"Cockett R. & Fukushima T. (May 1992) About Charity. Department of Computer Science, University of Calgary."},{"key":"S0956796810000171_ref65","unstructured":"Wadler P. (November 1998) The Expression Problem. Java Genericity Mailing list [online]. Available at: http:\/\/www.cse.ohio-state.edu\/~gb\/cis888.07g\/java-genericity\/20"},{"key":"S0956796810000171_ref60","doi-asserted-by":"crossref","unstructured":"Sch\u00e4rli N. , Ducasse S. , Nierstrasz O. & Black A. (July 2003) Traits: Composable units of behavior. In LNCS 2743: European Conference on Object-Oriented Programming. pp. 248\u2013274.","DOI":"10.1007\/978-3-540-45070-2_12"},{"key":"S0956796810000171_ref51","doi-asserted-by":"crossref","first-page":"98","DOI":"10.1145\/1088348.1088358","volume-title":"Haskell Workshop","author":"Oliveira","year":"2005"},{"key":"S0956796810000171_ref22","doi-asserted-by":"crossref","unstructured":"Hinze R. & L\u00f6h A. (2007) Generic programming, now! LNCS 4719: Datatype-Generic Programming.","DOI":"10.1007\/978-3-540-76786-2_3"},{"key":"S0956796810000171_ref25","volume-title":"Haskell Workshop","author":"Hughes","year":"1999"},{"key":"S0956796810000171_ref36","doi-asserted-by":"publisher","DOI":"10.1007\/BF01211391"},{"key":"S0956796810000171_ref1","doi-asserted-by":"crossref","first-page":"113","DOI":"10.1145\/117954.117963","volume-title":"Proceedings of Object Oriented Programming Systems Languages and Applications","author":"Agrawal","year":"1991"},{"key":"S0956796810000171_ref50","volume-title":"Programming in Scala: A Comprehensive Step-by-Step Guide","author":"Odersky","year":"2008"},{"key":"S0956796810000171_ref49","doi-asserted-by":"crossref","unstructured":"Odersky M. , Zenger C. & Zenger M. (2001) Colored local type inference. In Principles of Programming Languages, pp. 41\u201353.","DOI":"10.1145\/360204.360207"},{"key":"S0956796810000171_ref12","doi-asserted-by":"publisher","DOI":"10.1007\/978-1-349-91518-7"},{"key":"S0956796810000171_ref53","doi-asserted-by":"crossref","unstructured":"Oliveira B. C. D. S. (July 2009a) Modular visitor components: A practical solution to the expression families problem. Drossopoulou S. (ed), In 23rd European Conference on Object Oriented Programming (ECOOP), pp. 269\u2013293.","DOI":"10.1007\/978-3-642-03013-0_13"},{"key":"S0956796810000171_ref39","doi-asserted-by":"crossref","unstructured":"Mitchell N. & Runciman C. (2007) Uniform boilerplate and list processing. In Haskell Workshop, pp. 49\u201360.","DOI":"10.1145\/1291201.1291208"},{"key":"S0956796810000171_ref21","doi-asserted-by":"crossref","unstructured":"Hinze R. & Jeuring J. (2002) Generic Haskell: Practice and theory. In LNCS 2793: Summer School on Generic Programming.","DOI":"10.1007\/978-3-540-45191-4_1"},{"key":"S0956796810000171_ref57","doi-asserted-by":"crossref","unstructured":"Oliveira B. C. D. S. , Moors A. & Odersky M. (October 2010) Type classes as objects and implicits. In Systems, Programming, Languages and Applications: Software for Humanity (SPLASH), Rinard M. (ed).","DOI":"10.1145\/1869459.1869489"},{"key":"S0956796810000171_ref54","doi-asserted-by":"crossref","unstructured":"Oliveira B. C. D. S. (September 2009b) Scala for Generic Programmers: Source code [online]. Available at: http:\/\/www.comlab.ox.ac.uk\/projects\/gip\/Scala.tgz","DOI":"10.1145\/1411318.1411323"},{"key":"S0956796810000171_ref63","first-page":"55","volume-title":"Workshop on Generic Programming","author":"Sulzmann","year":"2006"},{"key":"S0956796810000171_ref41","doi-asserted-by":"publisher","DOI":"10.1145\/1159861.1159875"},{"key":"S0956796810000171_ref30","unstructured":"L\u00e4mmel R. , Visser J. & Kort J. (July 2000) Dealing with large bananas. In Workshop on Generic Programming, Jeuring J. (ed), pp. 46\u201359."},{"key":"S0956796810000171_ref64","volume-title":"Program Design Calculi","author":"Wadler","year":"1993"},{"key":"S0956796810000171_ref35","doi-asserted-by":"publisher","DOI":"10.1017\/S0956796807006326"},{"key":"S0956796810000171_ref48","unstructured":"Odersky M. & Zenger M. (2005) Scalable component abstractions. In Object Oriented Programming, Systems, Languages and Applications, pp. 41\u201357."},{"key":"S0956796810000171_ref43","unstructured":"Odersky M. (2006a) An Overview of the Scala Programming Language (second edition). Tech. rept. IC\/2006\/001. EPFL Lausanne, Switzerland."},{"key":"S0956796810000171_ref24","unstructured":"Hinze R. , L\u00f6h A. & Oliveira B. C. D. S. (2006) \u2018Scrap your Boilerplate\u2019 reloaded. LNCS 3945: Functional and Logic Programming, pp. 13\u201329."},{"key":"S0956796810000171_ref15","doi-asserted-by":"publisher","DOI":"10.1145\/227699.227700"},{"key":"S0956796810000171_ref58","unstructured":"Peyton Jones, S. , Vytiniotis D. , Weirich S. & Washburn G. (2006) Simple unification-based type inference for GADTs. In International Conference on Functional Programming, pp. 50\u201361."},{"key":"S0956796810000171_ref7","doi-asserted-by":"crossref","unstructured":"Cook W. R. (1989) A denotational Semantics of Inheritance. Ph.D. thesis, Brown University.","DOI":"10.1145\/74877.74922"},{"key":"S0956796810000171_ref47","unstructured":"Odersky M. & L\u00e4ufer K. (1996) Putting type annotations to work. In Principles of Programming Languages, pp. 54\u201367."},{"key":"S0956796810000171_ref46","unstructured":"Odersky M. (May 2007b) The Scala Language Specification, version 2.4 [online]. Available at: http:\/\/scala.epfl.ch\/docu\/files\/ScalaReference.pdf"},{"key":"S0956796810000171_ref40","unstructured":"Moors A. (June 2007) Code-follows-type Programming in Scala [online]. Available at: http:\/\/www.cs.kuleuven.be\/~adriaan\/?q=cft_intro"},{"key":"S0956796810000171_ref38","doi-asserted-by":"publisher","DOI":"10.1007\/3540543961_7"},{"key":"S0956796810000171_ref16","doi-asserted-by":"crossref","unstructured":"Harper R. & Lillibridge M. (January 1994) A type-theoretic approach to higher-order modules with sharing. In Principles of Programming Languages, pp. 123\u2013137.","DOI":"10.1145\/174675.176927"},{"key":"S0956796810000171_ref2","doi-asserted-by":"publisher","DOI":"10.1145\/1596638.1596652"},{"key":"S0956796810000171_ref3","doi-asserted-by":"crossref","first-page":"221","DOI":"10.1002\/j.1096-9942.1995.tb00019.x","article-title":"The Hopkins Object Group","volume":"1","author":"Bruce","year":"1995","journal-title":"Theory Pract. Object Syst."},{"key":"S0956796810000171_ref4","doi-asserted-by":"publisher","DOI":"10.1016\/j.entcs.2005.11.061"},{"key":"S0956796810000171_ref5","doi-asserted-by":"crossref","first-page":"90","DOI":"10.1145\/581690.581698","volume-title":"Haskell Workshop","author":"Cheney","year":"2002"},{"key":"S0956796810000171_ref29","unstructured":"L\u00e4mmel R. & Peyton Jones, S. (2005) Scrap your boilerplate with class: Extensible generic functions. In International Conference on Functional Programming, pp. 204\u2013215."},{"key":"S0956796810000171_ref67","doi-asserted-by":"publisher","DOI":"10.1145\/1159842.1159844"},{"key":"S0956796810000171_ref8","unstructured":"Dijkstra A. & Swierstra S. D. (2005) Making Implicit Parameters Explicit. Tech. rept. UU-CS-2005-032. Department of Information and Computing Sciences, Utrecht University."},{"key":"S0956796810000171_ref59","doi-asserted-by":"crossref","unstructured":"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 Symposium.","DOI":"10.1145\/1411286.1411301"},{"key":"S0956796810000171_ref10","doi-asserted-by":"publisher","DOI":"10.1007\/978-1-349-91518-7_3"},{"key":"S0956796810000171_ref11","doi-asserted-by":"crossref","unstructured":"Gibbons J. (2006) Design patterns as higher-order datatype-generic programs. In Workshop on Generic Programming, pp. 1\u201312.","DOI":"10.1145\/1159861.1159863"},{"key":"S0956796810000171_ref13","doi-asserted-by":"publisher","DOI":"10.1017\/S0956796809007291"},{"key":"S0956796810000171_ref18","first-page":"2","volume-title":"LNCS 1837: Proceedings of the Fifth International Conference on Mathematics of Program Construction","author":"Hinze","year":"2000"},{"key":"S0956796810000171_ref14","first-page":"85","volume-title":"Workshop on Generic Programming","author":"Gibbons","year":"2009"},{"key":"S0956796810000171_ref55","unstructured":"Oliveira B. C. D. S. & Sulzmann M. (April 2008) Objects to Unify Type Classes and GADTs [online]. Available at: http:\/\/www.comlab.ox.ac.uk\/people\/Bruno.Oliveira\/objects.pdf"},{"key":"S0956796810000171_ref19","volume-title":"The Fun of Programming","author":"Hinze","year":"2003"},{"key":"S0956796810000171_ref20","doi-asserted-by":"publisher","DOI":"10.1017\/S0956796806006022"},{"key":"S0956796810000171_ref42","doi-asserted-by":"crossref","unstructured":"Moors A. , Piessens F. & Odersky M. (2008) Generics of a higher kind, Object-Oriented Program. Syst. Lang. Appl.","DOI":"10.1145\/1449764.1449798"},{"key":"S0956796810000171_ref9","volume-title":"Design Patterns: Elements of Reusable Object-Oriented Software","author":"Gamma","year":"1995"},{"key":"S0956796810000171_ref23","doi-asserted-by":"publisher","DOI":"10.1016\/j.scico.2007.10.006"},{"key":"S0956796810000171_ref28","unstructured":"L\u00e4mmel R. & Peyton Jones, S. (2003) Scrap your boilerplate: A practical design pattern for generic programming. In Types in Language Design and Implementation, pp. 26\u201337."},{"key":"S0956796810000171_ref26","unstructured":"Jansson P. (May 2000) Functional Polytypic Programming. Ph.D. thesis, Computing Science, Chalmers University of Technology and G\u00f6teborg University, Sweden."},{"key":"S0956796810000171_ref17","first-page":"5","article-title":"Derivable type classes","volume":"41","author":"Hinze","year":"2000","journal-title":"Haskell Workshop: Electronic Notes in Theoretical Computer Science"},{"key":"S0956796810000171_ref27","first-page":"77","volume-title":"Haskell Workshop","author":"Kahl","year":"2001"},{"key":"S0956796810000171_ref31","doi-asserted-by":"crossref","unstructured":"Leroy X. (1994) Manifest types, modules and separate compilation. In Principles of Programming Languages, pp. 109\u2013122.","DOI":"10.1145\/174675.176926"},{"key":"S0956796810000171_ref32","volume-title":"Adaptive Object-Oriented Software: The Demeter Method with Propagation Patterns","author":"Lieberherr","year":"1996"},{"key":"S0956796810000171_ref33","unstructured":"L\u00f6h A. (2004) Exploring Generic Haskell. Ph.D. thesis, Utrecht University."},{"key":"S0956796810000171_ref34","doi-asserted-by":"crossref","unstructured":"L\u00f6h A. & Hinze R. (2006) Open data types and open functions. In Principles and Practice of Declarative Programming, pp. 133\u2013144.","DOI":"10.1145\/1140335.1140352"},{"key":"S0956796810000171_ref37","volume-title":"LNCS 925: Advanced Functional Programming","author":"Meijer","year":"1995"},{"key":"S0956796810000171_ref44","unstructured":"Odersky M. (July 2006b) Poor Man's Type Classes [online]. Available at: http:\/\/lamp.epfl.ch\/~odersky\/talks\/wg2.8-boston06.pdf"},{"key":"S0956796810000171_ref45","unstructured":"Odersky M. (May 2007a) Scala by Example [online]. Available at: http:\/\/scala.epfl.ch\/docu\/files\/ScalaIntro.pdf"},{"key":"S0956796810000171_ref52","unstructured":"Oliveira B. C. D. S. (2007) Genericity, Extensibility and Type-Safety in the Visitor Pattern. DPhil thesis, University of Oxford."},{"key":"S0956796810000171_ref56","unstructured":"Oliveira B. C. D. S. , Hinze R. & L\u00f6h A. (April 2006) Extensible and modular generics for the masses. In Trends in Functional Programming, pp. 109\u2013138."},{"key":"S0956796810000171_ref61","unstructured":"Schinz M. (May 2007) A Scala Tutorial for Java Programmers [online]. Available at: http:\/\/scala.epfl.ch\/docu\/files\/ScalaTutorial.pdf"},{"key":"S0956796810000171_ref62","doi-asserted-by":"crossref","unstructured":"Sheard T. & Peyton Jones S. (2002) Template meta-programming for Haskell. In Haskell Workshop.","DOI":"10.1145\/581690.581691"},{"key":"S0956796810000171_ref66","unstructured":"Washburn G. (May 2008) Revisiting Higher-Rank Impredicative Polymorphism in Scala [online]. Available at: http:\/\/existentialtype.net\/2008\/05\/26\/revisiting-higher-rank-impredicat%ive-polymorphism-in-scala\/"}],"container-title":["Journal of Functional Programming"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/www.cambridge.org\/core\/services\/aop-cambridge-core\/content\/view\/S0956796810000171","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2026,5,26]],"date-time":"2026-05-26T22:35:59Z","timestamp":1779834959000},"score":1,"resource":{"primary":{"URL":"https:\/\/www.cambridge.org\/core\/product\/identifier\/S0956796810000171\/type\/journal_article"}},"subtitle":["Comparing Haskell and Scala support for generic programming"],"short-title":[],"issued":{"date-parts":[[2010,7]]},"references-count":67,"journal-issue":{"issue":"3-4","published-print":{"date-parts":[[2010,7]]}},"alternative-id":["S0956796810000171"],"URL":"https:\/\/doi.org\/10.1017\/s0956796810000171","relation":{},"ISSN":["0956-7968","1469-7653"],"issn-type":[{"value":"0956-7968","type":"print"},{"value":"1469-7653","type":"electronic"}],"subject":[],"published":{"date-parts":[[2010,7]]}}}