packages feed

exact-pi 0.3.0.0 → 0.3.1.0

raw patch · 3 files changed

+11/−1 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.ExactPi: areExactlyEqual :: ExactPi -> ExactPi -> Bool

Files

changelog.md view
@@ -1,3 +1,7 @@+0.3.1.0
+-------
+* Added support for exactly comparing values.
+
 0.3.0.0
 -------
 * Added a type-level representation of ExactPi values.
exact-pi.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/
 
 name:                exact-pi
-version:             0.3.0.0
+version:             0.3.1.0
 synopsis:            Exact rational multiples of pi (and integer powers of pi)
 description:         Provides an exact representation for rational multiples of pi alongside an approximate representation of all reals.
                      Useful for storing and computing with conversion factors between physical units.
src/Data/ExactPi.hs view
@@ -23,6 +23,7 @@   isExact,
   isExactZero,
   isExactOne,
+  areExactlyEqual,
   isExactInteger,
   toExactInteger,
   isExactRational,
@@ -66,6 +67,11 @@ isExactOne :: ExactPi -> Bool
 isExactOne (Exact 0 1) = True
 isExactOne _ = False
+
+-- | Identifies whether two 'ExactPi' values are exactly equal.
+areExactlyEqual :: ExactPi -> ExactPi -> Bool
+areExactlyEqual (Exact z1 q1) (Exact z2 q2) = (z1 == z2 && q1 == q2) || (q1 == 0 && q2 == 0)
+areExactlyEqual _ _ = False
 
 -- | Identifies whether an 'ExactPi' is an exact representation of an integer.
 isExactInteger :: ExactPi -> Bool