units-2.2.1: A domain-specific type system for dimensional analysis

Copyright(C) 2014 Richard Eisenberg
LicenseBSD-style (see LICENSE)
MaintainerRichard Eisenberg (eir@cis.upenn.edu)
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Metrology

Contents

Description

The units package is a framework for strongly-typed dimensional analysis. This haddock documentation is generally not enough to be able to use this package effectively. Please see the readme at https://github.com/goldfirere/units/blob/master/README.md.

Some of the types below refer to declarations that are not exported and not documented here. This is because Haddock does not allow finely-tuned abstraction in documentation. (In particular, right-hand sides of type synonym declarations are always included.) If a symbol is not exported, you do not need to know anything about it to use this package.

Though it doesn't appear here, Count is an instance of Num, and generally has all the numeric instances that Double has.

This module exports definitions that lack unit-polymorphism. If you wish to write more polymorphic code, see Poly. If you wish to use the numerical hierarchy from the vector-space package, see Vector.

Synopsis

Operators working with a default LCSU

numIn :: (ValidDLU dim DefaultLCSU unit, Fractional n) => Qu dim DefaultLCSU n -> unit -> n Source

Extracts a numerical value from a dimensioned quantity, expressed in the given unit. For example:

inMeters :: Length -> Double
inMeters x = numIn x Meter

or

inMeters x = x # Meter   

(#) :: (ValidDLU dim DefaultLCSU unit, Fractional n) => Qu dim DefaultLCSU n -> unit -> n infix 5 Source

Infix synonym for numIn

quOf :: (ValidDLU dim DefaultLCSU unit, Fractional n) => n -> unit -> Qu dim DefaultLCSU n Source

Creates a dimensioned quantity in the given unit. For example:

height :: Length
height = quOf 2.0 Meter

or

height = 2.0 % Meter

(%) :: (ValidDLU dim DefaultLCSU unit, Fractional n) => n -> unit -> Qu dim DefaultLCSU n infixr 9 Source

Infix synonym for quOf

type Count = MkQu_U Number Source

The type of unitless dimensioned quantities. This is an instance of Num, though Haddock doesn't show it. This assumes a default LCSU and an internal representation of Double.

The rest of the units package interface.

Though Haddock doesn't show it, the polymorphic versions of numIn, '#', quOf, %, and Count are not re-exported.