Author:
OLIVEIRA BRUNO C. D. S.,GIBBONS JEREMY
Abstract
AbstractDatatype-generic programming (DGP) involves parametrization of programs by the shape of data, in the form of type constructors such as ‘list of’. 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 ‘Generics for the Masses’, Lämmel and Peyton Jones's ‘Scrap your Boilerplate with Class’, and Gibbons's ‘Origami Programming’.
Publisher
Cambridge University Press (CUP)
Reference67 articles.
1. Cockett R. & Fukushima T. (May 1992) About Charity. Department of Computer Science, University of Calgary.
2. 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
3. Schärli 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–274.
4. TypeCase
5. Hinze R. & Löh A. (2007) Generic programming, now! LNCS 4719: Datatype-Generic Programming.
Cited by
9 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献