haskellator-0.1.0.0: SI-Units supporting calculator
Safe HaskellSafe-Inferred
LanguageHaskell2010

Math.Haskellator.Internal.AstProcessingSteps.Evaluate

Description

Evaluate the expression tree to a numeric value and a dimension.

Synopsis

Documentation

type EvalValue = Value Dimension Source #

The specific Value type returned by the evaluation

evaluate Source #

Arguments

:: Expr

the expression tree to evaluate

-> Either Error Double

the numeric result or an error

Evaluate an expression tree to a numeric value

execute Source #

Arguments

:: Expr

the expression tree to evaluate

-> Either Error EvalValue

the result or an error

Determine the result (value and dimension) of an expression tree

mergeUnits :: Dimension -> Dimension -> Dimension Source #

Combine the Units of two Dimensions, by adding the powers of matching units.

>>> mergeUnits [UnitExp Meter 2, UnitExp Second 1, UnitExp Kilogram 1] [UnitExp Meter 1, UnitExp Second (-2)]
m^3*kg/s

subtractUnits :: Dimension -> Dimension -> Dimension Source #

Combine the Units of two Dimensions, by subtracting the powers of matching units.

>>> subtractUnits [UnitExp Meter 2, UnitExp Second 1, UnitExp Kilogram 1] [UnitExp Meter 1, UnitExp Second (-2)]
m*s^3*kg