diff --git a/src/Math/Haskellator/Internal/AstProcessingSteps/Evaluate.hs b/src/Math/Haskellator/Internal/AstProcessingSteps/Evaluate.hs index e8f1640..9820c71 100644 --- a/src/Math/Haskellator/Internal/AstProcessingSteps/Evaluate.hs +++ b/src/Math/Haskellator/Internal/AstProcessingSteps/Evaluate.hs @@ -38,9 +38,9 @@ execVal = return execBinOp :: Value Dimension -> Op -> Value Dimension -> SimpleAstFold (Value Dimension) execBinOp lhs Plus rhs | unit lhs =~= unit rhs = return $ combineValues (+) lhs rhs - | otherwise = throwError $ Error RuntimeError $ "Cannot add units " ++ show lhs ++ " and " ++ show rhs + | otherwise = throwError $ Error RuntimeError $ "Cannot add units " ++ show (unit lhs) ++ " and " ++ show (unit rhs) execBinOp lhs Minus rhs | unit lhs =~= unit rhs = return $ combineValues (-) lhs rhs - | otherwise = throwError $ Error RuntimeError $ "Cannot subtract units " ++ show lhs ++ " and " ++ show rhs + | otherwise = throwError $ Error RuntimeError $ "Cannot subtract units " ++ show (unit lhs) ++ " and " ++ show (unit rhs) execBinOp lhs Mult rhs = do let u = mergeUnits (unit lhs) (unit rhs) return $ Value (value lhs * value rhs) u diff --git a/src/Math/Haskellator/Internal/TH/UnitGeneration.hs b/src/Math/Haskellator/Internal/TH/UnitGeneration.hs index a7b404d..01591a8 100644 --- a/src/Math/Haskellator/Internal/TH/UnitGeneration.hs +++ b/src/Math/Haskellator/Internal/TH/UnitGeneration.hs @@ -129,6 +129,7 @@ genUnitExp = [d| show (UnitExp u i) = show u ++ "^" ++ show i instance Eq UnitExp where + (UnitExp $(return $ ConP (mkName "Multiplier") [] []) _) == (UnitExp $(return $ ConP (mkName "Multiplier") [] []) _) = True (UnitExp u1 i1) == (UnitExp u2 i2) = u1 == u2 && i1 == i2 |]