Copyright | Copyright (C) 2006-2018 Bjorn Buckwalter |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | Stable |
Portability | GHC only |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Extensions |
|
Numeric.Units.Dimensional.Dimensions.TermLevel
Description
This module defines physical dimensions expressed in terms of the SI base dimensions, including arithmetic.
Synopsis
- data Dimension' = Dim' !Int !Int !Int !Int !Int !Int !Int
- class HasDynamicDimension a => HasDimension a where
- dimension :: a -> Dimension'
- class HasDynamicDimension a where
- dynamicDimension :: a -> DynamicDimension
- data DynamicDimension
- (*) :: Dimension' -> Dimension' -> Dimension'
- (/) :: Dimension' -> Dimension' -> Dimension'
- (^) :: Dimension' -> Int -> Dimension'
- recip :: Dimension' -> Dimension'
- nroot :: Int -> Dimension' -> Maybe Dimension'
- sqrt :: Dimension' -> Maybe Dimension'
- cbrt :: Dimension' -> Maybe Dimension'
- dOne :: Dimension'
- dLength :: Dimension'
- dMass :: Dimension'
- dTime :: Dimension'
- dElectricCurrent :: Dimension'
- dThermodynamicTemperature :: Dimension'
- dAmountOfSubstance :: Dimension'
- dLuminousIntensity :: Dimension'
- asList :: Dimension' -> [Int]
- matchDimensions :: DynamicDimension -> DynamicDimension -> DynamicDimension
- isCompatibleWith :: HasDynamicDimension a => a -> Dimension' -> Bool
- hasSomeDimension :: HasDynamicDimension a => a -> Bool
Type
data Dimension' Source #
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.
Instances
Access to Dimension of Dimensional Values
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
HasDimension Dimension' Source # | |
Defined in Numeric.Units.Dimensional.Dimensions.TermLevel Methods dimension :: Dimension' -> Dimension' Source # | |
HasDimension AnyUnit Source # | |
Defined in Numeric.Units.Dimensional.Dynamic Methods dimension :: AnyUnit -> Dimension' Source # | |
HasDimension (AnyQuantity a) Source # | |
Defined in Numeric.Units.Dimensional.Dynamic Methods dimension :: AnyQuantity a -> Dimension' Source # | |
(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 # | |
KnownDimension d => HasDimension (Dimensional v d a) Source # | |
Defined in Numeric.Units.Dimensional.Internal Methods dimension :: 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
dynamicDimension :: a -> DynamicDimension Source #
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.
default dynamicDimension :: HasDimension a => a -> DynamicDimension Source #
Instances
HasDynamicDimension Dimension' Source # | |
Defined in Numeric.Units.Dimensional.Dimensions.TermLevel Methods | |
HasDynamicDimension DynamicDimension Source # | |
Defined in Numeric.Units.Dimensional.Dimensions.TermLevel Methods dynamicDimension :: DynamicDimension -> DynamicDimension Source # | |
HasDynamicDimension AnyUnit Source # | |
Defined in Numeric.Units.Dimensional.Dynamic Methods | |
HasDynamicDimension (AnyQuantity a) Source # | |
Defined in Numeric.Units.Dimensional.Dynamic Methods dynamicDimension :: AnyQuantity a -> DynamicDimension Source # | |
HasDynamicDimension (DynQuantity a) Source # | |
Defined in Numeric.Units.Dimensional.Dynamic Methods dynamicDimension :: DynQuantity a -> DynamicDimension Source # | |
(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 # | |
Defined in Numeric.Units.Dimensional.Dimensions.TypeLevel Methods dynamicDimension :: Proxy ('Dim l m t i th n j) -> DynamicDimension Source # | |
KnownDimension d => HasDynamicDimension (Dimensional v d a) Source # | |
Defined in Numeric.Units.Dimensional.Internal Methods dynamicDimension :: Dimensional v d a -> DynamicDimension Source # |
data DynamicDimension Source #
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
Data DynamicDimension Source # | |||||
Defined in Numeric.Units.Dimensional.Dimensions.TermLevel Methods gfoldl :: (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 # toConstr :: DynamicDimension -> Constr # dataTypeOf :: DynamicDimension -> DataType # 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 :: forall r r'. (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 # | |||||
Generic DynamicDimension Source # | |||||
Defined in Numeric.Units.Dimensional.Dimensions.TermLevel Associated Types
Methods from :: DynamicDimension -> Rep DynamicDimension x # to :: Rep DynamicDimension x -> DynamicDimension # | |||||
Show DynamicDimension Source # | |||||
Defined in Numeric.Units.Dimensional.Dimensions.TermLevel Methods showsPrec :: Int -> DynamicDimension -> ShowS # show :: DynamicDimension -> String # showList :: [DynamicDimension] -> ShowS # | |||||
NFData DynamicDimension Source # | |||||
Defined in Numeric.Units.Dimensional.Dimensions.TermLevel Methods rnf :: DynamicDimension -> () # | |||||
HasDynamicDimension DynamicDimension Source # | |||||
Defined in Numeric.Units.Dimensional.Dimensions.TermLevel Methods dynamicDimension :: DynamicDimension -> DynamicDimension Source # | |||||
Eq DynamicDimension Source # | |||||
Defined in Numeric.Units.Dimensional.Dimensions.TermLevel Methods (==) :: DynamicDimension -> DynamicDimension -> Bool # (/=) :: DynamicDimension -> DynamicDimension -> Bool # | |||||
Ord DynamicDimension Source # | |||||
Defined in Numeric.Units.Dimensional.Dimensions.TermLevel Methods compare :: DynamicDimension -> DynamicDimension -> Ordering # (<) :: DynamicDimension -> DynamicDimension -> Bool # (<=) :: DynamicDimension -> DynamicDimension -> Bool # (>) :: DynamicDimension -> DynamicDimension -> Bool # (>=) :: DynamicDimension -> DynamicDimension -> Bool # max :: DynamicDimension -> DynamicDimension -> DynamicDimension # min :: DynamicDimension -> DynamicDimension -> DynamicDimension # | |||||
type Rep DynamicDimension Source # | |||||
Defined in Numeric.Units.Dimensional.Dimensions.TermLevel type Rep DynamicDimension = D1 ('MetaData "DynamicDimension" "Numeric.Units.Dimensional.Dimensions.TermLevel" "dimensional-1.6.1-5Kh45RH4yKfKQGqcIykmmd" '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.
recip :: Dimension' -> Dimension' Source #
Forms the reciprocal of a dimension.
nroot :: Int -> Dimension' -> Maybe Dimension' Source #
Takes the nth root of a dimension, if it exists.
n must not be zero.
nroot (negate n) d == nroot n (recip d)
sqrt :: Dimension' -> Maybe Dimension' Source #
Takes the square root of a dimension, if it exists.
sqrt d == nroot 2 d
cbrt :: Dimension' -> Maybe Dimension' Source #
Takes the cube root of a dimension, if it exists.
cbrt d == nroot 3 d
Synonyms for Base Dimensions
dOne :: Dimension' Source #
The dimension of dimensionless values.
dLength :: Dimension' Source #
dMass :: Dimension' Source #
dTime :: Dimension' Source #
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
matchDimensions :: DynamicDimension -> DynamicDimension -> DynamicDimension Source #
Combines two DynamicDimension
s, determining the DynamicDimension
of a quantity that must
match both inputs.
This is the lattice meet operation for DynamicDimension
.
isCompatibleWith :: HasDynamicDimension a => a -> Dimension' -> Bool Source #
Determines if a value that has a DynamicDimension
is compatible with a specified Dimension'
.
hasSomeDimension :: HasDynamicDimension a => a -> Bool Source #
Determines if a value that has a DynamicDimension
in fact has any valid dimension at all.