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

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

Numeric.Units.Dimensional.UnitNames

Contents

- Data Types
- Construction of Unit Names
- Standard Names
  - Names for the Base Units
  - Names for the SI Metric Prefixes
- Convenience Type Synonyms for Unit Name Transformations
- Forgetting Unwanted Phantom Types

Description

This module provides types and functions for manipulating unit names.

Please note that the details of the name representation may be less stable than the other APIs provided by this package, as new features using them are still being developed.

Synopsis

- data UnitName m
- data NameAtom m
- type PrefixName = NameAtom PrefixAtom
- data Metricality
  - = Metric
  - | NonMetric
- atom :: String -> String -> String -> UnitName NonMetric
- applyPrefix :: PrefixName -> UnitName Metric -> UnitName NonMetric
- (*) :: UnitName m1 -> UnitName m2 -> UnitName NonMetric
- (/) :: UnitName m1 -> UnitName m2 -> UnitName NonMetric
- (^) :: UnitName m -> Int -> UnitName NonMetric
- product :: Foldable f => f (UnitName NonMetric) -> UnitName NonMetric
- reduce :: UnitName m -> UnitName m
- grouped :: UnitName m -> UnitName NonMetric
- baseUnitName :: Dimension' -> UnitName NonMetric
- nOne :: UnitName NonMetric
- nMeter :: UnitName Metric
- nGram :: UnitName Metric
- nKilogram :: UnitName NonMetric
- nSecond :: UnitName Metric
- nAmpere :: UnitName Metric
- nKelvin :: UnitName Metric
- nMole :: UnitName Metric
- nCandela :: UnitName Metric
- deka :: PrefixName
- hecto :: PrefixName
- kilo :: PrefixName
- mega :: PrefixName
- giga :: PrefixName
- tera :: PrefixName
- peta :: PrefixName
- exa :: PrefixName
- zetta :: PrefixName
- yotta :: PrefixName
- deci :: PrefixName
- centi :: PrefixName
- milli :: PrefixName
- micro :: PrefixName
- nano :: PrefixName
- pico :: PrefixName
- femto :: PrefixName
- atto :: PrefixName
- zepto :: PrefixName
- yocto :: PrefixName
- type UnitNameTransformer = forall m. UnitName m -> UnitName NonMetric
- type UnitNameTransformer2 = forall m1 m2. UnitName m1 -> UnitName m2 -> UnitName NonMetric
- weaken :: UnitName m -> UnitName NonMetric
- strengthen :: UnitName m -> Maybe (UnitName Metric)
- relax :: forall m1 m2. (Typeable m1, Typeable m2) => UnitName m1 -> Maybe (UnitName m2)

# Data Types

data UnitName m Source #

The name of a unit.

Instances

Eq (UnitName m) Source # |
Methods (==) :: UnitName m -> UnitName m -> Bool # (/=) :: UnitName m -> UnitName m -> Bool #
Show (UnitName m) Source # |
Methods showsPrec :: Int -> UnitName m -> ShowS # show :: UnitName m -> String # showList :: [UnitName m] -> ShowS #
HasInterchangeName (UnitName m) Source # |
Methods interchangeName :: UnitName m -> InterchangeName Source #

data NameAtom m Source #

Represents the name of an atomic unit or prefix.

Instances

Eq (NameAtom m) Source # |
Methods (==) :: NameAtom m -> NameAtom m -> Bool # (/=) :: NameAtom m -> NameAtom m -> Bool #
Typeable NameAtomType m => Data (NameAtom m) Source # |

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NameAtom m -> c (NameAtom m) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (NameAtom m) #

toConstr :: NameAtom m -> Constr #

dataTypeOf :: NameAtom m -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c (NameAtom m)) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (NameAtom m)) #

gmapT :: (forall b. Data b => b -> b) -> NameAtom m -> NameAtom m #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NameAtom m -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NameAtom m -> r #

gmapQ :: (forall d. Data d => d -> u) -> NameAtom m -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> NameAtom m -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> NameAtom m -> m (NameAtom m) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NameAtom m -> m (NameAtom m) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NameAtom m -> m (NameAtom m) #

Ord (NameAtom m) Source # |
Methods compare :: NameAtom m -> NameAtom m -> Ordering # (<) :: NameAtom m -> NameAtom m -> Bool # (<=) :: NameAtom m -> NameAtom m -> Bool # (>) :: NameAtom m -> NameAtom m -> Bool # (>=) :: NameAtom m -> NameAtom m -> Bool # max :: NameAtom m -> NameAtom m -> NameAtom m # min :: NameAtom m -> NameAtom m -> NameAtom m #
Generic (NameAtom m) Source # |
Associated Types type Rep (NameAtom m) :: * -> * # Methods from :: NameAtom m -> Rep (NameAtom m) x # to :: Rep (NameAtom m) x -> NameAtom m #
HasInterchangeName (NameAtom m) Source # |
Methods interchangeName :: NameAtom m -> InterchangeName Source #
type Rep (NameAtom m) Source # |

