Typing dynamic typing

  • Authors:
  • Arthur I. Baars;S. Doaitse Swierstra

  • Affiliations:
  • Utrecht University, Utrecht, The Netherlands;Utrecht University, Utrecht, The Netherlands

  • Venue:
  • Proceedings of the seventh ACM SIGPLAN international conference on Functional programming
  • Year:
  • 2002

Quantified Score

Hi-index 0.01

Visualization

Abstract

Even when programming in a statically typed language we every now and then encounter statically untypable values; such values result from interpreting values or from communicating with the outside world. To cope with this problem most languages include some form of dynamic types. It may be that the core language has been explicitly extended with such a type, or that one is allowed to live dangerously by using functions like unsafeCoerce. We show how, by a careful use of existentially and universally quantified types, one may achievem the same effect, without extending the language with new or unsafe features. The techniques explained are universally applicable, provided the core language is expressive enough; this is the case for the common implementations of Haskell. The techniques are used in the description of a type checking compiler that, starting from an expression term, constructs a typed function representing the semantics of that expression. In this function the overhead associated with the type checking is only once being paid for; in this sense we have thus achieved static type checking.