dimensional-1.0.1.3: Statically checked physical dimensions, using Type Families and Data Kinds.

Copyright | Copyright (C) 2006-2014 Bjorn Buckwalter
License | BSD3
Maintainer | bjorn@buckwalter.se
Stability | Stable
Portability | GHC only?
Safe Haskell | None
Language | Haskell2010

Numeric.Units.Dimensional.Dynamic

Contents

- Dynamic Quantities
- Dynamic Units

Description

Defines types for manipulation of units and quantities without phantom types for their dimensions.

Synopsis

- data AnyQuantity v
- demoteQuantity :: forall d v. KnownDimension d => Quantity d v -> AnyQuantity v
- promoteQuantity :: forall d v. KnownDimension d => AnyQuantity v -> Maybe (Quantity d v)
- data AnyUnit
- demoteUnit :: forall a d v. KnownDimension d => Unit a d v -> AnyUnit
- promoteUnit :: forall d. KnownDimension d => AnyUnit -> Maybe (Unit NonMetric d ExactPi)

# Dynamic Quantities

data AnyQuantity v Source #

A `Quantity` whose `Dimension` is only known dynamically.

Instances

Eq v => Eq (AnyQuantity v) Source # |
Methods (==) :: AnyQuantity v -> AnyQuantity v -> Bool # (/=) :: AnyQuantity v -> AnyQuantity v -> Bool #
Show v => Show (AnyQuantity v) Source # |
Methods showsPrec :: Int -> AnyQuantity v -> ShowS # show :: AnyQuantity v -> String # showList :: [AnyQuantity v] -> ShowS #
HasDimension (AnyQuantity v) Source # |
Methods dimension :: AnyQuantity v -> Dimension' Source #

demoteQuantity :: forall d v. KnownDimension d => Quantity d v -> AnyQuantity v Source #

Converts a `Quantity` of statically known `Dimension` into an `AnyQuantity`.

promoteQuantity :: forall d v. KnownDimension d => AnyQuantity v -> Maybe (Quantity d v) Source #

Converts an `AnyQuantity` into a `Quantity` of statically known `Dimension`, or `Nothing` if the dimension does not match.

# Dynamic Units

data AnyUnit Source #

A `Unit` whose `Dimension` is only known dynamically.

Instances

Show AnyUnit Source # |
Methods showsPrec :: Int -> AnyUnit -> ShowS # show :: AnyUnit -> String # showList :: [AnyUnit] -> ShowS #
HasDimension AnyUnit Source # |
Methods dimension :: AnyUnit -> Dimension' Source #

demoteUnit :: forall a d v. KnownDimension d => Unit a d v -> AnyUnit Source #

Converts a `Unit` of statically known `Dimension` into an `AnyUnit`.

promoteUnit :: forall d. KnownDimension d => AnyUnit -> Maybe (Unit NonMetric d ExactPi) Source #

Converts an `AnyUnit` into a `Unit` of statically known `Dimension`, or `Nothing` if the dimension does not match.

The result is represented in `ExactPi`, conversion to other representations is possible using `changeRepApproximate`.