diff --git a/src/Numeric/Decimal.hs b/src/Numeric/Decimal.hs index e3b47ec..805bbd0 100644 --- a/src/Numeric/Decimal.hs +++ b/src/Numeric/Decimal.hs @@ -846,8 +846,10 @@ fromFixedDecimal = coerce -- Arith 123.458 -- >>> fromFixedDecimalBounded (123.458 :: Fixed E3) :: Arith (Decimal RoundToZero 3 Int8) -- ArithError arithmetic overflow +-- ... -- >>> fromFixedDecimalBounded (-123.458 :: Fixed E3) :: Arith (Decimal RoundToZero 3 Word) -- ArithError arithmetic underflow +-- ... -- -- @since 0.2.0 fromFixedDecimalBounded :: diff --git a/src/Numeric/Decimal/BoundedArithmetic.hs b/src/Numeric/Decimal/BoundedArithmetic.hs index ff1bc7b..97a6631 100644 --- a/src/Numeric/Decimal/BoundedArithmetic.hs +++ b/src/Numeric/Decimal/BoundedArithmetic.hs @@ -42,6 +42,7 @@ instance Bounded a => Bounded (Arith a) where -- *** Exception: arithmetic underflow -- >>> 1.1 - 123 :: Arith (Decimal RoundDown 3 Word) -- ArithError arithmetic underflow +-- ... -- -- @since 0.2.0 arithM :: MonadThrow m => Arith a -> m a diff --git a/src/Numeric/Decimal/Internal.hs b/src/Numeric/Decimal/Internal.hs index fe6164b..6ac0152 100644 --- a/src/Numeric/Decimal/Internal.hs +++ b/src/Numeric/Decimal/Internal.hs @@ -993,8 +993,10 @@ signumDecimalBounded d = fromIntegerDecimalBounded $ signumDecimal (toInteger <$ -- -- >>> -1.28 :: Arith (Decimal RoundHalfUp 2 Int8) -- ArithError arithmetic overflow +-- ... -- >>> negate (1.28 :: Arith (Decimal RoundHalfUp 2 Int8)) -- ArithError arithmetic overflow +-- ... -- >>> :set -XNegativeLiterals -- >>> -1.28 :: Arith (Decimal RoundHalfUp 2 Int8) -- Arith -1.28 diff --git a/tests/Numeric/DecimalSpec.hs b/tests/Numeric/DecimalSpec.hs index d31d055..da865b7 100644 --- a/tests/Numeric/DecimalSpec.hs +++ b/tests/Numeric/DecimalSpec.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE TypeApplications #-} @@ -398,9 +399,7 @@ spec = do specRounding @4 @3 @Integer specRounding @4 @4 @Integer - - - +#if !MIN_VERSION_QuickCheck(2,15,0) assertException :: (NFData a, Exception exc) => (exc -> Bool) -- ^ Return True if that is the exception that was expected -> a -- ^ Value that should throw an exception, when fully evaluated @@ -421,6 +420,7 @@ assertExceptionIO isExc action = res `deepseq` return False) $ \exc -> show exc `deepseq` return (isExc exc)) assert hasFailed +#endif roundHalfUpTo :: Natural -> Rational -> Rational roundHalfUpTo to rational =