<div dir="ltr"><div>Hello Haskellers,<br>Björn Buckwalter and I are pleased to announce the release to Hackage of version 1.0 of the dimensional library, which statically tracks physical dimensions in Haskell code, as in the example below, preventing dimensional mistakes and requiring explicit documentation of units where raw values are exchanged with external systems.<br></div><blockquote><div><span style="font-family:monospace,monospace">{-# LANGUAGE NoImplicitPrelude #-}<br></span></div><div><span style="font-family:monospace,monospace">module Example where<br><br></span></div><div><span style="font-family:monospace,monospace">import Numeric.Units.Dimensional.Prelude<br></span></div><div><span style="font-family:monospace,monospace">import Numeric.Units.Dimensional.NonSI<br></span></div></blockquote><div><blockquote><pre><span style="font-family:monospace,monospace">-- a function that computes with dimensional values<br>escapeVelocity :: (Floating a) => Mass a -> Length a -> Velocity a
escapeVelocity m r = sqrt (two * g * m / r)
where
two = 2 *~ one
g = 6.6720e-11 *~ (newton * meter ^ pos2 / kilo gram ^ pos2)<br></span></pre></blockquote><blockquote><span style="font-family:monospace,monospace">>>> let re = <span class=""><code>6372.792 *~ kilo meter</code></span></span><br><span style="font-family:monospace,monospace"><span class=""><code></code></span><span class=""><code>>>> let me = 5.9742e24 *~ kilo gram</code></span></span><br><span style="font-family:monospace,monospace"><span class=""><code></code></span><span class=""><code><span class=""><code>>>> let ve = escapeVelocity me re</code></span></code></span></span><br><span style="font-family:monospace,monospace"><span class=""><code>>>> ve -- Show defaults to SI base units</code></span></span><br><span style="font-family:monospace,monospace"><span class=""><code>11184.537332296259 m s^-1</code></span></span><br><span style="font-family:monospace,monospace"><span class=""><code>>>> showIn (mile / hour) ve -- but we can show in other units</code></span></span><br><span style="font-family:monospace,monospace"><span class=""><code>"25019.09746845083 mi / h"</code></span></span><br><span style="font-family:monospace,monospace"><span class=""><code>>>> let vekph = ve /~ (kilo meter / hour) -- and extract raw values when needed</code></span></span><br><span style="font-family:monospace,monospace"><span class=""><code>40264.33439626653</code></span></span></blockquote><pre></pre></div><div>This
version is a major upgrade, consolidating features from the classic
dimensional package and the dimensional-tf package. It takes advantage
of the DataKinds and ClosedTypeFamilies extensions in GHC 7.8 to offer
even safer types with a nearly identical interface.<br><br>Also included:<br><ul><li>Units
carry names which can be combined by multiplication, division, and
(only where appropriate) application of metric prefixes. You can use
expressions like: showIn (milli meter / second) timeTravelSpeed to get
"39339.52 mm / s"</li><li>Exact conversion factors between units are
available, even when those conversion factors involve multiples of pi,
thanks to the exact-pi library</li><li>The dimensionally-polymorphic
siUnit term represents the coherent SI base unit of any dimension, which
can be convenient for wrapping and unwrapping quantities in some
contexts.<br></li><li>Storable and Unbox instances for Quantity types are available thanks to the efforts of <font size="2"><span style="font-weight:normal"><span>Alberto Valverde González.</span></span></font></li><li><font size="2"><span style="font-weight:normal"><span>The Numeric.Units.Dimensional.Dynamic
module offers types for safely manipulating quantities and units whose
dimensions are not known statically. Also available is a term-level
representation for dimensions.<br></span></span></font></li><li><font size="2"><span style="font-weight:normal"><span>Several other missing instances have been provided, including Bounded, Data, and Typeable instances.</span></span></font></li><li><font size="2"><span style="font-weight:normal"><span>New commonly used US customary units have been added, including US fluid measures and the knot.<br></span></span></font></li></ul><div><div><div><div><div>We
have several other development efforts underway, including a
type-checker plugin inspired by Adam Gundry's work, and on which he has
provided valuable advice, which we hope will lead to a clean library for
dimensionally typed linear algebra.<br><br></div><div>Comments and contributions are welcome at <a href="http://github.com/bjornbm/dimensional-dk" target="_blank">http://github.com/bjornbm/dimensional-dk</a>. (The repository name is a carryover from the name we were using while developing this version.)<br><br></div><div>One particularly welcome contribution would be assistance with developing a patch for <a href="https://ghc.haskell.org/trac/ghc/ticket/10391">GHC issue 10391</a>.<br></div><div><br></div><div>Cheers,<br></div><div>Doug McClean</div></div></div></div></div></div></div>