HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulenumeric-prelude-0.4.4Haskell98

Number.Physical.Unit

Abstract Physical Units

  • 1 type
  • 7 values
typetype T i = Map i Int
#

A Unit.T is a sparse vector with integer entries Each map n->m means that the unit of the n-th dimension is given m times.

Example: Let the quantity of length (meter, m) be the zeroth dimension and let the quantity of time (second, s) be the first dimension, then the composed unit m/s^2 corresponds to the Map [(0,1),(1,-2)].

In future I want to have more abstraction here, e.g. a type class from the Edison project that abstracts from the underlying implementation. Then one can easily switch between Arrays, Binary trees (like Map) and what know I.

valuescalar :: T i
#

The neutral Unit.T

valuefromVector :: (Enum i, Ord i) => [Int] -> T i
#

Convert a List to sparse Map representation Example: [-1,0,-2] -> [(0,-1),(2,-2)]