store 0.5.1.0 → 0.5.1.1
raw patch · 3 files changed
+30/−5 lines, 3 filesdep ~basedep ~template-haskellPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base, template-haskell
API changes (from Hackage documentation)
- Data.Store.Internal: instance Data.Store.Impl.Store (Data.Vector.Primitive.Vector Data.Primitive.Types.Addr)
+ Data.Store.Internal: instance Data.Primitive.Types.Prim a => Data.Store.Impl.Store (Data.Vector.Primitive.Vector (Data.Functor.Const.Const a b))
+ Data.Store.Internal: instance Data.Primitive.Types.Prim a => Data.Store.Impl.Store (Data.Vector.Primitive.Vector (Data.Functor.Identity.Identity a))
+ Data.Store.Internal: instance Data.Primitive.Types.Prim a => Data.Store.Impl.Store (Data.Vector.Primitive.Vector (Data.Ord.Down a))
+ Data.Store.Internal: instance Data.Primitive.Types.Prim a => Data.Store.Impl.Store (Data.Vector.Primitive.Vector (Data.Semigroup.First a))
+ Data.Store.Internal: instance Data.Primitive.Types.Prim a => Data.Store.Impl.Store (Data.Vector.Primitive.Vector (Data.Semigroup.Internal.Dual a))
+ Data.Store.Internal: instance Data.Primitive.Types.Prim a => Data.Store.Impl.Store (Data.Vector.Primitive.Vector (Data.Semigroup.Internal.Product a))
+ Data.Store.Internal: instance Data.Primitive.Types.Prim a => Data.Store.Impl.Store (Data.Vector.Primitive.Vector (Data.Semigroup.Internal.Sum a))
+ Data.Store.Internal: instance Data.Primitive.Types.Prim a => Data.Store.Impl.Store (Data.Vector.Primitive.Vector (Data.Semigroup.Last a))
+ Data.Store.Internal: instance Data.Primitive.Types.Prim a => Data.Store.Impl.Store (Data.Vector.Primitive.Vector (Data.Semigroup.Max a))
+ Data.Store.Internal: instance Data.Primitive.Types.Prim a => Data.Store.Impl.Store (Data.Vector.Primitive.Vector (Data.Semigroup.Min a))
+ Data.Store.Internal: instance Data.Store.Impl.Store (Data.Vector.Primitive.Vector (GHC.Stable.StablePtr a))
Files
- ChangeLog.md +6/−0
- src/Data/Store/Impl.hs +22/−3
- store.cabal +2/−2
ChangeLog.md view
@@ -1,5 +1,11 @@ # ChangeLog +## 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.
src/Data/Store/Impl.hs view
@@ -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,20 +265,36 @@ -- 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)+#endif -- Similarly to splitting up the generic class into multiple classes, we -- also split up the one for sum types.
store.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 5c038df3338fc7661664ddc082dde9288b48c1153a7680a63b2aed528590535e+-- hash: a18e85521a544ee521dc7788e9b2194c7c3ec0efbeb6092e401782d962ea22d3 name: store-version: 0.5.1.0+version: 0.5.1.1 synopsis: Fast binary serialization category: Serialization, Data homepage: https://github.com/fpco/store#readme