Abstract
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.
Chapter PDF
Similar content being viewed by others
Keywords
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.
References
F. Baader. Unification in commutative theories. Journal of Symbolic Computation, 8:479–497, 1989.
G. Baldwin. Implementation of physical units. SIGPLAN Notices, 22(8):45–50, August 1987.
L. Cardelli. Basic polymorphic typechecking. Science of Computer Programming, 8(2):147–172, 1987.
L. Damas. Type Assignment in Programming Languages. PhD thesis, Department of Computer Science, University of Edinburgh, 1985.
A. Dreiheller, M. Moerschbacher, and B. Mohr. PHYSCAL-programming Pascal with physical units. SIGPLAN Notices, 21(12):114–123, December 1986.
N. H. Gehani. Ada's derived types and units of measure. Software—Practice and Experience, 15(6):555–569, June 1985.
F. Henglein. Type inference with polymorphic recursion. ACM Transactions on Programming Languages and Systems, April 1993.
R. T. House. A proposal for an extended form of type checking of expressions. The Computer Journal, 26(4):366–374, 1983.
M. Karr and D. B. Loveman III. Incorporation of units into programming languages. Communications of the ACM, 21(5):385–391, May 1978.
D. Knuth. The Art of Computer Programming, Vol. 2, pages 303–304. Addison-Wesley, 1969.
A. J. Kfoury, J. Tiuryn, and P. Urzyczyn. Type reconstruction in the presence of polymorphic recursion. ACM Transactions on Programming Languages and Systems, April 1993.
H. L. Langhaar. Dimensional Analysis and Theory of Models. John Wiley and Sons, 1951.
D. Lankford, G. Butler, and B. Brady. Abelian group unification algorithms for elementary terms. Contemporary Mathematics, 29:193–199, 1984.
D. Leivant. Polymorphic type inference. In ACM Symposium on Principles of Programming Languages, 1983.
R. Männer. Strong typing and physical units. SIGPLAN Notices, 21(3):11–20, March 1986.
R. Mankin. letter. SIGPLAN Notices, 22(3):13, March 1987.
R. Milner, M. Tofte, and R. Harper. The Definition of Standard ML. MIT Press, Cambridge, Mass., 1989.
W. Nutt. Unification in monoidal theories. In 10th International Conference on Automated Deduction, volume 449 of Lecture Notes in Computer Science, pages 618–632. Springer-Verlag, July 1990.
L. C. Paulson. ML for the Working Programmer. Cambridge University Press, 1991.
N. Rothwell. Miscellaneous design issues in the ML Kit. Technical Report ECS-LFCS-92-237, Laboratory for Foundations of Computer Science, University of Edinburgh, 1992.
M. Wand and P. M. O'Keefe. Automatic dimensional inference. In J.-L. Lassez and G. Plotkin, editors, Computational Logic: Essays in Honor of Alan Robinson. MIT Press, 1991.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1994 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Kennedy, A. (1994). Dimension types. In: Sannella, D. (eds) Programming Languages and Systems — ESOP '94. ESOP 1994. Lecture Notes in Computer Science, vol 788. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-57880-3_23
Download citation
DOI: https://doi.org/10.1007/3-540-57880-3_23
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-57880-2
Online ISBN: 978-3-540-48376-2
eBook Packages: Springer Book Archive