From 58e895dd08637d63bb5043606da8272872ebfd8f Mon Sep 17 00:00:00 2001 From: Lukas Pietzschmann Date: Wed, 17 Jul 2024 15:51:44 +0200 Subject: [PATCH] Fixed doc comments --- src/Math/Haskellator/Internal/AstProcessingSteps/Evaluate.hs | 2 ++ src/Math/Haskellator/Internal/AstProcessingSteps/Normalize.hs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Math/Haskellator/Internal/AstProcessingSteps/Evaluate.hs b/src/Math/Haskellator/Internal/AstProcessingSteps/Evaluate.hs index fe84820..1e85e0e 100644 --- a/src/Math/Haskellator/Internal/AstProcessingSteps/Evaluate.hs +++ b/src/Math/Haskellator/Internal/AstProcessingSteps/Evaluate.hs @@ -76,6 +76,7 @@ execVar n = getVarBinding n >>= \case return result -- | 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 mergeUnits :: Dimension -> Dimension -> Dimension @@ -83,6 +84,7 @@ mergeUnits lhs rhs = [x{power = power x + power y} | (x, y) <- pairs] ++ lr ++ r where (pairs, (lr, rr)) = findPairs lhs rhs -- | 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 subtractUnits :: Dimension -> Dimension -> Dimension diff --git a/src/Math/Haskellator/Internal/AstProcessingSteps/Normalize.hs b/src/Math/Haskellator/Internal/AstProcessingSteps/Normalize.hs index 447401a..098c8f8 100644 --- a/src/Math/Haskellator/Internal/AstProcessingSteps/Normalize.hs +++ b/src/Math/Haskellator/Internal/AstProcessingSteps/Normalize.hs @@ -20,6 +20,7 @@ normalize :: Expr -- ^ the 'Expr' tree to normalize normalize = Right . foldExpr (Val . filterMultiplier . convertDimensionToBase) BinOp UnaryOp Conversion VarBindings Var -- | Converts a value to its base dimension +-- -- >>> convertDimensionToBase $ Value 1 [UnitExp Kilometer 2, UnitExp Hour 1] -- 3.6e9 m^2*s convertDimensionToBase :: AstValue -> AstValue @@ -28,6 +29,7 @@ convertDimensionToBase (Value v u) = foldr doIt (Value v []) u in Value (v' * v'') (u'':u') -- | 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 convertDimensionTo :: AstValue -> Dimension -> AstValue