Skip to main content

Lightweight Higher-Kinded Polymorphism

  • Conference paper

Part of the Lecture Notes in Computer Science book series (LNTCS,volume 8475)

Abstract

Higher-kinded polymorphism —i.e. abstraction over type constructors— is an essential component of many functional programming techniques such as monads, folds, and embedded DSLs. ML-family languages typically support a form of abstraction over type constructors using functors, but the separation between the core language and the module language leads to awkwardness as functors proliferate.

We show how to express higher-kinded polymorphism in OCaml without functors, using an abstract type app to represent type application, and opaque brands to denote abstractable type constructors. We demonstrate the flexibility of our approach by using it to translate a variety of standard higher-kinded programs into functor-free OCaml code.

Keywords

  • Type Expression
  • Type Constructor
  • Abstract Type
  • Core Language
  • Constructor Class

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

This is a preview of subscription content, access via your institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • DOI: 10.1007/978-3-319-07151-0_8
  • Chapter length: 17 pages
  • Instant PDF download
  • Readable on all devices
  • Own it forever
  • Exclusive offer for individuals only
  • Tax calculation will be finalised during checkout
eBook
USD   54.99
Price excludes VAT (USA)
  • ISBN: 978-3-319-07151-0
  • Instant PDF download
  • Readable on all devices
  • Own it forever
  • Exclusive offer for individuals only
  • Tax calculation will be finalised during checkout
Softcover Book
USD   69.99
Price excludes VAT (USA)

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Baars, A.I., Swierstra, S.D.: Typing dynamic typing. In: ICFP 2002, pp. 157–166. ACM, New York (2002), ISBN 1-58113-487-8

    Google Scholar 

  2. Chambart, P., Henry, G.: Experiments in generic programming: runtime type representation and implicit values. In: OCaml Users and Developers Workshop (2012)

    Google Scholar 

  3. Hinze, R.: Efficient generalized folds. In: Jeuring, J. (ed.) Proceedings of the 2nd Workshop on Generic Programming, Ponte de Lima, Portugal, pp. 1–16 (July 2000)

    Google Scholar 

  4. Hudak, P., Hughes, J., Peyton Jones, S., Wadler, P.: A history of Haskell: Being lazy with class. In: Proceedings of the Third ACM SIGPLAN Conference on History of Programming Languages, HOPL III, pp. 12–1–12–55. ACM, New York (2007) ISBN 978-1-59593-766-7

    Google Scholar 

  5. Hughes, J.: Generalising monads to arrows. Science of Computer Programming 37(13), 67–111 (2000) ISSN 0167-6423

    Google Scholar 

  6. Jeltsch, W.: Generic record combinators with static type checking. In: Proceedings of the 12th International ACM SIGPLAN Symposium on Principles and Practice of Declarative Programming, pp. 143–154. ACM (2010)

    Google Scholar 

  7. Jones, M.P.: A system of constructor classes: overloading and implicit higher-order polymorphism. Journal of Functional Programming 5, 1–35 (1995) ISSN 1469-7653

    Google Scholar 

  8. Kiselyov, O., Shan, C.-C.: Lightweight static capabilities. Electron. Notes Theor. Comput. Sci. 174(7), 79–104 (2007) ISSN 1571-0661

    Google Scholar 

  9. Kiselyov, O., Lämmel, R., Schupke, K.: Strongly typed heterogeneous collections. In: Proceedings of the 2004 ACM SIGPLAN Workshop on Haskell, pp. 96–107. ACM (2004)

    Google Scholar 

  10. Leroy, X.: Applicative functors and fully transparent higher-order modules. In: Proceedings of the 22Nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 1995, pp. 142–153. ACM, New York (1995) ISBN 0-89791-692-1, http://doi.acm.org/10.1145/199448.199476 , doi:10.1145/199448.199476

  11. Löh, A., Hinze, R.: Open data types and open functions. In: Proceedings of the 8th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming, PPDP 2006, pp. 133–144. ACM, New York (2006) ISBN 1-59593-388-3

    Google Scholar 

  12. McBride, C., Paterson, R.: Applicative programming with effects. J. Funct. Program. 18(1), 1–13 (2008) ISSN 0956-7968

    Google Scholar 

  13. Pottier, F., Gauthier, N.: Polymorphic typed defunctionalization. In: Proceedings of the 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2004, pp. 89–98. ACM, New York (2004) ISBN 1-58113-729-X

    Google Scholar 

  14. Reynolds, J.C.: Definitional interpreters for higher-order programming languages. In: Proceedings of the ACM Annual Conference, ACM 1972, vol. 2, pp. 717–740. ACM, New York (1972)

    Google Scholar 

  15. Schrijvers, T., Peyton Jones, S., Chakravarty, M., Sulzmann, M.: Type checking with open type functions. In: Proceedings of the 13th ACM SIGPLAN International Conference on Functional Programming, ICFP 2008, pp. 51–62. ACM, New York (2008) ISBN 978-1-59593-919-7

    Google Scholar 

  16. Swamy, N., Guts, N., Leijen, D., Hicks, M.: Lightweight monadic programming in ML. In: Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming, ICFP 2011, pp. 15–27. ACM, New York (2011) ISBN 978-1-4503-0865-6

    Google Scholar 

  17. Voigtländer, J.: Asymptotic improvement of computations over free monads. In: Audebaud, P., Paulin-Mohring, C. (eds.) MPC 2008. LNCS, vol. 5133, pp. 388–403. Springer, Heidelberg (2008)

    CrossRef  Google Scholar 

  18. Wadler, P., Blott, S.: 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, pp. 60–76. ACM, New York (1989) ISBN 0-89791-294-2

    Google Scholar 

  19. Yallop, J., Kiselyov, O.: First-class modules: hidden power and tantalizing promises. In: ACM SIGPLAN Workshop on ML, Baltimore, Maryland, United States (September 2010)

    Google Scholar 

  20. Yorgey, B.A., Weirich, S., Cretin, J., Peyton Jones, S., Vytiniotis, D., Magalhães, J.P.: Giving Haskell a promotion. In: Proceedings of the 8th ACM SIGPLAN Workshop on Types in Language Design and Implementation, TLDI 2012, pp. 53–66. ACM, New York (2012) ISBN 978-1-4503-1120-5

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and Permissions

Copyright information

© 2014 Springer International Publishing Switzerland

About this paper

Cite this paper

Yallop, J., White, L. (2014). Lightweight Higher-Kinded Polymorphism. In: Codish, M., Sumii, E. (eds) Functional and Logic Programming. FLOPS 2014. Lecture Notes in Computer Science, vol 8475. Springer, Cham. https://doi.org/10.1007/978-3-319-07151-0_8

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-07151-0_8

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-07150-3

  • Online ISBN: 978-3-319-07151-0

  • eBook Packages: Computer ScienceComputer Science (R0)