skip to main content
short-paper

Experience report: type-checking polymorphic units for astrophysics research in Haskell

Published:03 September 2014Publication History
Skip Abstract Section

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.

References

  1. Bureau International des Poids et Mesures. International vocabulary of metrology: Basic and general concepts and associated terms. JCGM, pages 1--91, 2012.Google ScholarGoogle Scholar
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle Scholar
  4. R. A. Eisenberg and S. Weirich. Dependently typed programming with singletons. In Haskell Symposium '12, pages 117--130, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. P. Guo and S. McCamant. Annotation-less unit type inference for C. Final Project, 6.883: Program Analysis, 2005.Google ScholarGoogle Scholar
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. A. Kennedy. Programming Languages and Dimensions. PhD thesis, University of Cambridge, 1996.Google ScholarGoogle Scholar
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. G. Mainland and G. Morrisett. Nikola: Embedding compiled GPU functions in Haskell. SIGPLAN Not., 45 (11): 67--78, Sept. 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarCross RefCross Ref
  13. T. Muranushi. Paraiso: an automated tuning framework for explicit solvers of partial differential equations. Computational Science & Discovery, 5 (1): 015003, 2012.Google ScholarGoogle ScholarCross RefCross Ref
  14. 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 ScholarGoogle Scholar
  15. W. H. Nelson. The Gimli glider. Soaring Magazine, 1997.Google ScholarGoogle Scholar
  16. P. Roy and N. Shankar. Simcheck: An expressive type system for simulink. In NASA Formal Methods, pages 149--160, 2010.Google ScholarGoogle Scholar
  17. 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 ScholarGoogle Scholar
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Experience report: type-checking polymorphic units for astrophysics research in Haskell

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 49, Issue 12
          Haskell '14
          December 2014
          141 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2775050
          • Editor:
          • Andy Gill
          Issue’s Table of Contents
          • cover image ACM Conferences
            Haskell '14: Proceedings of the 2014 ACM SIGPLAN symposium on Haskell
            September 2014
            154 pages
            ISBN:9781450330411
            DOI:10.1145/2633357

          Copyright © 2014 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 3 September 2014

          Check for updates

          Qualifiers

          • short-paper

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!