Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Normalizes the expression tree generated by the Parser
to a tree that can be evaluated.
Documentation
convertDimensionTo :: AstValue -> Dimension -> AstValue Source #
Converts a value to a given dimension. Throws if the conversion is not possible.
>>>
convertDimensionTo (Value 3600000000 [UnitExp Meter 2, UnitExp Second 1]) [UnitExp Kilometer 2, UnitExp Hour 1]
1.0 h*km^2
convertDimensionToBase :: AstValue -> AstValue Source #
Converts a value to its base dimension
>>>
convertDimensionToBase $ Value 1 [UnitExp Kilometer 2, UnitExp Hour 1]
3.6e9 m^2*s
Normalize all values inside the tree to their base units
tryConvertDimensionTo :: AstValue -> Dimension -> Maybe AstValue Source #
Tries to convert a value to a given dimension. Returns Nothing
if the conversion is not possible.
See convertDimensionTo
for an example.