Type.Data.Units
- Package
- purescript-typelevel-measures
- Repository
- csicar/purescript-typelevel-measures
#Measured Source
data Measured v (u :: Row Type)
Represents a value with a List of Measures with Exponents value [m² * s³]
Types are constructed using the type aliases provided by the Base Units:
Measured Int (Meter N3 ())
which represents Int with Unit `[1/m³]``
The infix operator :
allows for simpler syntax: Int : Meter N3 ()
Instances
#MeasureExp Source
data MeasureExp (m :: Measure) (exp :: Int)
Base Measure with an Exponent. Represents m^exp
Instances
(SumInt exp1 exp2 exp3, IsZeroInt exp3 isZero, If isZero (RLProxy tail') (RLProxy (Cons sym (MeasureExp m exp3) tail')) (RLProxy result), Combine tail tail') => Combine (Cons sym (MeasureExp m exp1) (Cons sym (MeasureExp m exp2) tail)) result
(Combine rest rest') => Combine (Cons sym1 (MeasureExp m1 exp1) rest) (Cons sym1 (MeasureExp m1 exp1) rest')
(InverseRowList tail inverseTail, Inverse ty inverseTy) => InverseRowList (Cons sym (MeasureExp m ty) tail) (Cons sym (MeasureExp m inverseTy) inverseTail)
(ShowMeasure ty, Show (ShowRow tail), IsInt exp) => Show (ShowRow (Cons sym (MeasureExp ty exp) tail))
#Combine Source
class Combine (original :: RowList) (combined :: RowList) | original -> combined
Combines two sequential same symbols by adding their values
Example: Combine (m², m¹, s¹, s¹, kg) (m³, s², kg)
Instances
(SumInt exp1 exp2 exp3, IsZeroInt exp3 isZero, If isZero (RLProxy tail') (RLProxy (Cons sym (MeasureExp m exp3) tail')) (RLProxy result), Combine tail tail') => Combine (Cons sym (MeasureExp m exp1) (Cons sym (MeasureExp m exp2) tail)) result
(Combine rest rest') => Combine (Cons sym1 (MeasureExp m1 exp1) rest) (Cons sym1 (MeasureExp m1 exp1) rest')
Combine Nil Nil
#InverseRow Source
class InverseRow (original :: Row Type) (inverted :: Row Type) | inverted -> original
Invert a Row: InserseRow (Meter P1 * Sec N3 ()) (Meter N1 * Sec N3 ())
Instances
(RowToList original originalList, InverseRowList originalList resultList, ListToRow resultList result) => InverseRow original result
#InverseRowList Source
class InverseRowList (original :: RowList) (inverted :: RowList) | original -> inverted, inverted -> original
Instances
InverseRowList Nil Nil
(InverseRowList tail inverseTail, Inverse ty inverseTy) => InverseRowList (Cons sym (MeasureExp m ty) tail) (Cons sym (MeasureExp m inverseTy) inverseTail)
#divide Source
divide :: forall ib v c b a. InverseRow b ib => AddRows a ib c => EuclideanRing v => Measured v a -> Measured v b -> Measured v c
divide values with measures
#type (*) Source
Operator alias for Type.Row.RowApply (right-associative / precedence 4)
"Multiply" Measures: (Meter P1 * Sec N2 * ()) ≡ (Meter P1 (Sec N2 ()))
Note: The last *
can be omitted Sec N2 * () ≡ Sec N2 ()
#type (:) Source
Operator alias for Type.Data.Units.Measured (non-associative / precedence 3)
Add Unit to a value: (Int : Meter P1 ()) ≡ Measured Int (Meter P1 ())
- Modules
- Type.
Data. Units - Type.
Data. Units. SI