type Rep (NameAtom m) = D1 (MetaData "NameAtom" "Numeric.Units.Dimensional.UnitNames.Internal" "dimensional-1.0.1.3-J9LDKppAtjNKDu3TyelN12" False) (C1 (MetaCons "NameAtom" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "_interchangeName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 InterchangeName)) ((:*:) (S1 (MetaSel (Just Symbol "abbreviation_en") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) (S1 (MetaSel (Just Symbol "name_en") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)))))

type PrefixName = NameAtom PrefixAtom Source #

The name of a metric prefix.

data Metricality Source #

Encodes whether a unit is a metric unit, that is, whether it can be combined with a metric prefix to form a related unit.

Constructors

Metric | Capable of receiving a metric prefix.
NonMetric | Incapable of receiving a metric prefix.

Instances

Eq Metricality Source # |
Methods (==) :: Metricality -> Metricality -> Bool # (/=) :: Metricality -> Metricality -> Bool #
Data Metricality Source # |

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Metricality -> c Metricality #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Metricality #

toConstr :: Metricality -> Constr #

dataTypeOf :: Metricality -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Metricality) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Metricality) #

gmapT :: (forall b. Data b => b -> b) -> Metricality -> Metricality #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Metricality -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Metricality -> r #

gmapQ :: (forall d. Data d => d -> u) -> Metricality -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Metricality -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Metricality -> m Metricality #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Metricality -> m Metricality #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Metricality -> m Metricality #

Ord Metricality Source # |
Methods compare :: Metricality -> Metricality -> Ordering # (<) :: Metricality -> Metricality -> Bool # (<=) :: Metricality -> Metricality -> Bool # (>) :: Metricality -> Metricality -> Bool # (>=) :: Metricality -> Metricality -> Bool # max :: Metricality -> Metricality -> Metricality # min :: Metricality -> Metricality -> Metricality #
Generic Metricality Source # |
Associated Types type Rep Metricality :: * -> * # Methods from :: Metricality -> Rep Metricality x # to :: Rep Metricality x -> Metricality #
type Rep Metricality Source # |
type Rep Metricality = D1 (MetaData "Metricality" "Numeric.Units.Dimensional.Variants" "dimensional-1.0.1.3-J9LDKppAtjNKDu3TyelN12" False) ((:+:) (C1 (MetaCons "Metric" PrefixI False) U1) (C1 (MetaCons "NonMetric" PrefixI False) U1))

# Construction of Unit Names

atom Source #

Arguments

:: String | Interchange name
-> String | Abbreviated name in international English
-> String | Full name in international English
-> UnitName NonMetric |

Constructs an atomic name for a custom unit.

applyPrefix :: PrefixName -> UnitName Metric -> UnitName NonMetric Source #

Forms a `UnitName` from a `Metric` name by applying a metric prefix.

(*) :: UnitName m1 -> UnitName m2 -> UnitName NonMetric infixl 7 Source #

Form a `UnitName` by taking the product of two others.

(/) :: UnitName m1 -> UnitName m2 -> UnitName NonMetric infixl 7 Source #

Form a `UnitName` by dividing one by another.

(^) :: UnitName m -> Int -> UnitName NonMetric infixr 8 Source #

Form a `UnitName` by raising a name to an integer power.

product :: Foldable f => f (UnitName NonMetric) -> UnitName NonMetric Source #

Forms the product of a list of `UnitName`s.

If you wish to form a heterogenous product of `Metric` and `NonMetric` units you should apply `weaken` to the `Metric` ones.

reduce :: UnitName m -> UnitName m Source #

grouped :: UnitName m -> UnitName NonMetric Source #

Constructs a `UnitName` by applying a grouping operation to another `UnitName`, which may be useful to express precedence.

# Standard Names

baseUnitName :: Dimension' -> UnitName NonMetric Source #

The name of the base unit associated with a specified dimension.

## Names for the Base Units

nOne :: UnitName NonMetric Source #

nMeter :: UnitName Metric Source #

nGram :: UnitName Metric Source #

nKilogram :: UnitName NonMetric Source #

nSecond :: UnitName Metric Source #

nAmpere :: UnitName Metric Source #

nKelvin :: UnitName Metric Source #

nMole :: UnitName Metric Source #

nCandela :: UnitName Metric Source #

## Names for the SI Metric Prefixes

deka :: PrefixName Source #

hecto :: PrefixName Source #

kilo :: PrefixName Source #

mega :: PrefixName Source #

giga :: PrefixName Source #

tera :: PrefixName Source #

peta :: PrefixName Source #

exa :: PrefixName Source #

zetta :: PrefixName Source #

yotta :: PrefixName Source #

deci :: PrefixName Source #

centi :: PrefixName Source #

milli :: PrefixName Source #

micro :: PrefixName Source #

nano :: PrefixName Source #

pico :: PrefixName Source #

femto :: PrefixName Source #

atto :: PrefixName Source #

zepto :: PrefixName Source #

yocto :: PrefixName Source #

# Convenience Type Synonyms for Unit Name Transformations

type UnitNameTransformer = forall m. UnitName m -> UnitName NonMetric Source #

The type of a unit name transformation that may be associated with an operation that takes a single unit as input.

type UnitNameTransformer2 = forall m1 m2. UnitName m1 -> UnitName m2 -> UnitName NonMetric Source #

The type of a unit name transformation that may be associated with an operation that takes two units as input.

# Forgetting Unwanted Phantom Types

weaken :: UnitName m -> UnitName NonMetric Source #

Convert a `UnitName` which may or may not be `Metric` to one which is certainly `NonMetric`.

strengthen :: UnitName m -> Maybe (UnitName Metric) Source #

Attempt to convert a `UnitName` which may or may not be `Metric` to one which is certainly `Metric`.

relax :: forall m1 m2. (Typeable m1, Typeable m2) => UnitName m1 -> Maybe (UnitName m2) Source #

Convert a `UnitName` of one `Metricality` into a name of the other metricality by strengthening or weakening if neccessary. Because it may not be possible to strengthen, the result is returned in a `Maybe` wrapper.