Dimension Types

Scientists and engineers must ensure that physical equations are dimensionally consistent, but existing programming languages treat all numeric values as dimensionless. This paper extends a strongly-typed programming language with a notion of dimension type. Our approach improves on previous proposals in that dimension types may be polymorphic. Furthermore, any expression which is typable in the system has a most general type, and we describe an algorithm which infers this type automatically. The algorithm exploits equational unification over Abelian groups in addition to ordinary term unification. An implementation of the type system is described, extending the ML Kit compiler. Finally, we discuss the problem of obtaining a canonical form for principal types and sketch some more powerful systems which use dependent and higher-order polymorphic types.

[1]  David B. Loveman,et al.  Incorporation of units into programming languages , 1978, CACM.

[2]  Luís Damas Type assignment in programming languages , 1984 .

[3]  Erik G. Urdang Book Review: The T Programming Language: A Dialect of Lisp by Stephen Slade, Prentice Hall, Inc. 1987 , 1987, SIGP.

[4]  Luca Cardelli,et al.  Basic Polymorphic Typechecking , 1987, Sci. Comput. Program..

[5]  A Dreiheller,et al.  Programming pascal with physical units , 1986, SIGP.

[6]  H. Langhaar Dimensional analysis and theory of models , 1951 .

[7]  Werner Nutt,et al.  Unification in Monoidal Theories , 1990, CADE.

[8]  Geoff Baldwin Implementation of physical units , 1987, SIGP.

[9]  Robin Milner,et al.  Definition of standard ML , 1990 .

[10]  Daniel Leivant,et al.  Polymorphic type inference , 1983, POPL '83.

[11]  Fritz Henglein,et al.  Type inference with polymorphic recursion , 1993, TOPL.

[12]  R. Männer,et al.  Strong typing and physical units , 1986, SIGP.

[13]  Ronald T. House A Proposal for an Extended Form of Type Checking of Expressions , 1983, Comput. J..

[14]  Franz Baader,et al.  Unification in Commutative Theories , 1989, J. Symb. Comput..

[15]  Mitchell Wand,et al.  Automatic Dimensional Inference , 1991, Computational Logic - Essays in Honor of Alan Robinson.

[16]  Narain H. Gehani Ada's derived types and units of measure , 1985, Softw. Pract. Exp..

[17]  Jerzy Tiuryn,et al.  Type reconstruction in the presence of polymorphic recursion , 1993, TOPL.

[18]  Dallas Lankford,et al.  Abelian group unification algorithms for elementary terms , 1984 .