Hello community, here is the log from the commit of package ghc-store for openSUSE:Leap:15.2 checked in at 2020-02-19 18:41:19 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/ghc-store (Old) and /work/SRC/openSUSE:Leap:15.2/.ghc-store.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-store" Wed Feb 19 18:41:19 2020 rev:13 rq:771469 version:0.7.1 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/ghc-store/ghc-store.changes 2020-01-15 15:02:38.981817129 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.ghc-store.new.26092/ghc-store.changes 2020-02-19 18:41:20.254199637 +0100 @@ -1,0 +2,88 @@ +Mon Nov 18 03:02:55 UTC 2019 - [email protected] + +- Update store to version 0.7.1. + ## 0.7.1 + + * Fixes compilation with GHC-7.10 due to it not defining `Generic` + instances for `Complex` and `Identity`. See [#142][]. + + * Documents some gotchas about using store vs other libraries + + [#142]: https://github.com/fpco/store/issues/142 + +------------------------------------------------------------------- +Sun Nov 10 03:03:18 UTC 2019 - [email protected] + +- Update store to version 0.7.0. + ## 0.7.0 + + * Fixes a bug where the `Store` instances for `Identity`, `Const`, and + `Complex` all have `Storable` superclasses instead of `Store. See + [#143][]. + + [#143]: https://github.com/fpco/store/issues/143 + + ## 0.6.1 + + * Can now optionally be built with `integer-simple` instead of + `integer-gmp`, via the `integer-simple` cabal flag. Note that the + serialization of `Integer` with `integer-simple` differs from what + is used by the GMP default. See [#147][]. + + [#147]: https://github.com/fpco/store/pull/147 + +------------------------------------------------------------------- +Fri Nov 8 16:14:50 UTC 2019 - Peter Simons <[email protected]> + +- Drop obsolete group attributes. + +------------------------------------------------------------------- +Thu Oct 24 02:03:05 UTC 2019 - [email protected] + +- Update store to version 0.6.0.1. + ## 0.6.0.1 + + * Now builds with GHC-7.10 - compatibility was broken in 0.6.0 due to + the fix for GHC-8.8. See + [#146][https://github.com/fpco/store/issues/146]. + +------------------------------------------------------------------- +Fri Oct 18 02:02:37 UTC 2019 - [email protected] + +- Update store to version 0.6.0. + ## 0.6.0 + + * Now builds with GHC-8.8. This is a major version bump because + MonadFail constraints were added to some functions, which is + potentially a breaking change. + +------------------------------------------------------------------- +Mon Jul 8 02:01:12 UTC 2019 - [email protected] + +- Update store to version 0.5.1.2. + ## 0.5.1.2 + + * Fixes compilation with GHC < 8.0. See + [#142](https://github.com/fpco/store/issues/142). + +------------------------------------------------------------------- +Wed May 22 02:02:01 UTC 2019 - [email protected] + +- Update store to version 0.5.1.1. + ## 0.5.1.1 + + * Update to the instances for generics, to improve error messages for + sum types with more than 255 constructors. See + [#141](https://github.com/fpco/store/issues/141) + +------------------------------------------------------------------- +Thu Apr 25 02:02:26 UTC 2019 - [email protected] + +- Update store to version 0.5.1.0. + ## 0.5.1.0 + + * Update to TH to support sum types with more than 62 constructors. + + * Uses TH to derive Either instance, so that it can sometimes have ConstSize #119. + +------------------------------------------------------------------- Old: ---- store-0.5.0.1.tar.gz New: ---- store-0.7.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-store.spec ++++++ --- /var/tmp/diff_new_pack.YotOvS/_old 2020-02-19 18:41:20.590200050 +0100 +++ /var/tmp/diff_new_pack.YotOvS/_new 2020-02-19 18:41:20.590200050 +0100 @@ -1,7 +1,7 @@ # # spec file for package ghc-store # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,11 +19,10 @@ %global pkg_name store %bcond_with tests Name: ghc-%{pkg_name} -Version: 0.5.0.1 +Version: 0.7.1 Release: 0 Summary: Fast binary serialization License: MIT -Group: Development/Libraries/Haskell URL: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz BuildRequires: ghc-Cabal-devel @@ -38,6 +37,7 @@ BuildRequires: ghc-cryptohash-devel BuildRequires: ghc-deepseq-devel BuildRequires: ghc-directory-devel +BuildRequires: ghc-fail-devel BuildRequires: ghc-filepath-devel BuildRequires: ghc-free-devel BuildRequires: ghc-hashable-devel @@ -68,12 +68,7 @@ BuildRequires: ghc-vector-devel BuildRequires: ghc-void-devel %if %{with tests} -BuildRequires: ghc-cereal-devel -BuildRequires: ghc-cereal-vector-devel BuildRequires: ghc-clock-devel -BuildRequires: ghc-criterion-devel -BuildRequires: ghc-vector-binary-instances-devel -BuildRequires: ghc-weigh-devel %endif %description @@ -81,7 +76,6 @@ %package devel Summary: Haskell %{pkg_name} library development files -Group: Development/Libraries/Haskell Requires: %{name} = %{version}-%{release} Requires: ghc-compiler = %{ghc_version} Requires(post): ghc-compiler = %{ghc_version} ++++++ store-0.5.0.1.tar.gz -> store-0.7.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/store-0.5.0.1/ChangeLog.md new/store-0.7.1/ChangeLog.md --- old/store-0.5.0.1/ChangeLog.md 2018-10-21 09:35:42.000000000 +0200 +++ new/store-0.7.1/ChangeLog.md 2019-11-17 20:29:05.000000000 +0100 @@ -1,5 +1,60 @@ # ChangeLog +## 0.7.1 + +* Fixes compilation with GHC-7.10 due to it not defining `Generic` + instances for `Complex` and `Identity`. See [#142][]. + +* Documents some gotchas about using store vs other libraries + +[#142]: https://github.com/fpco/store/issues/142 + +## 0.7.0 + +* Fixes a bug where the `Store` instances for `Identity`, `Const`, and + `Complex` all have `Storable` superclasses instead of `Store. See + [#143][]. + +[#143]: https://github.com/fpco/store/issues/143 + +## 0.6.1 + +* Can now optionally be built with `integer-simple` instead of + `integer-gmp`, via the `integer-simple` cabal flag. Note that the + serialization of `Integer` with `integer-simple` differs from what + is used by the GMP default. See [#147][]. + +[#147]: https://github.com/fpco/store/pull/147 + +## 0.6.0.1 + +* Now builds with GHC-7.10 - compatibility was broken in 0.6.0 due to + the fix for GHC-8.8. See + [#146][https://github.com/fpco/store/issues/146]. + +## 0.6.0 + +* Now builds with GHC-8.8. This is a major version bump because + MonadFail constraints were added to some functions, which is + potentially a breaking change. + +## 0.5.1.2 + +* Fixes compilation with GHC < 8.0. See + [#142](https://github.com/fpco/store/issues/142). + +## 0.5.1.1 + +* Update to the instances for generics, to improve error messages for + sum types with more than 255 constructors. See + [#141](https://github.com/fpco/store/issues/141) + +## 0.5.1.0 + +* Update to TH to support sum types with more than 62 constructors. + +* Uses TH to derive Either instance, so that it can sometimes have ConstSize #119. + ## 0.5.0.1 * Updates to test-suite enabling `store` to build with newer dependencies. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/store-0.5.0.1/README.md new/store-0.7.1/README.md --- old/store-0.5.0.1/README.md 2018-05-31 06:35:48.000000000 +0200 +++ new/store-0.7.1/README.md 2019-11-17 19:14:02.000000000 +0100 @@ -14,6 +14,11 @@ [#31](https://github.com/fpco/store/issues/31). This plan makes little endian the default, so that the most common endianness has no overhead. + - Another way that the serialization behavior can vary is if + integer-simple is used instead of GHC's default of using + GMP. `Integer` serialized with the `integer-simple` flag enabled + are not compatible with those serialized without the flag enabled. + * Instead of implementing lazy serialization / deserialization involving multiple input / output buffers, `peek` and `poke` always work with a single buffer. This buffer is allocated by asking the value for its size before @@ -36,6 +41,23 @@ * Utilities for streaming encoding / decoding of Store encoded messages, via the `store-streaming` package. +## Gotchas + +Store is best used for communication between trusted processes and +local caches. It can certainly be used for other purposes, but the +builtin set of instances have some gotchas to be aware of: + +* Store's builtin instances serialize in a format which depends on + machine endianness. + +* Store's builtin instances trust the data when deserializing. For + example, the deserialization of `Vector` will read the vector's link + from the first 8 bytes. It will then allocate enough memory to store + all the elements. Malicious or malformed input could cause + allocation of large amounts of memory. See [issue #122][] + +[issue #122]: https://github.com/fpco/store/issues/122 + ## Blog posts * [Initial release announcement](https://www.fpcomplete.com/blog/2016/05/store-package) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/store-0.5.0.1/src/Data/Store/Impl.hs new/store-0.7.1/src/Data/Store/Impl.hs --- old/store-0.5.0.1/src/Data/Store/Impl.hs 2017-11-22 16:23:16.000000000 +0100 +++ new/store-0.7.1/src/Data/Store/Impl.hs 2019-11-17 19:14:03.000000000 +0100 @@ -1,4 +1,6 @@ {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE DeriveDataTypeable #-} @@ -28,6 +30,7 @@ import Data.Typeable (Typeable, typeRep) import Data.Word import Foreign.Storable (Storable, sizeOf) +import GHC.Exts (Constraint) import GHC.Generics import GHC.TypeLits import Prelude @@ -262,21 +265,40 @@ -- FIXME: check that this type level stuff dosen't get turned into -- costly runtime computation -instance (SumArity (a :+: b) <= 255, GStoreSizeSum 0 (a :+: b)) +instance (FitsInByte (SumArity (a :+: b)), GStoreSizeSum 0 (a :+: b)) => GStoreSize (a :+: b) where gsize = VarSize $ \x -> sizeOf (undefined :: Word8) + gsizeSum x (Proxy :: Proxy 0) {-# INLINE gsize #-} -instance (SumArity (a :+: b) <= 255, GStorePokeSum 0 (a :+: b)) +instance (FitsInByte (SumArity (a :+: b)), GStorePokeSum 0 (a :+: b)) => GStorePoke (a :+: b) where gpoke x = gpokeSum x (Proxy :: Proxy 0) {-# INLINE gpoke #-} -instance (SumArity (a :+: b) <= 255, GStorePeekSum 0 (a :+: b)) +instance (FitsInByte (SumArity (a :+: b)), GStorePeekSum 0 (a :+: b)) => GStorePeek (a :+: b) where gpeek = do tag <- peekStorable gpeekSum tag (Proxy :: Proxy 0) {-# INLINE gpeek #-} +-- See https://github.com/fpco/store/issues/141 - this constraint type +-- family machinery improves error messages for generic deriving on +-- sum types with many constructors. + +type FitsInByte n = FitsInByteResult (n <=? 255) + +type family FitsInByteResult (b :: Bool) :: Constraint where + FitsInByteResult 'True = () + FitsInByteResult 'False = TypeErrorMessage + "Generic deriving of Store instances can only be used on datatypes with fewer than 256 constructors." + +type family TypeErrorMessage (a :: Symbol) :: Constraint where +#if MIN_VERSION_base(4,9,0) + TypeErrorMessage a = TypeError ('Text a) +-- GHC < 8.0 does not support empty closed type families +#elif __GLASGOW_HASKELL__ < 800 + TypeErrorMessage a = a ~ "" +#endif + -- Similarly to splitting up the generic class into multiple classes, we -- also split up the one for sum types. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/store-0.5.0.1/src/Data/Store/Internal.hs new/store-0.7.1/src/Data/Store/Internal.hs --- old/store-0.5.0.1/src/Data/Store/Internal.hs 2018-06-01 23:30:19.000000000 +0200 +++ new/store-0.7.1/src/Data/Store/Internal.hs 2019-11-17 20:28:37.000000000 +0100 @@ -76,10 +76,12 @@ import qualified Data.ByteString.Lazy as LBS import qualified Data.ByteString.Short.Internal as SBS import Data.Containers (IsMap, ContainerKey, MapValue, mapFromList, mapToList, IsSet, setFromList) +import Data.Complex (Complex (..)) import Data.Data (Data) import Data.Fixed (Fixed (..), Pico) import Data.Foldable (forM_, foldl') import Data.Functor.Contravariant +import Data.Functor.Identity (Identity (..)) import Data.HashMap.Strict (HashMap) import Data.HashSet (HashSet) import Data.Hashable (Hashable) @@ -118,10 +120,15 @@ import Foreign.Ptr (plusPtr, minusPtr) import Foreign.Storable (Storable, sizeOf) import GHC.Generics (Generic) +#ifdef INTEGER_GMP import qualified GHC.Integer.GMP.Internals as I +import GHC.Types (Int (I#)) +#else +import GHC.Types (Word (W#)) +import qualified GHC.Integer.Simple.Internals as I +#endif import GHC.Real (Ratio(..)) import GHC.TypeLits -import GHC.Types (Int (I#)) import Instances.TH.Lift () import Language.Haskell.TH import Language.Haskell.TH.Instances () @@ -132,9 +139,11 @@ import TH.Derive -- Conditional import to avoid warning +#ifdef INTEGER_GMP #if MIN_VERSION_integer_gmp(1,0,0) import GHC.Prim (sizeofByteArray#) #endif +#endif ------------------------------------------------------------------------ -- Utilities for defining list-like 'Store' instances in terms of 'IsSequence' @@ -573,6 +582,7 @@ {-# INLINE peekArray #-} instance Store Integer where +#ifdef INTEGER_GMP #if MIN_VERSION_integer_gmp(1,0,0) size = VarSize $ \ x -> sizeOf (undefined :: Word8) + case x of @@ -640,6 +650,51 @@ when (r /= 0) (peekException "Buffer size stored for encoded Integer not divisible by Word size (to get limb count).") return (I.J# sz arr) #endif +#else + -- NOTE: integer-simple uses a different encoding than GMP + size = VarSize $ \ x -> + sizeOf (undefined :: Word8) + case x of + I.Positive ds -> (1 + fromIntegral (numDigits ds)) * sizeOf (undefined :: Word) + I.Negative ds -> (1 + fromIntegral (numDigits ds)) * sizeOf (undefined :: Word) + I.Naught -> 0 + where + poke x = case x of + I.Naught -> poke (0 :: Word8) + I.Positive ds -> do + poke (1 :: Word8) + poke (numDigits ds) + pokeDigits ds + I.Negative ds -> do + poke (2 :: Word8) + poke (numDigits ds) + pokeDigits ds + where + pokeDigits I.None = pure () + pokeDigits (I.Some d ds) = poke (W# d) *> pokeDigits ds + peek = do + tag <- peek :: Peek Word8 + case tag of + 0 -> pure I.Naught + 1 -> do + len <- peek :: Peek Word + I.Positive <$> peekDigits len + 2 -> do + len <- peek :: Peek Word + I.Negative <$> peekDigits len + _ -> peekException "Invalid Integer tag" + where + peekDigits i + | i <= 0 = pure I.None + | otherwise = do + W# d <- peek + ds <- peekDigits (i - 1) + pure $! I.Some d ds + +numDigits :: I.Digits -> Word +numDigits = go 0 + where go !acc I.None = acc + go !acc (I.Some _ ds) = go (acc + 1) ds +#endif -- instance Store GHC.Fingerprint.Types.Fingerprint where @@ -666,6 +721,19 @@ poke (x :% y) = poke (x, y) peek = uncurry (:%) <$> peek +-- Similarly, manual implementation due to no Generic instance for +-- Complex and Identity in GHC-7.10 and earlier. + +instance Store a => Store (Complex a) where + size = combineSize (\(x :+ _) -> x) (\(_ :+ y) -> y) + poke (x :+ y) = poke (x, y) + peek = uncurry (:+) <$> peek + +instance Store a => Store (Identity a) where + size = contramap (\(Identity x) -> x) size + poke (Identity x) = poke x + peek = Identity <$> peek + instance Store Time.Day where size = contramap Time.toModifiedJulianDay (size :: Size Integer) poke = poke . Time.toModifiedJulianDay @@ -688,7 +756,7 @@ instance Store a => Store (First a) instance Store a => Store (Last a) instance Store a => Store (Maybe a) -instance (Store a, Store b) => Store (Either a b) +instance Store a => Store (Const a b) -- FIXME: have TH deriving handle unboxed fields? @@ -702,6 +770,7 @@ instance Deriving (Store Any) instance Deriving (Store Void) instance Deriving (Store Bool) + instance (Store a, Store b) => Deriving (Store (Either a b)) |])) -- TODO: higher arities? Limited now by Generics instances for tuples diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/store-0.5.0.1/src/Data/Store/TH/Internal.hs new/store-0.7.1/src/Data/Store/TH/Internal.hs --- old/store-0.5.0.1/src/Data/Store/TH/Internal.hs 2017-11-22 16:23:16.000000000 +0100 +++ new/store-0.7.1/src/Data/Store/TH/Internal.hs 2019-11-17 19:14:03.000000000 +0100 @@ -24,11 +24,11 @@ import Control.Applicative import Data.Complex () -import Data.Generics.Aliases (extT) -import Data.Generics.Schemes (listify, everywhere) +import Data.Generics.Aliases (extT, mkQ, extQ) +import Data.Generics.Schemes (listify, everywhere, something) import Data.List (find, nub) import qualified Data.Map as M -import Data.Maybe (fromMaybe) +import Data.Maybe (fromMaybe, isJust) import Data.Primitive.ByteArray import Data.Primitive.Types import Data.Store.Core @@ -103,9 +103,16 @@ sizeNames = zipWith (\_ -> mkName . ("sz" ++) . show) cons ints tagName = mkName "tag" valName = mkName "val" - sizeExpr = - caseE (tupE (concatMap (map sizeAtType . snd) cons)) - (if null sizeNames then [matchConstSize] else [matchConstSize, matchVarSize]) + sizeExpr + -- Maximum size of GHC tuples + | length cons <= 62 = + caseE (tupE (concatMap (map sizeAtType . snd) cons)) + (case cons of + -- Avoid overlapping matches when the case expression is () + [] -> [matchConstSize] + [c] | null (snd c) -> [matchConstSize] + _ -> [matchConstSize, matchVarSize]) + | otherwise = varSizeExpr where sizeAtType :: (Name, Type) -> ExpQ sizeAtType (_, ty) = [| size :: Size $(return ty) |] @@ -139,9 +146,11 @@ matchVarSize :: MatchQ matchVarSize = do match (tupP (map (\(n, _) -> varP n) (concatMap snd cons))) - (normalB [| VarSize $ \x -> tagSize + - $(caseE [| x |] (map matchVar cons)) |]) + (normalB varSizeExpr) [] + varSizeExpr :: ExpQ + varSizeExpr = + [| VarSize $ \x -> tagSize + $(caseE [| x |] (map matchVar cons)) |] matchVar :: (Name, [(Name, Type)]) -> MatchQ matchVar (cname, []) = match (conP cname []) (normalB [| 0 |]) [] @@ -278,13 +287,24 @@ \(TypeclassInstance cs ty _) -> let argTy = head (tail (unAppsT ty)) tyNameLit = LitE (StringL (pprint ty)) in - if p argTy + if p argTy && not (superclassHasStorable cs) then Just $ makeStoreInstance cs argTy (AppE (VarE 'sizeStorableTy) tyNameLit) (AppE (VarE 'peekStorableTy) tyNameLit) (VarE 'pokeStorable) else Nothing +-- See #143. Often Storable superclass constraints should instead be +-- Store constraints, so instead it just warns for these. +superclassHasStorable :: Cxt -> Bool +superclassHasStorable = isJust . something (mkQ Nothing justStorable `extQ` ignoreStrings) + where + justStorable :: Type -> Maybe () + justStorable (ConT n) | n == ''Storable = Just () + justStorable _ = Nothing + ignoreStrings :: String -> Maybe () + ignoreStrings _ = Nothing + ------------------------------------------------------------------------ -- Vector @@ -354,7 +374,14 @@ FamilyI _ insts <- reify ''UV.Vector return (map (everywhere (id `extT` dequalVarT) . go) insts) where -#if MIN_VERSION_template_haskell(2,11,0) +#if MIN_VERSION_template_haskell(2,15,0) + go (NewtypeInstD preds _ lhs _ con _) + | [_, ty] <- unAppsT lhs + = (preds, ty, conToDataCons con) + go (DataInstD preds _ lhs _ cons _) + | [_, ty] <- unAppsT lhs + = (preds, ty, concatMap conToDataCons cons) +#elif MIN_VERSION_template_haskell(2,11,0) go (NewtypeInstD preds _ [ty] _ con _) = (preds, ty, conToDataCons con) go (DataInstD preds _ [ty] _ cons _) = (preds, ty, concatMap conToDataCons cons) #else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/store-0.5.0.1/src/Data/Store/TH.hs new/store-0.7.1/src/Data/Store/TH.hs --- old/store-0.5.0.1/src/Data/Store/TH.hs 2017-11-22 16:23:16.000000000 +0100 +++ new/store-0.7.1/src/Data/Store/TH.hs 2019-11-17 19:14:03.000000000 +0100 @@ -37,6 +37,7 @@ , assertRoundtrip ) where +import qualified Control.Monad.Fail as Fail import Data.Complex () import Data.Store.Impl import Data.Typeable (Typeable, typeOf) @@ -60,7 +61,7 @@ expr <- [e| property $ changeDepth (\_ -> depth) $ \x -> checkRoundtrip verbose (x :: $(return ty)) |] return ("Roundtrips (" ++ pprint ty ++ ")", expr) -assertRoundtrip :: (Eq a, Show a, Store a, Monad m, Typeable a) => Bool -> a -> m () +assertRoundtrip :: (Eq a, Show a, Store a, Fail.MonadFail m, Typeable a) => Bool -> a -> m () assertRoundtrip verbose x | checkRoundtrip verbose x = return () | otherwise = fail $ "Failed to roundtrip " ++ show (typeOf x) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/store-0.5.0.1/src/Data/Store/Version.hs new/store-0.7.1/src/Data/Store/Version.hs --- old/store-0.5.0.1/src/Data/Store/Version.hs 2017-11-22 16:23:16.000000000 +0100 +++ new/store-0.7.1/src/Data/Store/Version.hs 2019-11-17 19:14:03.000000000 +0100 @@ -217,7 +217,7 @@ goField = do s <- get case sFieldNames s of - [] -> fail "impossible case in getStructureInfo'" + [] -> error "impossible case in getStructureInfo'" (name:names) -> do getStructureInfo' ignore renames (Proxy :: Proxy b) s' <- get diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/store-0.5.0.1/src/Data/Store.hs new/store-0.7.1/src/Data/Store.hs --- old/store-0.5.0.1/src/Data/Store.hs 2018-05-31 06:35:48.000000000 +0200 +++ new/store-0.7.1/src/Data/Store.hs 2019-11-17 19:14:02.000000000 +0100 @@ -10,6 +10,22 @@ -- -- If you need streaming encode / decode of multiple store encoded -- messages, take a look at the @store-streaming@ package. +-- +-- = Gotchas +-- +-- Store is best used for communication between trusted processes and +-- local caches. It can certainly be used for other purposes, but the +-- builtin set of instances have some gotchas to be aware of: +-- +-- * Store's builtin instances serialize in a format which depends on +-- machine endianness. +-- +-- * Store's builtin instances trust the data when deserializing. For +-- example, the deserialization of `Vector` will read the vector's +-- link from the first 8 bytes. It will then allocate enough memory +-- to store all the elements. Malicious or malformed input could +-- cause allocation of large amounts of memory. See +-- https://github.com/fpco/store/issues/122 module Data.Store ( -- * Encoding and decoding strict ByteStrings. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/store-0.5.0.1/src/System/IO/ByteBuffer.hs new/store-0.7.1/src/System/IO/ByteBuffer.hs --- old/store-0.5.0.1/src/System/IO/ByteBuffer.hs 2017-11-22 16:23:16.000000000 +0100 +++ new/store-0.7.1/src/System/IO/ByteBuffer.hs 2019-11-17 19:14:03.000000000 +0100 @@ -43,6 +43,7 @@ import Control.Applicative import Control.Exception (SomeException, throwIO) import Control.Exception.Lifted (Exception, bracket, catch) +import qualified Control.Monad.Fail as Fail import Control.Monad.IO.Class (MonadIO, liftIO) import Control.Monad.Trans.Control (MonadBaseControl) import Data.ByteString (ByteString) @@ -280,7 +281,7 @@ -- such the ones created by the @network@ package. -- -- Returns how many bytes could be read non-blockingly. -fillFromFd :: MonadIO m => ByteBuffer -> Fd -> Int -> m Int +fillFromFd :: (MonadIO m, Fail.MonadFail m) => ByteBuffer -> Fd -> Int -> m Int fillFromFd bb sock maxBytes = if maxBytes < 0 then fail ("fillFromFd: negative argument (" ++ show maxBytes ++ ")") else bbHandler "fillFromFd" bb go diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/store-0.5.0.1/store.cabal new/store-0.7.1/store.cabal --- old/store-0.5.0.1/store.cabal 2018-10-21 09:52:04.000000000 +0200 +++ new/store-0.7.1/store.cabal 2019-11-17 20:27:26.000000000 +0100 @@ -1,18 +1,18 @@ -cabal-version: >= 1.10 +cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.29.0. +-- This file has been generated from package.yaml by hpack version 0.31.1. -- -- see: https://github.com/sol/hpack -- --- hash: cf65d77ec7461cd466e325a485e2ac48b5cbfcf303c243e11f5b8e9674d9057e +-- hash: d5e9f1dc824c80abb31d16173dc0f03262e5125f67a92e81d0c5da4796ed8a26 name: store -version: 0.5.0.1 +version: 0.7.1 synopsis: Fast binary serialization category: Serialization, Data homepage: https://github.com/fpco/store#readme bug-reports: https://github.com/fpco/store/issues -maintainer: Michael Sloan <[email protected]> +maintainer: Michael Sloan <[email protected]> copyright: 2016 FP Complete license: MIT license-file: LICENSE @@ -29,6 +29,11 @@ manual: True default: False +flag integer-simple + description: Use the [simple integer library](http://hackage.haskell.org/package/integer-simple) instead of [integer-gmp](http://hackage.haskell.org/package/integer-gmp) + manual: False + default: False + flag small-bench manual: True default: False @@ -61,13 +66,13 @@ , cryptohash >=0.11.6 , deepseq >=1.3.0.2 , directory >=1.2 + , fail >=4.9 , filepath >=1.3 , free >=4.11 , ghc-prim >=0.3.1.0 , hashable >=1.2.3.1 , hspec >=2.1.2 , hspec-smallcheck >=0.3.0 - , integer-gmp >=0.5.1.0 , lifted-base >=0.2.3.3 , monad-control >=0.3.3.0 , mono-traversable >=0.7.0 @@ -83,7 +88,7 @@ , text >=1.2.0.4 , th-lift >=0.7.1 , th-lift-instances >=0.1.4 - , th-orphans >=0.12.2 + , th-orphans >=0.13.2 , th-reify-many >=0.1.6 , th-utilities >=0.2 , time >=1.4.2 @@ -91,6 +96,13 @@ , unordered-containers >=0.2.5.1 , vector >=0.10.12.3 , void >=0.5.11 + if flag(integer-simple) + build-depends: + integer-simple >=0.1.1.1 + else + cpp-options: -DINTEGER_GMP + build-depends: + integer-gmp >=0.5.1.0 default-language: Haskell2010 test-suite store-test @@ -118,13 +130,13 @@ , cryptohash >=0.11.6 , deepseq >=1.3.0.2 , directory >=1.2 + , fail >=4.9 , filepath >=1.3 , free >=4.11 , ghc-prim >=0.3.1.0 , hashable >=1.2.3.1 , hspec >=2.1.2 , hspec-smallcheck >=0.3.0 - , integer-gmp >=0.5.1.0 , lifted-base >=0.2.3.3 , monad-control >=0.3.3.0 , mono-traversable >=0.7.0 @@ -141,7 +153,7 @@ , text >=1.2.0.4 , th-lift >=0.7.1 , th-lift-instances >=0.1.4 - , th-orphans >=0.12.2 + , th-orphans >=0.13.2 , th-reify-many >=0.1.6 , th-utilities >=0.2 , time >=1.4.2 @@ -149,14 +161,23 @@ , unordered-containers >=0.2.5.1 , vector >=0.10.12.3 , void >=0.5.11 + if flag(integer-simple) + build-depends: + integer-simple >=0.1.1.1 + else + cpp-options: -DINTEGER_GMP + build-depends: + integer-gmp >=0.5.1.0 default-language: Haskell2010 -test-suite store-weigh +benchmark store-bench type: exitcode-stdio-1.0 - main-is: Allocations.hs + main-is: Bench.hs + other-modules: + Paths_store hs-source-dirs: - test - ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -O2 -threaded -rtsopts -with-rtsopts=-N -with-rtsopts=-T -O2 + bench + ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -O2 -threaded -rtsopts -with-rtsopts=-N1 -with-rtsopts=-s -with-rtsopts=-qg build-depends: array >=0.5.0.0 , async >=2.0.2 @@ -165,21 +186,19 @@ , base64-bytestring >=0.1.1 , bifunctors >=4.0 , bytestring >=0.10.4.0 - , cereal - , cereal-vector , containers >=0.5.5.1 , contravariant >=1.3 , criterion , cryptohash >=0.11.6 , deepseq >=1.3.0.2 , directory >=1.2 + , fail >=4.9 , filepath >=1.3 , free >=4.11 , ghc-prim >=0.3.1.0 , hashable >=1.2.3.1 , hspec >=2.1.2 , hspec-smallcheck >=0.3.0 - , integer-gmp >=0.5.1.0 , lifted-base >=0.2.3.3 , monad-control >=0.3.3.0 , mono-traversable >=0.7.0 @@ -196,26 +215,38 @@ , text >=1.2.0.4 , th-lift >=0.7.1 , th-lift-instances >=0.1.4 - , th-orphans >=0.12.2 + , th-orphans >=0.13.2 , th-reify-many >=0.1.6 , th-utilities >=0.2 , time >=1.4.2 , transformers >=0.3.0.0 , unordered-containers >=0.2.5.1 , vector >=0.10.12.3 - , vector-binary-instances , void >=0.5.11 - , weigh + if flag(integer-simple) + build-depends: + integer-simple >=0.1.1.1 + else + cpp-options: -DINTEGER_GMP + build-depends: + integer-gmp >=0.5.1.0 + if flag(comparison-bench) + cpp-options: -DCOMPARISON_BENCH + build-depends: + binary + , cereal + , cereal-vector + , vector-binary-instances + if flag(small-bench) + cpp-options: -DSMALL_BENCH default-language: Haskell2010 -benchmark store-bench +benchmark store-weigh type: exitcode-stdio-1.0 - main-is: Bench.hs - other-modules: - Paths_store + main-is: Allocations.hs hs-source-dirs: - bench - ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -O2 -threaded -rtsopts -with-rtsopts=-N1 -with-rtsopts=-s -with-rtsopts=-qg + test + ghc-options: -Wall -fwarn-tabs -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -O2 -threaded -rtsopts -with-rtsopts=-N -with-rtsopts=-T -O2 build-depends: array >=0.5.0.0 , async >=2.0.2 @@ -224,19 +255,21 @@ , base64-bytestring >=0.1.1 , bifunctors >=4.0 , bytestring >=0.10.4.0 + , cereal + , cereal-vector , containers >=0.5.5.1 , contravariant >=1.3 , criterion , cryptohash >=0.11.6 , deepseq >=1.3.0.2 , directory >=1.2 + , fail >=4.9 , filepath >=1.3 , free >=4.11 , ghc-prim >=0.3.1.0 , hashable >=1.2.3.1 , hspec >=2.1.2 , hspec-smallcheck >=0.3.0 - , integer-gmp >=0.5.1.0 , lifted-base >=0.2.3.3 , monad-control >=0.3.3.0 , mono-traversable >=0.7.0 @@ -253,21 +286,21 @@ , text >=1.2.0.4 , th-lift >=0.7.1 , th-lift-instances >=0.1.4 - , th-orphans >=0.12.2 + , th-orphans >=0.13.2 , th-reify-many >=0.1.6 , th-utilities >=0.2 , time >=1.4.2 , transformers >=0.3.0.0 , unordered-containers >=0.2.5.1 , vector >=0.10.12.3 + , vector-binary-instances , void >=0.5.11 - if flag(comparison-bench) - cpp-options: -DCOMPARISON_BENCH + , weigh + if flag(integer-simple) build-depends: - binary - , cereal - , cereal-vector - , vector-binary-instances - if flag(small-bench) - cpp-options: -DSMALL_BENCH + integer-simple >=0.1.1.1 + else + cpp-options: -DINTEGER_GMP + build-depends: + integer-gmp >=0.5.1.0 default-language: Haskell2010 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/store-0.5.0.1/test/Data/StoreSpec.hs new/store-0.7.1/test/Data/StoreSpec.hs --- old/store-0.5.0.1/test/Data/StoreSpec.hs 2018-10-21 09:43:29.000000000 +0200 +++ new/store-0.7.1/test/Data/StoreSpec.hs 2019-11-17 20:28:37.000000000 +0100 @@ -16,6 +16,7 @@ import Control.Applicative import Control.Exception (evaluate) import Control.Monad (unless) +import Control.Monad.Fail (MonadFail) import qualified Data.Array.Unboxed as A import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as LBS @@ -31,7 +32,9 @@ import qualified Data.List.NonEmpty as NE import Data.Map (Map) import Data.Monoid +#if !MIN_VERSION_primitive(0,7,0) import Data.Primitive.Types (Addr) +#endif import Data.Proxy (Proxy(..)) import Data.Sequence (Seq) import Data.Sequences (fromList) @@ -233,11 +236,6 @@ instance Monad m => Serial m Void where series = generate (\_ -> []) -#if !MIN_VERSION_template_haskell(2,11,0) -deriving instance Show NameFlavour -deriving instance Show NameSpace -#endif - -- We define our own Serial instance for 'Ratio' because of <https://github.com/feuerbach/smallcheck/pull/34> newtype SerialRatio a = SerialRatio (Ratio a) @@ -284,9 +282,11 @@ spec = do describe "Store on all monomorphic instances" $(do insts <- getAllInstanceTypes1 ''Store - omitTys0 <- sequence - [ [t| Addr |] - , [t| CUIntPtr |] + omitTys0 <- sequence $ +#if !MIN_VERSION_primitive(0,7,0) + [t| Addr |] : +#endif + [ [t| CUIntPtr |] , [t| CIntPtr |] , [t| IntPtr |] , [t| WordPtr |] @@ -303,7 +303,7 @@ filtered = filter f insts smallcheckManyStore verbose 2 $ map return filtered) it "Store on non-numeric Float/Double values" $ do - let testNonNumeric :: forall a m. (RealFloat a, Eq a, Show a, Typeable a, Store a, Monad m) => Proxy a -> m () + let testNonNumeric :: forall a m. (RealFloat a, Eq a, Show a, Typeable a, Store a, Monad m, MonadFail m) => Proxy a -> m () testNonNumeric _proxy = do assertRoundtrip verbose ((1/0) :: a) assertRoundtrip verbose ((-1/0) :: a)
