store 0.7.7 → 0.7.8
raw patch · 4 files changed
+35/−6 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Store.Internal: instance (GHC.Arr.Ix i, Data.Array.Base.IArray Data.Array.Base.UArray e, Data.Store.Impl.Store i, Data.Store.Impl.Store e) => Data.Store.Impl.Store (Data.Array.Base.UArray i e)
- Data.Store.Internal: instance (GHC.Arr.Ix i, Data.Store.Impl.Store i, Data.Store.Impl.Store e) => Data.Store.Impl.Store (GHC.Arr.Array i e)
+ Data.Store.Internal: instance (GHC.Ix.Ix i, Data.Array.Base.IArray Data.Array.Base.UArray e, Data.Store.Impl.Store i, Data.Store.Impl.Store e) => Data.Store.Impl.Store (Data.Array.Base.UArray i e)
+ Data.Store.Internal: instance (GHC.Ix.Ix i, Data.Store.Impl.Store i, Data.Store.Impl.Store e) => Data.Store.Impl.Store (GHC.Arr.Array i e)
+ Data.Store.Internal: instance Data.Store.Impl.Store GHC.Natural.Natural
+ Data.Store.Internal: instance Data.Store.Impl.Store Language.Haskell.TH.Syntax.Bytes
- Data.Store: decodeExPortionWith :: () => Peek a -> ByteString -> (Offset, a)
+ Data.Store: decodeExPortionWith :: Peek a -> ByteString -> (Offset, a)
- Data.Store: decodeExWith :: () => Peek a -> ByteString -> a
+ Data.Store: decodeExWith :: Peek a -> ByteString -> a
- Data.Store: decodeIOPortionWith :: () => Peek a -> ByteString -> IO (Offset, a)
+ Data.Store: decodeIOPortionWith :: Peek a -> ByteString -> IO (Offset, a)
- Data.Store: decodeIOWith :: () => Peek a -> ByteString -> IO a
+ Data.Store: decodeIOWith :: Peek a -> ByteString -> IO a
- Data.Store: decodeWith :: () => Peek a -> ByteString -> Either PeekException a
+ Data.Store: decodeWith :: Peek a -> ByteString -> Either PeekException a
- Data.Store: peekException :: () => Text -> Peek a
+ Data.Store: peekException :: Text -> Peek a
- Data.Store.Internal: StaticSize :: a -> StaticSize a
+ Data.Store.Internal: StaticSize :: a -> StaticSize (n :: Nat) a
- Data.Store.Internal: [unStaticSize] :: StaticSize a -> a
+ Data.Store.Internal: [unStaticSize] :: StaticSize (n :: Nat) a -> a
- Data.Store.Internal: decodeExPortionWith :: () => Peek a -> ByteString -> (Offset, a)
+ Data.Store.Internal: decodeExPortionWith :: Peek a -> ByteString -> (Offset, a)
- Data.Store.Internal: decodeExWith :: () => Peek a -> ByteString -> a
+ Data.Store.Internal: decodeExWith :: Peek a -> ByteString -> a
- Data.Store.Internal: decodeIOPortionWith :: () => Peek a -> ByteString -> IO (Offset, a)
+ Data.Store.Internal: decodeIOPortionWith :: Peek a -> ByteString -> IO (Offset, a)
- Data.Store.Internal: decodeIOWith :: () => Peek a -> ByteString -> IO a
+ Data.Store.Internal: decodeIOWith :: Peek a -> ByteString -> IO a
- Data.Store.Internal: decodeWith :: () => Peek a -> ByteString -> Either PeekException a
+ Data.Store.Internal: decodeWith :: Peek a -> ByteString -> Either PeekException a
- Data.Store.Internal: peekException :: () => Text -> Peek a
+ Data.Store.Internal: peekException :: Text -> Peek a
- Data.Store.Internal: pokeException :: () => Text -> Poke a
+ Data.Store.Internal: pokeException :: Text -> Poke a
- Data.Store.Internal: tooManyBytes :: () => Int -> Int -> String -> IO void
+ Data.Store.Internal: tooManyBytes :: Int -> Int -> String -> IO void
Files
- ChangeLog.md +6/−0
- src/Data/Store/Internal.hs +12/−0
- store.cabal +2/−2
- test/Data/StoreSpec.hs +15/−4
ChangeLog.md view
@@ -1,5 +1,11 @@ # ChangeLog +## 0.7.8++* Adds a `Store` instance for `Natural`. See [#154][].++[#154]: https://github.com/mgsloan/store/issues/154+ ## 0.7.7 * Test now compiles with `smallcheck >= 1.2` and `base >= 4.14`.
src/Data/Store/Internal.hs view
@@ -135,6 +135,7 @@ import Language.Haskell.TH.ReifyMany import Language.Haskell.TH.Syntax import Network.Socket (AddrInfo)+import Numeric.Natural (Natural) import Prelude import TH.Derive @@ -711,6 +712,17 @@ where go !acc I.None = acc go !acc (I.Some _ ds) = go (acc + 1) ds #endif++-- Piggybacks off of the Integer instance++instance Store Natural where+ size = contramap fromIntegral (size :: Size Integer)+ poke = poke . toInteger+ peek = do+ x <- peek :: Peek Integer+ if x < 0+ then peekException "Encountered negative integer when expecting a Natural"+ else return $ fromIntegral x -- instance Store GHC.Fingerprint.Types.Fingerprint where
store.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 0d992daa83559baa310905729749defd6734060ce7c1b6bdcebee8b782a81f0d+-- hash: 15f2b9eaacfa66b2ffec07be091687b82f176b78e38bfd203f2e3e38d02bfa33 name: store-version: 0.7.7+version: 0.7.8 synopsis: Fast binary serialization category: Serialization, Data homepage: https://github.com/fpco/store#readme
test/Data/StoreSpec.hs view
@@ -64,6 +64,7 @@ import Language.Haskell.TH import Language.Haskell.TH.Syntax import Network.Socket+import Numeric.Natural (Natural) import Prelude import System.Clock (TimeSpec) import System.Posix.Types@@ -139,11 +140,13 @@ , ''CSUSeconds, ''CFloat, ''CDouble ] ++ #endif-#ifdef mingw32_HOST_OS- []-#else- [ ''CSpeed, ''CCc ]+#if !MIN_VERSION_smallcheck(1,1,3)+ [ ''Natural ] ++ #endif+#ifndef mingw32_HOST_OS+ [ ''CSpeed, ''CCc ] +++#endif+ [] f n = [d| instance Monad m => Serial m $(conT n) where series = generate (\_ -> [0, 1]) |] concat <$> mapM f ns)@@ -456,7 +459,11 @@ (decodeEx bs :: HashMap Int ()) `shouldBe` m evaluate (decodeEx bs :: Map Int ()) `shouldThrow` isUnexpectedMarkerException evaluate (decodeEx bs :: IntMap ()) `shouldThrow` isUnexpectedMarkerException+ it "Expects decode of negative integer as a natural to throw PeekException" $ do+ evaluate (decodeEx (encode ((-5) :: Integer)) :: Natural)+ `shouldThrow` isNegativeNaturalException + isPokeException :: Test.Hspec.Selector PokeException isPokeException = const True @@ -469,3 +476,7 @@ isUnexpectedMarkerException :: Test.Hspec.Selector PeekException isUnexpectedMarkerException (PeekException _ t) = "Expected marker for ascending Map / IntMap: " `T.isPrefixOf` t++isNegativeNaturalException :: Test.Hspec.Selector PeekException+isNegativeNaturalException (PeekException _ t) =+ "Encountered negative integer when expecting a Natural" `T.isPrefixOf` t