Abstract
Generic programming (GP) is an increasingly important trend in programming languages. Well-known GP mechanisms, such as type classes and the C++0x concepts proposal, usually combine two features: 1) a special type of interfaces; and 2) implicit instantiation of implementations of those interfaces.
Scala implicits are a GP language mechanism, inspired by type classes, that break with the tradition of coupling implicit instantiation with a special type of interface. Instead, implicits provide only implicit instantiation, which is generalized to work for any types. This turns out to be quite powerful and useful to address many limitations that show up in other GP mechanisms.
This paper synthesizes the key ideas of implicits formally in a minimal and general core calculus called the implicit calculus (λ⇒), and it shows how to build source languages supporting implicit instantiation on top of it. A novelty of the calculus is its support for partial resolution and higher-order rules (a feature that has been proposed before, but was never formalized or implemented). Ultimately, the implicit calculus provides a formal model of implicits, which can be used by language designers to study and inform implementations of similar mechanisms in their own languages.
- The Boost C++ libraries. http://www.boost.org/, 2010.Google Scholar
- C. Camarão and L. Figueiredo. Type inference for overloading without restrictions, declarations or annotations. In FLOPS, 1999.Google Scholar
Cross Ref
- M. Chakravarty, G. Keller, and S. L. Peyton Jones. Associated type synonyms. In ICFP, 2005. Google Scholar
Digital Library
- M. Chakravarty, G. Keller, S. L. Peyton Jones, and S. Marlow. Associated types with class. In POPL, 2005. Google Scholar
Digital Library
- D. Devriese and F. Piessens. On the bright side of type classes: Instance arguments in agda. In ICFP, 2011. Google Scholar
Digital Library
- A. Dijkstra and S. D. Swierstra. Making implicit parameters explicit. Technical report, Utrecht University, 2005.Google Scholar
- G. Dos Reis and B. Stroustrup. Specifying C++ concepts. In POPL '06, pages 295--308, 2006. Google Scholar
Digital Library
- D. Dreyer, R. Harper, M. Chakravarty, and G. Keller. Modular type classes. In POPL, 2007. Google Scholar
Digital Library
- R. Garcia, J. Jarvi, A. Lumsdaine, Jeremy Siek, and J. Willcock. A comparative study of language support for generic programming. In OOPSLA, 2003. Google Scholar
Digital Library
- J. Gibbons. Patterns in datatype-generic programming. In The Fun of Programming, Cornerstones in Computing. Palgrave, 2003.Google Scholar
- D. Gregor, J. Järvi, J. G. Siek, B. Stroustrup, G. Dos Reis, and A. Lumsdaine. Concepts: linguistic support for generic programming in c++. In OOPSLA, 2006. Google Scholar
Digital Library
- R. Hinze and S. L. Peyton Jones. Derivable type classes. Electronic Notes in Theoretical Computer Science, 41(1):5--35, 2001.Google Scholar
Cross Ref
- J. Hughes. Restricted data types in Haskell. In Haskell, 1999.Google Scholar
- P. Jansson and J. Jeuring. Polytypic programming. In AFP. Springer-Verlag, 1996. Google Scholar
Digital Library
- M. P. Jones. Simplifying and improving qualified types. In FPCA, 1995. Google Scholar
Digital Library
- M. P. Jones. Type classes with functional dependencies. In ESOP, 2000. Google Scholar
Digital Library
- S. L. Peyton Jones, M. P. Jones, and E. Meijer. Type classes: exploring the design space. In Haskell Workshop, 1997.Google Scholar
- W. Kahl and J. Scheffczyk. Named instances for Haskell type classes. In Haskell Workshop, 2001.Google Scholar
- R. Kowalski. Predicate logic as a programming language. In Proceedings of IFIP Congress, 1974.Google Scholar
- R. Kowalski, Donald, and Kuehner. Linear resolution with selection function. Artificial Intelligence, 2, 1971.Google Scholar
- R. Lämmel and S. L. Peyton Jones. Scrap your boilerplate with class: extensible generic functions. In ICFP, 2005.Google Scholar
Digital Library
- J. Lewis, J. Launchbury, E. Meijer, and M. Shields. Implicit parameters: dynamic scoping with static types. In POPL, 2000. Google Scholar
Digital Library
- D. Musser and A. Stepanov. Generic programming. In Symbolic and algebraic computation: ISSAC 88, pages 13--25. Springer, 1988. Google Scholar
Digital Library
- D. R. Musser and A. Saini. The STL Tutorial and Reference Guide: C++ Programming with the Standard Template Library. Addison Wesley Longman Publishing Co., Inc., 1995. Google Scholar
Digital Library
- M. Neubauer, P. Thiemann, M. Gasbichler, and M. Sperber. Functional logic overloading. In POPL, 2002. Google Scholar
Digital Library
- M. Odersky. Poor man's type classes. http://lamp.epfl.ch/ odersky/talks/wg2.8-boston06.pdf, July 2006.Google Scholar
- M. Odersky. The Scala language specification, version 2.8 2010.Google Scholar
- B. C. d. S. Oliveira and J. Gibbons. Scala for generic programmers. Journal of Functional Programming, 20, 2010. Google Scholar
Digital Library
- B. C. d. S. Oliveira, A. Moors, and M. Odersky. Type classes as objects and implicits. In OOPSLA, 2010. Google Scholar
Digital Library
- B. C. d. S. Oliveira, T. Schrijvers, W. Choi, W. Lee, and K. Yi. Extended report: The implicit calculus. http://arxiv.org/abs/1203.4499, 2012.Google Scholar
- A. Rodriguez, J. Jeuring, P. Jansson, A. Gerdes, O. Kiselyov, and B. C. d. S. Oliveira. Comparing libraries for generic programming in haskell. In Haskell, 2008. Google Scholar
Digital Library
- T. Schrijvers, S. L. Peyton Jones, M. Chakravarty, and M. Sulzmann. Type checking with open type functions. In ICFP, 2008. Google Scholar
Digital Library
- T. Schrijvers, S. L. Peyton Jones, M. Sulzmann, and D. Vytiniotis. Complete and decidable type inference for GADTs. In ICFP, 2009. Google Scholar
Digital Library
- J. Siek. The C++0x Concepts Effort. http://ecee.colorado. edu/~siek/concepts_effort.pdf, 2011.Google Scholar
- J. G. Siek and A. Lumsdaine. Essential language support for generic programming. In PLDI, 2005. Google Scholar
Digital Library
- J. G. Siek and A. Lumsdaine. A language for generic programming in the large. Science of Computer Programming, 76(5), 2011. Google Scholar
Digital Library
- M. Sozeau and N. Oury. First-class type classes. In TPHOLs, 2008. Google Scholar
Digital Library
- B. Stroustrup. Simplifying the use of concepts. Technical report, Technical Report N2906, ISO/IEC JTC 1 SC22 WG21, 2009.Google Scholar
- P. J. Stuckey and M. Sulzmann. A theory of overloading. In ICFP, 2002. Google Scholar
Digital Library
- V. Trifonov. Simulating quantified class constraints. In Haskell, 2003. Google Scholar
Digital Library
- D. Vytiniotis, S. L. Peyton Jones, T. Schrijvers, and M. Sulzmann. OUTSIDEIN(x): Modular type inference with local assumptions. Journal of Functional Programming, 21(4--5):333--412, 2011. Google Scholar
Digital Library
- P. L.Wadler and S. Blott. How to make ad-hoc polymorphism less ad hoc. In POPL, 1989. Google Scholar
Digital Library
Index Terms
The implicit calculus: a new foundation for generic programming
Recommendations
Type classes as objects and implicits
OOPSLA '10Type classes were originally developed in Haskell as a disciplined alternative to ad-hoc polymorphism. Type classes have been shown to provide a type-safe solution to important challenges in software engineering and programming languages such as, for ...
The implicit calculus: a new foundation for generic programming
PLDI '12: Proceedings of the 33rd ACM SIGPLAN Conference on Programming Language Design and ImplementationGeneric programming (GP) is an increasingly important trend in programming languages. Well-known GP mechanisms, such as type classes and the C++0x concepts proposal, usually combine two features: 1) a special type of interfaces; and 2) implicit ...
Type classes as objects and implicits
OOPSLA '10: Proceedings of the ACM international conference on Object oriented programming systems languages and applicationsType classes were originally developed in Haskell as a disciplined alternative to ad-hoc polymorphism. Type classes have been shown to provide a type-safe solution to important challenges in software engineering and programming languages such as, for ...







Comments