typerep-map 0.5.0.0 → 0.6.0.0
raw patch · 6 files changed
+76/−27 lines, 6 filesdep ~basedep ~criteriondep ~ghc-prim
Dependency ranges changed: base, criterion, ghc-prim, hedgehog, hspec, vector
Files
- CHANGELOG.md +8/−0
- benchmark/CMap.hs +1/−1
- benchmark/CacheMap.hs +1/−1
- benchmark/DMap.hs +1/−1
- src/Data/TypeRepMap/Internal.hs +51/−16
- typerep-map.cabal +14/−8
CHANGELOG.md view
@@ -3,6 +3,14 @@ `typerep-map` uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. +## 0.6.0.0 — Nov 2, 2022++* [#125](https://github.com/kowainik/typerep-map/issues/125):+ Support GHC-9.4.+* Allow `vector-0.13`.+* Allow `hedgehog-1.2` and `hspec-2.10`.+* Allow `criterion-1.6`.+ ## 0.5.0.0 — Feb 15, 2022 * [#117](https://github.com/kowainik/typerep-map/issues/117):
benchmark/CMap.hs view
@@ -59,7 +59,7 @@ -> Proxy (a :: Nat) -> TypeRepMap (Proxy :: Nat -> Type) inserts !c 0 _ = c-inserts !c n x = inserts+inserts c n x = inserts (insert x c) (n - 1) (Proxy :: Proxy (a + 1))
benchmark/CacheMap.hs view
@@ -60,7 +60,7 @@ -> Proxy (a :: Nat) -> TypeRepMap (Proxy :: Nat -> Type) inserts !c 0 _ = c-inserts !c n x = inserts+inserts c n x = inserts (insert x c) (n - 1) (Proxy :: Proxy (a + 1))
benchmark/DMap.hs view
@@ -61,7 +61,7 @@ -> Proxy (a :: Nat) -> TypeRepMap (Proxy :: Nat -> Type) inserts !c 0 _ = c-inserts !c n x = inserts+inserts c n x = inserts (insert (typeRep @a) x c) (n - 1) (Proxy :: Proxy (a + 1))
src/Data/TypeRepMap/Internal.hs view
@@ -56,6 +56,9 @@ import Data.Semigroup (All (..), Semigroup (..)) import Data.Type.Equality (TestEquality (..), (:~:) (..)) import GHC.Base (Any, Int (..), Int#, (*#), (+#), (<#))+#if MIN_VERSION_base(4,17,0)+import GHC.Base (word64ToWord#)+#endif import GHC.Exts (IsList (..), inline, sortWith) import GHC.Fingerprint (Fingerprint (..)) #if WORD_SIZE_IN_BITS >= 64@@ -459,17 +462,49 @@ cachedBinarySearch (Fingerprint (W64# a) (W64# b)) fpAs fpBs = inline (go 0#) where go :: Int# -> Maybe Int+#if MIN_VERSION_base(4,17,0) go i = case i <# len of 0# -> Nothing- _ -> let !(W64# valA) = indexPrimArray fpAs (I# i) in case a `ltWord#` valA of- 0# -> case a `eqWord#` valA of- 0# -> go (2# *# i +# 2#)- _ -> let !(W64# valB) = indexPrimArray fpBs (I# i) in case b `eqWord#` valB of- 0# -> case b `ltWord#` valB of- 0# -> go (2# *# i +# 2#)- _ -> go (2# *# i +# 1#)- _ -> Just (I# i)- _ -> go (2# *# i +# 1#)+ _ ->+ let !(W64# (word64ToWord# -> valA)) = indexPrimArray fpAs (I# i)+ !a' = word64ToWord# a+ !b' = word64ToWord# b+ in+ case a' `ltWord#` valA of+ 0# ->+ case a' `eqWord#` valA of+ 0# -> go (2# *# i +# 2#)+ _ ->+ let !(W64# valB) = indexPrimArray fpBs (I# i)+ in+ case word64ToWord# b `eqWord#` word64ToWord# valB of+ 0# ->+ case b' `ltWord#` word64ToWord# valB of+ 0# -> go (2# *# i +# 2#)+ _ -> go (2# *# i +# 1#)+ _ -> Just (I# i)+ _ -> go (2# *# i +# 1#)+#else+ go i = case i <# len of+ 0# -> Nothing+ _ ->+ let !(W64# valA) = indexPrimArray fpAs (I# i)+ in+ case a `ltWord#` valA of+ 0# ->+ case a `eqWord#` valA of+ 0# -> go (2# *# i +# 2#)+ _ ->+ let !(W64# valB) = indexPrimArray fpBs (I# i)+ in+ case b `eqWord#` valB of+ 0# ->+ case b `ltWord#` valB of+ 0# -> go (2# *# i +# 2#)+ _ -> go (2# *# i +# 1#)+ _ -> Just (I# i)+ _ -> go (2# *# i +# 1#)+#endif len :: Int# len = let !(I# l) = sizeofPrimArray fpAs in l@@ -641,20 +676,20 @@ sz = sizeofPrimArray fingerprintAs check i | i >= sz = All True | otherwise =- let left = i*2+1- right = i*2+2+ let left = i * 2 + 1+ right = i * 2 + 2 -- maximum value in the left branch leftMax = fmap (\j -> (indexPrimArray fingerprintAs j, indexPrimArray fingerprintBs j)) $ lastMay- $ takeWhile (<sz)- $ iterate (\j -> j*2+2) left+ $ takeWhile (< sz)+ $ iterate (\j -> j * 2 + 2) left -- minimum value in the right branch rightMin = fmap (\j -> (indexPrimArray fingerprintAs j, indexPrimArray fingerprintBs j)) $ lastMay- $ takeWhile (<sz)- $ iterate (\j -> j*2+1) right+ $ takeWhile (< sz)+ $ iterate (\j -> j * 2 + 1) right in mconcat [ All $ if left < sz@@ -673,5 +708,5 @@ GT -> False else True , All $ fromMaybe True $ (<=) <$> leftMax <*> rightMin- , check (i+1)+ , check (i + 1) ]
typerep-map.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: typerep-map-version: 0.5.0.0+version: 0.6.0.0 synopsis: Efficient implementation of a dependent map with types as keys description: A dependent map from type representations to values of these types.@@ -34,14 +34,15 @@ , GHC == 8.8.4 , GHC == 8.10.7 , GHC == 9.0.2- , GHC == 9.2.1+ , GHC == 9.2.4+ , GHC == 9.4.2 source-repository head type: git location: https://github.com/kowainik/typerep-map.git common common-options- build-depends: base >= 4.10 && < 4.17+ build-depends: base >= 4.10 && < 4.18 default-language: Haskell2010 default-extensions: BangPatterns@@ -65,6 +66,11 @@ -Werror=missing-deriving-strategies if impl(ghc >= 8.10) ghc-options: -Wunused-packages+ if impl(ghc >= 9.0)+ ghc-options: -Winvalid-haddock+ if impl(ghc >= 9.2)+ ghc-options: -Wredundant-bang-patterns+ -Woperator-whitespace library import: common-options@@ -73,7 +79,7 @@ Data.TypeRepMap Data.TypeRepMap.Internal - build-depends: ghc-prim >= 0.5.1.1 && < 0.9+ build-depends: ghc-prim >= 0.5.1.1 && < 0.10 , primitive ^>= 0.7.0 , deepseq ^>= 1.4 @@ -85,7 +91,7 @@ Data.TypeRep.Vector build-depends: containers >= 0.5.10.2 && < 0.7- , vector ^>= 0.12.0.1+ , vector >= 0.12.0.1 && < 0.14 , deepseq ^>= 1.4 test-suite typerep-map-test@@ -101,8 +107,8 @@ , Test.TypeRep.VectorOpt build-depends: ghc-typelits-knownnat >= 0.4.2 && < 0.8- , hedgehog >= 1.0 && < 1.2- , hspec >= 2.7.1 && < 2.10+ , hedgehog >= 1.0 && < 1.3+ , hspec >= 2.7.1 && < 2.11 , hspec-hedgehog ^>= 0.0.1 , typerep-map , typerep-extra-impls@@ -122,7 +128,7 @@ , Vector , OptimalVector - build-depends: criterion >= 1.4.1.0 && < 1.6+ build-depends: criterion >= 1.4.1.0 && < 1.7 , deepseq ^>= 1.4.3.0 , dependent-map >= 0.2.4.0 && < 0.5 , dependent-sum >= 0.5 && < 0.8