Experience report

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.

[1]  Toshikazu Ebisuzaki GRAPE project: an overview , 1993 .

[2]  J. Gregory Morrisett,et al.  Nikola: embedding compiled GPU functions in Haskell , 2010, Haskell '10.

[3]  Simon L. Peyton Jones,et al.  Regular, shape-polymorphic, parallel arrays in Haskell , 2010, ICFP '10.

[4]  Toshiyuki Fukushige,et al.  GRAPE-6: Massively-Parallel Special-Purpose Computer for Astrophysical Particle Simulations , 2003, astro-ph/0310702.

[5]  Andrew John Kennedy,et al.  Programming languages and dimensions , 1995 .

[6]  Simon L. Peyton Jones,et al.  Closed type families with overlapping equations , 2014, POPL.

[7]  Bo Joel Svensson,et al.  Obsidian: A Domain Specific Embedded Language for Parallel Programming of Graphics Processors , 2008, IFL.

[8]  Natarajan Shankar,et al.  SimCheck: An Expressive Type System for Simulink , 2010, NASA Formal Methods.

[9]  Simon L. Peyton Jones,et al.  Giving Haskell a promotion , 2012, TLDI '12.

[10]  Stephanie Weirich,et al.  Dependently typed programming with singletons , 2013, Haskell '12.

[11]  Shu-ichiro Inutsuka,et al.  DEVELOPMENT OF A METHOD FOR THE OBSERVATION OF LIGHTNING IN PROTOPLANETARY DISKS USING ION LINES , 2015, 1511.01199.

[12]  Manuel M. T. Chakravarty,et al.  Accelerating Haskell array codes with multicore GPUs , 2011, DAMP '11.

[13]  Shu-ichiro Inutsuka,et al.  Observation of Lightning in Protoplanetary Disks by Ion Lines , 2014 .

[14]  Bradford Larsen,et al.  Simple optimizations for an applicative array language for graphics processors , 2011, DAMP '11.

[15]  Andrew Kennedy,et al.  Types for Units-of-Measure: Theory and Practice , 2009, CEFP.

[16]  Stephen McCamant,et al.  Annotation-less Unit Type Inference for C , 2005 .

[17]  Simon L. Peyton Jones,et al.  Understanding functional dependencies via constraint handling rules , 2007, J. Funct. Program..

[18]  Takayuki Muranushi,et al.  Paraiso : An Automated Tuning Framework for Explicit Solvers of Partial Differential Equations , 2012, ArXiv.