data-inttrie 0.0.8 → 0.0.9
raw patch · 2 files changed
+18/−2 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.IntTrie: modify' :: (Ord b, Num b, Bits b) => b -> (a -> a) -> IntTrie a -> IntTrie a
Files
- Data/IntTrie.hs +17/−1
- data-inttrie.cabal +1/−1
Data/IntTrie.hs view
@@ -17,7 +17,7 @@ ------------------------------------------------------------- module Data.IntTrie - ( IntTrie, identity, apply, modify, overwrite )+ ( IntTrie, identity, apply, modify, modify', overwrite ) where import Control.Applicative@@ -87,6 +87,22 @@ | x == 1 = BitTrie (f one) even odd | testBit x 0 = BitTrie one even (modifyPositive (x `shiftR` 1) f odd) | otherwise = BitTrie one (modifyPositive (x `shiftR` 1) f even) odd+++-- | Modify the function at one point (strict version)+modify' :: (Ord b, Num b, Bits b) => b -> (a -> a) -> IntTrie a -> IntTrie a+modify' x f (IntTrie neg z pos) =+ case compare x 0 of+ LT -> (IntTrie $! modifyPositive' (-x) f neg) z pos+ EQ -> (IntTrie neg $! f z) pos+ GT -> IntTrie neg z $! modifyPositive' x f pos++modifyPositive' :: (Num b, Bits b) => b -> (a -> a) -> BitTrie a -> BitTrie a+modifyPositive' x f (BitTrie one even odd)+ | x == 1 = (BitTrie $! f one) even odd+ | testBit x 0 = BitTrie one even $! modifyPositive' (x `shiftR` 1) f odd+ | otherwise = (BitTrie one $! modifyPositive' (x `shiftR` 1) f even) odd+ -- | Overwrite the function at one point --
data-inttrie.cabal view
@@ -1,7 +1,7 @@ Name: data-inttrie Description: A simple lazy, infinite trie from integers.-Version: 0.0.8+Version: 0.0.9 Stability: experimental Synopsis: A lazy, infinite trie of integers. License: BSD3