compensated 0.3 → 0.4.1
raw patch · 3 files changed
+23/−1 lines, 3 filesdep +bytesPVP ok
version bump matches the API change (PVP)
Dependencies added: bytes
API changes (from Hackage documentation)
+ Numeric.Compensated: instance (Compensable a, NFData a) => NFData (Compensated a)
+ Numeric.Compensated: instance (Compensable a, Serial a) => Serial (Compensated a)
Files
- CHANGELOG.markdown +8/−0
- compensated.cabal +2/−1
- src/Numeric/Compensated.hs +13/−0
CHANGELOG.markdown view
@@ -1,3 +1,11 @@+0.4.1+-----+* Marked this package `Trustworthy`.++0.4+---+* Added `NFData` and `Serial` instances+ 0.3 --- * Major version bump due to large semantics change in `log-domain`.
compensated.cabal view
@@ -1,6 +1,6 @@ name: compensated category: Numeric-version: 0.3+version: 0.4.1 license: BSD3 cabal-version: >= 1.8 license-file: LICENSE@@ -44,6 +44,7 @@ base >= 4.3 && < 5, bifunctors >= 3.2 && < 4, binary >= 0.5 && < 0.8,+ bytes >= 0.7 && < 1, cereal >= 0.3.5 && < 0.4, comonad >= 3 && < 4, deepseq >= 1.3 && < 1.5,
src/Numeric/Compensated.hs view
@@ -6,6 +6,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE PatternGuards #-}+{-# LANGUAGE Trustworthy #-} -------------------------------------------------------------------- -- | -- Copyright : (c) Edward Kmett 2013@@ -52,6 +53,7 @@ import Control.Applicative import Control.Lens as L+import Control.DeepSeq import Control.Monad import Data.Binary as Binary import Data.Data@@ -61,6 +63,7 @@ import Data.Ratio import Data.SafeCopy import Data.Serialize as Serialize+import Data.Bytes.Serial as Bytes import Data.Semigroup import Data.Vector.Unboxed as U import Data.Vector.Generic as G@@ -269,6 +272,10 @@ compensatedDataType = mkDataType "Data.Analytics.Numeric.Compensated" [compensatedConstr] {-# NOINLINE compensatedDataType #-} +instance (Compensable a, NFData a) => NFData (Compensated a) where+ rnf m = with m $ \x y -> rnf x `seq` rnf y `seq` ()+ {-# INLINE rnf #-}+ instance (Compensable a, Show a) => Show (Compensated a) where showsPrec d m = with m $ \a b -> showParen (d > 10) $ showString "compensated " . T.showsPrec 11 a . showChar ' ' . T.showsPrec 11 b@@ -495,6 +502,12 @@ put m = with m $ \a b -> do Serialize.put a Serialize.put b++instance (Compensable a, Serial a) => Serial (Compensated a) where+ deserialize = compensated <$> Bytes.deserialize <*> Bytes.deserialize+ serialize m = with m $ \a b -> do+ Bytes.serialize a+ Bytes.serialize b -- ಠ_ಠ this unnecessarily expects that the format won't change, because I can't derive a better instance. instance (Compensable a, Serialize a) => SafeCopy (Compensated a)