Copyright | Copyright (C) 2006-2018 Bjorn Buckwalter |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | Stable |
Portability | GHC only |
Safe Haskell | None |
Language | Haskell2010 |
Numeric.Units.Dimensional.UnitNames
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 :: Metricality)
- data NameAtom (m :: NameAtomType)
- data Prefix
- type PrefixName = NameAtom 'PrefixAtom
- data Metricality
- atom :: String -> String -> String -> UnitName 'NonMetric
- applyPrefix :: Prefix -> UnitName 'Metric -> UnitName 'NonMetric
- (*) :: forall (m1 :: Metricality) (m2 :: Metricality). UnitName m1 -> UnitName m2 -> UnitName 'NonMetric
- (/) :: forall (m1 :: Metricality) (m2 :: Metricality). UnitName m1 -> UnitName m2 -> UnitName 'NonMetric
- (^) :: forall (m :: Metricality). UnitName m -> Int -> UnitName 'NonMetric
- product :: Foldable f => f (UnitName 'NonMetric) -> UnitName 'NonMetric
- reduce :: forall (m :: Metricality). UnitName m -> UnitName m
- grouped :: forall (m :: Metricality). UnitName m -> UnitName 'NonMetric
- baseUnitName :: Dimension' -> UnitName 'NonMetric
- siPrefixes :: [Prefix]
- nOne :: UnitName 'NonMetric
- prefixName :: Prefix -> PrefixName
- scaleFactor :: Prefix -> Rational
- type UnitNameTransformer = forall (m :: Metricality). UnitName m -> UnitName 'NonMetric
- type UnitNameTransformer2 = forall (m1 :: Metricality) (m2 :: Metricality). UnitName m1 -> UnitName m2 -> UnitName 'NonMetric
- weaken :: forall (m :: Metricality). UnitName m -> UnitName 'NonMetric
- strengthen :: forall (m :: Metricality). UnitName m -> Maybe (UnitName 'Metric)
- relax :: forall (m1 :: Metricality) (m2 :: Metricality). (Typeable m1, Typeable m2) => UnitName m1 -> Maybe (UnitName m2)
- name_en :: NameAtom m -> String
- abbreviation_en :: NameAtom m -> String
- asAtomic :: forall (m :: Metricality). UnitName m -> Maybe (NameAtom ('UnitAtom m))
Data Types
data UnitName (m :: Metricality) Source #
The name of a unit.
Instances
Show (UnitName m) Source # |
|
NFData (UnitName m) Source # | |
Defined in Numeric.Units.Dimensional.UnitNames.Internal | |
HasInterchangeName (UnitName m) Source # | |
Defined in Numeric.Units.Dimensional.UnitNames.Internal Methods interchangeName :: UnitName m -> InterchangeName Source # | |
Eq (UnitName m) Source # | |
data NameAtom (m :: NameAtomType) Source #
Represents the name of an atomic unit or prefix.
Instances
A metric prefix.
Instances
Data Prefix Source # | |||||
Defined in Numeric.Units.Dimensional.UnitNames.Internal Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Prefix -> c Prefix # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Prefix # toConstr :: Prefix -> Constr # dataTypeOf :: Prefix -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Prefix) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Prefix) # gmapT :: (forall b. Data b => b -> b) -> Prefix -> Prefix # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Prefix -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Prefix -> r # gmapQ :: (forall d. Data d => d -> u) -> Prefix -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Prefix -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Prefix -> m Prefix # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Prefix -> m Prefix # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Prefix -> m Prefix # | |||||
Generic Prefix Source # | |||||
Defined in Numeric.Units.Dimensional.UnitNames.Internal Associated Types
| |||||
NFData Prefix Source # | |||||
Defined in Numeric.Units.Dimensional.UnitNames.Internal | |||||
HasInterchangeName Prefix Source # | |||||
Defined in Numeric.Units.Dimensional.UnitNames.Internal Methods | |||||
Eq Prefix Source # | |||||
Ord Prefix Source # | |||||
Defined in Numeric.Units.Dimensional.UnitNames.Internal | |||||
type Rep Prefix Source # | |||||
Defined in Numeric.Units.Dimensional.UnitNames.Internal type Rep Prefix = D1 ('MetaData "Prefix" "Numeric.Units.Dimensional.UnitNames.Internal" "dimensional-1.6.1-5Kh45RH4yKfKQGqcIykmmd" 'False) (C1 ('MetaCons "Prefix" 'PrefixI 'True) (S1 ('MetaSel ('Just "prefixName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PrefixName) :*: S1 ('MetaSel ('Just "scaleFactor") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Rational))) |
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
Data Metricality Source # | |||||
Defined in Numeric.Units.Dimensional.Variants 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 :: forall r r'. (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 # | |||||
Generic Metricality Source # | |||||
Defined in Numeric.Units.Dimensional.Variants Associated Types
| |||||
NFData Metricality Source # | |||||
Defined in Numeric.Units.Dimensional.Variants Methods rnf :: Metricality -> () # | |||||
Eq Metricality Source # | |||||
Defined in Numeric.Units.Dimensional.Variants | |||||
Ord Metricality Source # | |||||
Defined in Numeric.Units.Dimensional.Variants 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 # | |||||
type Rep Metricality Source # | |||||
Defined in Numeric.Units.Dimensional.Variants |
Construction of Unit Names
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.
(*) :: forall (m1 :: Metricality) (m2 :: Metricality). UnitName m1 -> UnitName m2 -> UnitName 'NonMetric infixl 7 Source #
Form a UnitName
by taking the product of two others.
(/) :: forall (m1 :: Metricality) (m2 :: Metricality). UnitName m1 -> UnitName m2 -> UnitName 'NonMetric infixl 7 Source #
Form a UnitName
by dividing one by another.
(^) :: forall (m :: Metricality). UnitName m -> Int -> UnitName 'NonMetric infixr 8 Source #
Form a UnitName
by raising a name to an integer power.
reduce :: forall (m :: Metricality). UnitName m -> UnitName m Source #
Reduce a UnitName
by algebraic simplifications.
Standard Names
baseUnitName :: Dimension' -> UnitName 'NonMetric Source #
The name of the base unit associated with a specified dimension.
siPrefixes :: [Prefix] Source #
A list of all Prefix
es defined by the SI.
Inspecting Prefixes
prefixName :: Prefix -> PrefixName Source #
The name of a metric prefix.
scaleFactor :: Prefix -> Rational Source #
The scale factor denoted by a metric prefix.
Convenience Type Synonyms for Unit Name Transformations
type UnitNameTransformer = forall (m :: Metricality). 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 :: Metricality) (m2 :: Metricality). 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
strengthen :: forall (m :: Metricality). UnitName m -> Maybe (UnitName 'Metric) Source #
relax :: forall (m1 :: Metricality) (m2 :: Metricality). (Typeable m1, Typeable m2) => UnitName m1 -> Maybe (UnitName m2) Source #
Convert a UnitName
of one Metricality
into a name of another metricality by
strengthening or weakening if neccessary. Because it may not be possible to strengthen,
the result is returned in a Maybe
wrapper.
abbreviation_en :: NameAtom m -> String Source #
The abbreviated name of the unit in international English.