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

Numeric.Units.Dimensional.Dimensions.TermLevel

Description

This module defines physical dimensions expressed in terms of the SI base dimensions, including arithmetic.

Synopsis

# Type

A physical dimension, encoded as 7 integers, representing a factorization of the dimension into the 7 SI base dimensions. By convention they are stored in the same order as in the Dimension data kind.

Constructors

 Dim' !Int !Int !Int !Int !Int !Int !Int
Instances
 Source # Instance details Methods Source # Instance details Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Dimension' -> c Dimension' #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Dimension' #dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Dimension') #dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Dimension') #gmapT :: (forall b. Data b => b -> b) -> Dimension' -> Dimension' #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Dimension' -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Dimension' -> r #gmapQ :: (forall d. Data d => d -> u) -> Dimension' -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> Dimension' -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> Dimension' -> m Dimension' #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Dimension' -> m Dimension' #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Dimension' -> m Dimension' # Source # Instance details Methods Source # Instance details MethodsshowList :: [Dimension'] -> ShowS # Source # Instance details Associated Typestype Rep Dimension' :: Type -> Type # Methods Source # Instance details Methodsstimes :: Integral b => b -> Dimension' -> Dimension' # Source # The monoid of dimensions under multiplication. Instance details Methodsmconcat :: [Dimension'] -> Dimension' # Source # Instance details Methodsrnf :: Dimension' -> () # Source # Instance details Methods Source # Instance details Methods type Rep Dimension' Source # Instance details type Rep Dimension' = D1 (MetaData "Dimension'" "Numeric.Units.Dimensional.Dimensions.TermLevel" "dimensional-1.3-7Gh1mp5ZBGaGfkDr7lUYf2" False) (C1 (MetaCons "Dim'" PrefixI False) ((S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int) :*: (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int))) :*: ((S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int)) :*: (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Int)))))

class HasDynamicDimension a => HasDimension a where Source #

Dimensional values inhabit this class, which allows access to a term-level representation of their dimension.

Methods

dimension :: a -> Dimension' Source #

Obtains a term-level representation of a value's dimension.

Instances
 Source # Instance details Methods Source # Instance detailsDefined in Numeric.Units.Dimensional.Dynamic Methods Source # Instance detailsDefined in Numeric.Units.Dimensional.Dynamic Methods (KnownTypeInt l, KnownTypeInt m, KnownTypeInt t, KnownTypeInt i, KnownTypeInt th, KnownTypeInt n, KnownTypeInt j) => HasDimension (Proxy (Dim l m t i th n j)) Source # Instance details Methodsdimension :: Proxy (Dim l m t i th n j) -> Dimension' Source # KnownDimension d => HasDimension (Dimensional v d a) Source # Instance detailsDefined in Numeric.Units.Dimensional.Internal Methodsdimension :: Dimensional v d a -> Dimension' Source #

class HasDynamicDimension a where Source #

Dimensional values, or those that are only possibly dimensional, inhabit this class, which allows access to a term-level representation of their dimension.

Minimal complete definition

Nothing

Methods

Gets the 'DynamicDimension of a dynamic dimensional value, which may be NoDimension if it does not represent a dimensional value of any Dimension.

A default implementation is available for types that are also in the HasDimension typeclass.

Gets the 'DynamicDimension of a dynamic dimensional value, which may be NoDimension if it does not represent a dimensional value of any Dimension.

A default implementation is available for types that are also in the HasDimension typeclass.

Instances
 Source # Instance details Methods Source # Instance details Methods Source # Instance detailsDefined in Numeric.Units.Dimensional.Dynamic Methods Source # Instance detailsDefined in Numeric.Units.Dimensional.Dynamic Methods Source # Instance detailsDefined in Numeric.Units.Dimensional.Dynamic Methods (KnownTypeInt l, KnownTypeInt m, KnownTypeInt t, KnownTypeInt i, KnownTypeInt th, KnownTypeInt n, KnownTypeInt j) => HasDynamicDimension (Proxy (Dim l m t i th n j)) Source # Instance details MethodsdynamicDimension :: Proxy (Dim l m t i th n j) -> DynamicDimension Source # KnownDimension d => HasDynamicDimension (Dimensional v d a) Source # Instance detailsDefined in Numeric.Units.Dimensional.Internal Methods

The dimension of a dynamic value, which may not have any dimension at all.

Constructors

 NoDimension The value has no valid dimension. SomeDimension Dimension' The value has the given dimension. AnyDimension The value may be interpreted as having any dimension.
Instances
 Source # Instance details Methods Source # Instance details Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DynamicDimension -> c DynamicDimension #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DynamicDimension #dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c DynamicDimension) #dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DynamicDimension) #gmapT :: (forall b. Data b => b -> b) -> DynamicDimension -> DynamicDimension #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DynamicDimension -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DynamicDimension -> r #gmapQ :: (forall d. Data d => d -> u) -> DynamicDimension -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> DynamicDimension -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> DynamicDimension -> m DynamicDimension #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DynamicDimension -> m DynamicDimension #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DynamicDimension -> m DynamicDimension # Source # Instance details Methods Source # Instance details MethodsshowList :: [DynamicDimension] -> ShowS # Source # Instance details Associated Typestype Rep DynamicDimension :: Type -> Type # Methods Source # Instance details Methodsrnf :: DynamicDimension -> () # Source # Instance details Methods Source # Instance details type Rep DynamicDimension = D1 (MetaData "DynamicDimension" "Numeric.Units.Dimensional.Dimensions.TermLevel" "dimensional-1.3-7Gh1mp5ZBGaGfkDr7lUYf2" False) (C1 (MetaCons "NoDimension" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "SomeDimension" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Dimension')) :+: C1 (MetaCons "AnyDimension" PrefixI False) (U1 :: Type -> Type)))

# Dimension Arithmetic

(*) :: Dimension' -> Dimension' -> Dimension' infixl 7 Source #

Forms the product of two dimensions.

(/) :: Dimension' -> Dimension' -> Dimension' infixl 7 Source #

Forms the quotient of two dimensions.

(^) :: Dimension' -> Int -> Dimension' infixr 8 Source #

Raises a dimension to an integer power.

Forms the reciprocal of a dimension.

Takes the nth root of a dimension, if it exists.

n must not be zero.

nroot (negate n) d == nroot n (recip d)

Takes the square root of a dimension, if it exists.

sqrt d == nroot 2 d

Takes the cube root of a dimension, if it exists.

cbrt d == nroot 3 d

# Synonyms for Base Dimensions

The dimension of dimensionless values.

# Deconstruction

asList :: Dimension' -> [Int] Source #

Converts a dimension to a list of 7 integers, representing the exponent associated with each of the 7 SI base dimensions in the standard order.

# Examining Dynamic Dimensions

Combines two DynamicDimensions, determining the DynamicDimension of a quantity that must match both inputs.

This is the lattice meet operation for DynamicDimension.

Determines if a value that has a DynamicDimension is compatible with a specified Dimension'.

Determines if a value that has a DynamicDimension in fact has any valid dimension at all.