store 0.7.0 → 0.7.1
raw patch · 6 files changed
+63/−15 lines, 6 filesdep ~th-orphansPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: th-orphans
API changes (from Hackage documentation)
Files
- ChangeLog.md +9/−0
- README.md +17/−0
- src/Data/Store.hs +16/−0
- src/Data/Store/Internal.hs +15/−4
- store.cabal +6/−6
- test/Data/StoreSpec.hs +0/−5
ChangeLog.md view
@@ -1,5 +1,14 @@ # 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
README.md view
@@ -41,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)
src/Data/Store.hs view
@@ -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.
src/Data/Store/Internal.hs view
@@ -76,12 +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.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.Functor.Identity (Identity (..)) import Data.HashMap.Strict (HashMap) import Data.HashSet (HashSet) import Data.Hashable (Hashable)@@ -721,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@@ -743,8 +756,6 @@ instance Store a => Store (First a) instance Store a => Store (Last a) instance Store a => Store (Maybe a)-instance Store a => Store (Identity a)-instance Store a => Store (Complex a) instance Store a => Store (Const a b) -- FIXME: have TH deriving handle unboxed fields?
store.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: e97026b3dd607ae815326e726b09a470b5b4bb879c5d9faaee87ef206e9a4830+-- hash: d5e9f1dc824c80abb31d16173dc0f03262e5125f67a92e81d0c5da4796ed8a26 name: store-version: 0.7.0+version: 0.7.1 synopsis: Fast binary serialization category: Serialization, Data homepage: https://github.com/fpco/store#readme@@ -88,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@@ -153,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@@ -215,7 +215,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@@ -286,7 +286,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
test/Data/StoreSpec.hs view
@@ -236,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)