extended-reals 0.1.0.0 → 0.2.0.0
raw patch · 4 files changed
+17/−9 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.ExtendedReal: inf :: Extended r
Files
- CHANGELOG.markdown +3/−0
- extended-reals.cabal +2/−2
- src/Data/ExtendedReal.hs +5/−0
- test/TestExtendedReal.hs +7/−7
+ CHANGELOG.markdown view
@@ -0,0 +1,3 @@+0.2.0.0+-----+* add 'inf' as a short-hand for PosInf
extended-reals.cabal view
@@ -1,5 +1,5 @@ name: extended-reals-version: 0.1.0.0+version: 0.2.0.0 synopsis: Extension of real numbers with positive/negative infinities description: Extension of real numbers with positive/negative infinities (±∞).@@ -11,7 +11,7 @@ maintainer: masahiro.sakai@gmail.com category: Math build-type: Simple-extra-source-files: .travis.yml+extra-source-files: .travis.yml, CHANGELOG.markdown cabal-version: >=1.10 bug-reports: https://github.com/msakai/extended-reals/issues
src/Data/ExtendedReal.hs view
@@ -28,6 +28,7 @@ ----------------------------------------------------------------------------- module Data.ExtendedReal ( Extended (..)+ , inf , isFinite , isInfinite ) where@@ -62,6 +63,10 @@ hashWithSalt s NegInf = s `hashWithSalt` (0::Int) hashWithSalt s (Finite x) = s `hashWithSalt` (1::Int) `hashWithSalt` x hashWithSalt s PosInf = s `hashWithSalt` (2::Int)++-- | Infinity (∞)+inf :: Extended r+inf = PosInf -- | @isFinite x = not (isInfinite x)@. isFinite :: Extended r -> Bool
test/TestExtendedReal.hs view
@@ -71,7 +71,7 @@ -- PosInf + NegInf is left undefined case_add_PosInf_NegInf :: IO () case_add_PosInf_NegInf =- eval (PosInf + NegInf :: Extended Rational) @?= Nothing+ eval (inf + (- inf) :: Extended Rational) @?= Nothing prop_mult_assoc :: Property prop_mult_assoc =@@ -109,12 +109,12 @@ -- We define 0 * PosInf = 0 case_mult_zero_PosInf :: IO () case_mult_zero_PosInf =- 0 * PosInf @?= (0 :: Extended Rational)+ 0 * inf @?= (0 :: Extended Rational) -- We define 0 * NegInf = 0 case_mult_zero_NegInf :: IO () case_mult_zero_NegInf =- 0 * NegInf @?= (0 :: Extended Rational)+ 0 * (- inf) @?= (0 :: Extended Rational) prop_negate_inverse :: Property prop_negate_inverse = @@ -132,20 +132,20 @@ isFinite a && a /= 0 ==> recip (recip a) == a case_recip_PosInf :: IO ()-case_recip_PosInf = recip PosInf @?= (0 :: Extended Rational)+case_recip_PosInf = recip inf @?= (0 :: Extended Rational) case_recip_NegInf :: IO ()-case_recip_NegInf = recip NegInf @?= (0 :: Extended Rational)+case_recip_NegInf = recip (- inf) @?= (0 :: Extended Rational) prop_NegInf_smallest :: Property prop_NegInf_smallest = forAll arbitrary $ \(a :: Extended Rational) ->- NegInf <= a+ -inf <= a prop_PosInf_largest :: Property prop_PosInf_largest = forAll arbitrary $ \(a :: Extended Rational) ->- a <= PosInf+ a <= inf -- ---------------------------------------------------------------------- -- Test harness