Abstract
Many of the bugs in scientific programs have their roots in mistreatment of physical dimensions, via erroneous expressions in the quantity calculus. Now that the type system in the Glasgow Haskell Compiler is rich enough to support type-level integers and other promoted datatypes, we can type-check the quantity calculus in Haskell. In addition to basic dimension-aware arithmetic and unit conversions, our units library features an extensible system of dimensions and units, a notion of dimensions apart from that of units, and unit polymorphism designed to describe the laws of physics. We demonstrate the utility of units by writing an astrophysics research paper. This work is free of unit concerns because every quantity expression in the paper is rigorously type-checked.
- Bureau International des Poids et Mesures. International vocabulary of metrology: Basic and general concepts and associated terms. JCGM, pages 1--91, 2012.Google Scholar
- M. M. T. Chakravarty, G. Keller, S. Lee, T. L. McDonell, and V. Grover. Accelerating Haskell array codes with multicore GPUs. In Declarative Aspects of Multicore Programming (DAMP '11), pages 3--14, 2011. Google Scholar
Digital Library
- T. Ebisuzaki, J. Makino, T. Fukushige, M. Taiji, D. Sugimoto, T. Ito, and S. K. Okumura. GRAPE Project: an Overview. Publications of the Astronomical Society of Japan, 45: 269--278, June 1993.Google Scholar
- R. A. Eisenberg and S. Weirich. Dependently typed programming with singletons. In Haskell Symposium '12, pages 117--130, 2012. Google Scholar
Digital Library
- R. A. Eisenberg, D. Vytiniotis, S. Peyton Jones, and S. Weirich. Closed type families with overlapping equations. In Principles of Programming Languages (POPL '14), pages 671--683, 2014. Google Scholar
Digital Library
- P. Guo and S. McCamant. Annotation-less unit type inference for C. Final Project, 6.883: Program Analysis, 2005.Google Scholar
- G. Keller, M. M. T. Chakravarty, R. Leshchinskiy, S. Peyton Jones, and B. Lippmeier. Regular, shape-polymorphic, parallel arrays in Haskell. In SIGPLAN Not., volume 45, pages 261--272. ACM, 2010. Google Scholar
Digital Library
- A. Kennedy. Programming Languages and Dimensions. PhD thesis, University of Cambridge, 1996.Google Scholar
- A. J. Kennedy. Types for units-of-measure: Theory and practice. In Z. Horváth, R. Plasmeijer, and V. Zsók, editors, Central European Functional Programming School, volume 6299 of Lecture Notes in Computer Science, pages 268--305. Springer, 2010. 10.1007/978-3-642-17685-2_8. Google Scholar
Digital Library
- B. Larsen. Simple optimizations for an applicative array language for graphics processors. In Declarative Aspects of Multicore Programming (DAMP '11), pages 25--34, 2011. Google Scholar
Digital Library
- G. Mainland and G. Morrisett. Nikola: Embedding compiled GPU functions in Haskell. SIGPLAN Not., 45 (11): 67--78, Sept. 2010. Google Scholar
Digital Library
- J. Makino, T. Fukushige, M. Koga, and K. Namura. GRAPE-6: Massively-Parallel Special-Purpose Computer for Astrophysical Particle Simulations. Publications of the Astronomical Society of Japan, 55: 1163--1187, Dec. 2003.Google Scholar
Cross Ref
- T. Muranushi. Paraiso: an automated tuning framework for explicit solvers of partial differential equations. Computational Science & Discovery, 5 (1): 015003, 2012.Google Scholar
Cross Ref
- T. Muranushi, E. Akiyama, S. Inutsuka, N. Hideko, and S. Okuzumi. Observation of lightning in protoplanetary disks by ion lines. The Astrophysical Journal, to be Submitted, 2014.Google Scholar
- W. H. Nelson. The Gimli glider. Soaring Magazine, 1997.Google Scholar
- P. Roy and N. Shankar. Simcheck: An expressive type system for simulink. In NASA Formal Methods, pages 149--160, 2010.Google Scholar
- A. G. Stephenson, D. R. Mulville, F. H. Bauer, G. A. Dukeman, P. Norvig, L. S. LaPiana, P. J. Rutledge, D. Folta, and R. Sackheim. Mars climate orbiter mishap investigation board Phase I report, 44 pp. NASA, Washington, DC, 1999.Google Scholar
- M. Sulzmann, G. J. Duck, S. Peyton-Jones, and P. J. Stuckey. Understanding functional dependencies via constraint handling rules. Journal of Functional Programming, 17: 83--129, 2007. Google Scholar
Digital Library
- J. Svensson, M. Sheeran, and K. Claessen. Obsidian: A domain specific embedded language for parallel programming of graphics processors. In Implementation and Application of Functional Languages (IFL '08), pages 156--173, 2011. Google Scholar
Digital Library
- B. A. Yorgey, S. Weirich, J. Cretin, S. Peyton Jones, D. Vytiniotis, and J. P. Magalhães. Giving Haskell a promotion. In Types in Language Design and Implementation (TLDI '12), pages 53--66, 2012. Google Scholar
Digital Library
Index Terms
Experience report: type-checking polymorphic units for astrophysics research in Haskell
Recommendations
Experience report: type-checking polymorphic units for astrophysics research in Haskell
Haskell '14: Proceedings of the 2014 ACM SIGPLAN symposium on HaskellMany of the bugs in scientific programs have their roots in mistreatment of physical dimensions, via erroneous expressions in the quantity calculus. Now that the type system in the Glasgow Haskell Compiler is rich enough to support type-level integers ...
Constrained type families
We present an approach to support partiality in type-level computation without compromising expressiveness or type safety. Existing frameworks for type-level computation either require totality or implicitly assume it. For example, type families in ...
Closed type families with overlapping equations
POPL '14Open, type-level functions are a recent innovation in Haskell that move Haskell towards the expressiveness of dependent types, while retaining the look and feel of a practical programming language. This paper shows how to increase expressiveness still ...







Comments