store 0.7.2 → 0.7.3
raw patch · 5 files changed
+44/−6 lines, 5 files
Files
- ChangeLog.md +7/−0
- src/Data/Store/Internal.hs +14/−0
- src/Data/Store/TH/Internal.hs +1/−1
- store.cabal +2/−2
- test/Data/StoreSpec.hs +20/−3
ChangeLog.md view
@@ -1,5 +1,12 @@ # ChangeLog +## 0.7.3++* Fixes compilation with `ghc-8.10`, particularly+ `template-haskell-2.16.0.0`. See [#149][].++[#149]: https://github.com/fpco/store/issues/149+ ## 0.7.2 * Fixes compilation with `vector >= 0.12.1.1` by making
src/Data/Store/Internal.hs view
@@ -399,6 +399,20 @@ fp <- peekToPlainForeignPtr "Data.ByteString.ByteString" len return (BS.PS fp 0 len) +-- | Template Haskell Bytes are nearly identical to ByteString, but it+-- can't depend on ByteString.+instance Store Bytes where+ size = VarSize $ \x ->+ sizeOf (undefined :: Int) ++ fromIntegral (bytesSize x)+ poke (Bytes sourceFp sourceOffset sourceLength) = do+ poke sourceLength+ pokeFromForeignPtr sourceFp (fromIntegral sourceOffset) (fromIntegral sourceLength)+ peek = do+ len <- peek+ fp <- peekToPlainForeignPtr "Data.ByteString.ByteString" (fromIntegral len)+ return (Bytes fp 0 len)+ instance Store SBS.ShortByteString where size = VarSize $ \x -> sizeOf (undefined :: Int) +
src/Data/Store/TH/Internal.hs view
@@ -26,7 +26,7 @@ import Data.Complex () import Data.Generics.Aliases (extT, mkQ, extQ) import Data.Generics.Schemes (listify, everywhere, something)-import Data.List (find, nub)+import Data.List (find) import qualified Data.Map as M import Data.Maybe (fromMaybe, isJust) import Data.Primitive.ByteArray
store.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 196a4a2e4a6b3e3eaf65b19fdbd12fea95fc3f94de915299ff2ebd319ba41302+-- hash: e4f0078547f11838248333341a491371c654d004c243fe8f6b750d9988225242 name: store-version: 0.7.2+version: 0.7.3 synopsis: Fast binary serialization category: Serialization, Data homepage: https://github.com/fpco/store#readme
test/Data/StoreSpec.hs view
@@ -23,6 +23,7 @@ import qualified Data.ByteString.Short as SBS import Data.Complex (Complex(..)) import Data.Containers (mapFromList, setFromList)+import Data.Generics (listify) import Data.HashMap.Strict (HashMap) import Data.HashSet (HashSet) import Data.Hashable (Hashable)@@ -70,6 +71,7 @@ import System.Posix.Types import Test.Hspec hiding (runIO) import Test.SmallCheck.Series+import TH.Utilities (unAppsT) ------------------------------------------------------------------------ -- Instances for base types@@ -136,15 +138,21 @@ $(do tys <- getAllInstanceTypes1 ''PV.Prim let f ty = [d| instance (Serial m $(return ty), Monad m) => Serial m (PV.Vector $(return ty)) where series = fmap PV.fromList series |]- concat <$> mapM f tys)+ concat <$> mapM f (filter (\ty -> length (unAppsT ty) == 1) tys)) --- Instance needed for generic TH instances+{-+-- Instances for TH are not currently needed, because the tests for+-- serialization roundtripping are disabled due to Bytes' Eq instance,+-- see issue #150. -- Needs to be done manually because in GHC 7.8's TH, NameFlavour uses -- unboxed values and cannot use generic deriving. So we skip having an -- instance for it. instance Monad m => Serial m Name where series = fmap mkName series +instance Monad m => Serial m Bytes where+ series = fmap ((\(BS.PS p o l) -> Bytes p (fromIntegral o) (fromIntegral l)) . BS.pack) series+ -- Serial instances for (Generic a) types. -- FIXME: generating for TH instances is probably just adding@@ -156,11 +164,18 @@ let ns = [ ''Any, ''All ] ++ thNames f n = [d| instance Monad m => Serial m $(conT n) |] concat <$> mapM f ns)+-} $(do let ns = [ ''Dual, ''Sum, ''Product, ''First, ''Last ] f n = [d| instance (Monad m, Serial m a) => Serial m ($(conT n) a) |] concat <$> mapM f ns) +instance Monad m => Serial m Any where+ series = fmap Any series++instance Monad m => Serial m All where+ series = fmap All series+ instance Monad m => Serial m Fingerprint where series = generate (\_ -> [Fingerprint 0 0, Fingerprint maxBound maxBound]) @@ -299,8 +314,10 @@ , [t| TimeSpec |] ] omitTys <- (omitTys0 ++) <$> mapM (\ty -> [t| PV.Vector $(pure ty) |]) omitTys0- let f ty = isMonoType ty && ty `notElem` omitTys+ let f ty = isMonoType ty && ty `notElem` omitTys && null (listify isThName ty) filtered = filter f insts+ -- Roundtrip testing of TH instances is disabled - see issue #150+ isThName n = nameModule n == Just "Language.Haskell.TH.Syntax" 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, MonadFail m) => Proxy a -> m ()