ACM Home Page
Please provide us with feedback. Feedback
Types for units-of-measure in f#: invited talk
Full text PdfPdf (155 KB)
Source
International Conference on Functional Programming archive
Proceedings of the 2008 ACM SIGPLAN workshop on ML table of contents
Victoria, BC, Canada
Pages 1-2  
Year of Publication: 2008
ISBN:978-1-60558-062-3
Author
Andrew Kennedy  Microsoft Research Cambridge, Cambridge, United Kingdom
Sponsors
SIGPLAN: ACM Special Interest Group on Programming Languages
ACM: Association for Computing Machinery
Publisher
ACM  New York, NY, USA
Bibliometrics
Downloads (6 Weeks): 1,   Downloads (12 Months): 30,   Citation Count: 0
Additional Information:

abstract   index terms   collaborative colleagues  

Tools and Actions: Request Permissions Request Permissions    Review this Article  
DOI Bookmark: Use this link to bookmark this Article: http://doi.acm.org/10.1145/1411304.1411305
What is a DOI?

ABSTRACT

Bugs caused by units-of-measure errors can have catastrophic consequences, the most famous of which was the loss in September 1999 of NASA's Mars Climate Orbiter probe, caused by a confusion between newtons (the SI unit of force) and lbf (the Imperial unit of force).

This talk will describe support for static checking and inference of units-of-measure in the F# programming language. From the programmer's perspective, the feature is not intrusive. Numeric constants are annotated with their units, user-defined types may be parameterized on units, and the compiler does the rest, flowing unit-of-measure information through to inferred types. Behind the scenes, there are a number of technical subtleties. The type inference algorithm achieves principal types through the use of (a) Abelian group unification and (b) a change-of-basis procedure when inferring polymorphic types for let-bound variables. Type schemes are presented to the programmer in a consistent style that is related to the Hermite normal form from linear algebra. In addition, there are a number of interesting interactions with F#'s support for object-oriented programming.

The talk will of course include a demonstration, and also a selection of case studies in the domains of machine learning, games programming, physics simulation, and finance.