Module

Type.Data.Units

Package
purescript-typelevel-measures
Repository
csicar/purescript-typelevel-measures

#Measured Source

data Measured v (u :: # 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

#Measure Source

kind Measure

#MProxy Source

data MProxy (m :: Measure)

Proxy from kind Measure to kind Type

#MeasureExp Source

data MeasureExp (m :: Measure) (exp :: Int)

Base Measure with an Exponent. Represents m^exp

Instances

#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

#combine Source

combine :: forall a b. Combine a b => RLProxy a -> RLProxy b

Valuelevel combine

#AddRows Source

class AddRows (a :: # Type) (b :: # Type) (sum :: # Type) | a b -> sum

Adds two rows, adding entries with the same type

Instances

#addRows Source

addRows :: forall a b sum. AddRows a b sum => RProxy a -> RProxy b -> RProxy sum

#InverseRow Source

class InverseRow (original :: # Type) (inverted :: # Type) | inverted -> original

Invert a Row: InserseRow (Meter P1 * Sec N3 ()) (Meter N1 * Sec N3 ())

Instances

#InverseRowList Source

class InverseRowList (original :: RowList) (inverted :: RowList) | original -> inverted, inverted -> original

Instances

#mult Source

mult :: forall a b c v. AddRows a b c => Semiring v => Measured v a -> Measured v b -> Measured v c

multily values with measures

#(**) Source

Operator alias for Type.Data.Units.mult (left-associative / precedence 7)

#divide Source

divide :: forall a b c v ib. InverseRow b ib => AddRows a ib c => EuclideanRing v => Measured v a -> Measured v b -> Measured v c

divide values with measures

#(//) Source

Operator alias for Type.Data.Units.divide (left-associative / precedence 7)

#liftV Source

liftV :: forall a. Semiring a => a -> a : ()

lifts a Value to a unitless Measured

#add Source

add :: forall m v. Semiring v => Measured v m -> Measured v m -> Measured v m

add values with measures

#(++) Source

Operator alias for Type.Data.Units.add (left-associative / precedence 6)

#sub Source

sub :: forall v m. Ring v => Measured v m -> Measured v m -> Measured v m

subtract values with measures

#(-*) Source

Operator alias for Type.Data.Units.sub (left-associative / precedence 6)

#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 ())

#ShowMeasure Source

class ShowMeasure (m :: Measure)  where

Members

#ShowRow Source

data ShowRow (r :: RowList)

Instances