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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Baars, A.I., Swierstra, S.D.: Typing dynamic typing. In: ICFP 2002, pp. 157–166. ACM, New York (2002), ISBN 1-58113-487-8
Chambart, P., Henry, G.: Experiments in generic programming: runtime type representation and implicit values. In: OCaml Users and Developers Workshop (2012)
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)
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
Hughes, J.: Generalising monads to arrows. Science of Computer Programming 37(13), 67–111 (2000) ISSN 0167-6423
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)
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
Kiselyov, O., Shan, C.-C.: Lightweight static capabilities. Electron. Notes Theor. Comput. Sci. 174(7), 79–104 (2007) ISSN 1571-0661
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)
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
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
McBride, C., Paterson, R.: Applicative programming with effects. J. Funct. Program. 18(1), 1–13 (2008) ISSN 0956-7968
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
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)
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
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
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)
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
Yallop, J., Kiselyov, O.: First-class modules: hidden power and tantalizing promises. In: ACM SIGPLAN Workshop on ML, Baltimore, Maryland, United States (September 2010)
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
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)