Ad-hoc polymorphism and dynamic typing in a statically typed functional language

Static typing in functional programming languages such as Clean, Haskell, and ML is highly beneficial: it prevents erroneous behaviour at run time and provides opportunities for optimisations. However, dynamic typing is just as important as sometimes types are not known until run time. Examples are exchanging values between applications by deserialisation from disk, input provided by a user, or obtaining values via a network connection. Ideally, a static typing system works in close harmony with an orthogonal dynamic typing system; not discriminating between statically and dynamically typed values. In contrast to Haskell's minimal support for dynamic typing, Clean has an extensive dynamic typing; it adopted ML's support for monomorphism and parametric polymorphism and added the notion of type dependencies. Unfortunately, ad-hoc polymorphism has been left out of the equation over the years. While both ad-hoc polymorphism and dynamic typing have been studied in-depth earlier, their interaction in a statically typed functional language has not been studied before. In this paper we explore the design space of their interactions.

[1]  Martin Odersky,et al.  Putting type annotations to work , 1996, POPL '96.

[2]  Marco Pil Dynamic Types and Type Dependent Functions , 1998, IFL.

[3]  Philip Wadler,et al.  How to make ad-hoc polymorphism less ad hoc , 1989, POPL '89.

[4]  Martín Abadi,et al.  Dynamic typing in polymorphic languages , 1995, Journal of Functional Programming.

[5]  James Cheney,et al.  A lightweight implementation of generics and dynamics , 2002, Haskell '02.

[6]  Martin Odersky,et al.  Polymorphic type inference and abstract data types , 1994, TOPL.

[7]  Stefan Kaes,et al.  Parametric Overloading in Polymorphic Programming Languages , 1988, ESOP.

[8]  François Rouaix,et al.  Safe run-time overloading , 1989, POPL '90.

[9]  Pieter Koopman,et al.  Exchanging sources between clean and Haskell: a double-edged front end for the clean compiler , 2010 .

[10]  Marinus J. Plasmeijer,et al.  A Functional Shell That Operates on Typed and Compiled Applications , 2004, Advanced Functional Programming.

[11]  Manuel M. T. Chakravarty,et al.  ML Modules and Haskell Type Classes: A Constructive Comparison , 2008, APLAS.

[12]  Peter Achten Clean for Haskell98 Programmers -- A Quick Reference Guide -- , 2007 .

[13]  Martín Abadi,et al.  Dynamic typing in a statically-typed language , 1989, POPL '89.

[14]  S. Doaitse Swierstra,et al.  Typing dynamic typing , 2002, ICFP '02.

[15]  Marinus J. Plasmeijer,et al.  Exchanging sources between clean and Haskell: a double-edged front end for the clean compiler , 2010, Haskell '10.

[16]  John Peterson,et al.  Implementing type classes , 1993, PLDI '93.

[17]  Simon L. Peyton Jones,et al.  Understanding functional dependencies via constraint handling rules , 2007, J. Funct. Program..

[18]  Simon Peyton Jones,et al.  Type classes: an exploration of the design space , 1997 .

[19]  Stephanie Weirich,et al.  An open and shut typecase , 2005, TLDI '05.

[20]  Marco Pil First Class File I/O , 1996, Implementation of Functional Languages.

[21]  Ronny Wichers Schreur,et al.  Dynamic Construction of Generic Functions , 2004, IFL.

[22]  Simon L. Peyton Jones,et al.  OutsideIn(X) Modular type inference with local assumptions , 2011, J. Funct. Program..

[23]  Xavier Leroy,et al.  Dynamics in ML , 1991, FPCA.

[24]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[25]  Peter Seibel,et al.  Simon Peyton Jones , 2009 .

[26]  Erik Meijer Dynamic typing when needed: The end of the cold war between programming languages , 2004 .

[27]  Simon L. Peyton Jones,et al.  Practical type inference for arbitrary-rank types , 2007, Journal of Functional Programming.

[28]  Simon L. Peyton Jones,et al.  Simple unification-based type inference for GADTs , 2006, ICFP '06.