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

CopyrightCopyright (C) 2006-2018 Bjorn Buckwalter
LicenseBSD3
Maintainerbjorn@buckwalter.se
StabilityExperimental
PortabilityGHC only?
Safe HaskellNone
LanguageHaskell2010

Numeric.Units.Dimensional.Coercion

Description

Re-exports the raw Quantity constructor from the Numeric.Units.Dimensional.Internal module, along with coerce, for convenience in converting between raw representations and dimensional values.

Note that use of these constructs requires the user to verify the dimensional safety of the conversion, because the coercion doesn't explicitly mention the unit of the representation. Note also that the Quantity constructor constructs a SQuantity which may have a scale factor other than One.

Note that the haddock documentation doesn't mention the Quantity constructor because it is a part of the Dimensional associated data family, but it is exported by this module.

Synopsis

Documentation

coerce :: Coercible * a b => a -> b #

The function coerce allows you to safely convert between values of types that have the same representation with no run-time overhead. In the simplest case you can use it instead of a newtype constructor, to go from the newtype's concrete type to the abstract type. But it also works in more complicated settings, e.g. converting a list of newtypes to a list of concrete types.

unQuantity :: SQuantity s d a -> a Source #

Unwraps a possibly-scaled SQuantity, yielding its underlying representation.

This is a type-restricted version of coerce.