variety 0.1.0.0 → 0.1.0.1
raw patch · 3 files changed
+40/−25 lines, 3 filesdep −extraPVP ok
version bump matches the API change (PVP)
Dependencies removed: extra
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- src/Codec/Arithmetic/Variety/BitVec.hs +7/−4
- variety.cabal +29/−21
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for variety +## 0.1.0.1 -- 2025-06-05++* Removed dependency on extra+ ## 0.1.0.0 -- 2025-06-04 * First version.
src/Codec/Arithmetic/Variety/BitVec.hs view
@@ -42,7 +42,6 @@ import qualified Data.Bits as Bits import Data.Word (Word8) import qualified Data.List as L-import qualified Data.List.Extra as L import Data.ByteString.Lazy (ByteString) import qualified Data.ByteString.Lazy as BS @@ -89,12 +88,16 @@ -- the length is not a multiple of 8. toBytes :: BitVec -> ByteString toBytes v@(BitVec len _) = BS.pack $ fmap pack8bits $- L.chunksOf 8 $ pad ++ toBits v+ chunksOf 8 $ pad ++ toBits v where padLen = (-len) `mod` 8 pad = assert ((len + padLen) `mod` 8 == 0) $ L.replicate padLen False + chunksOf _ [] = []+ chunksOf i xs = a : chunksOf i b+ where (a,b) = L.splitAt i xs+ -- | Read bits from the binary representation of an @Integer@. This -- excludes the possibility of any leading zeros. Use `bitVec` for more -- flexible construction.@@ -177,13 +180,13 @@ where intLen = bitLen int -- | Returns the value of a bit at a given index, with @0@ being the--- index of the most significant bit.+-- index of the most significant (left-most) bit. (!!) :: BitVec -> Int -> Bool (BitVec len int) !! i = Bits.testBit int (len - i - 1) infixl 9 !! -- | Returns the value of a bit at a given index if within bounds, with--- @0@ being the index of the most significant bit.+-- @0@ being the index of the most significant (left-most) bit. (!?) :: BitVec -> Int -> Maybe Bool (BitVec len int) !? i | i < 0 || i >= len = Nothing
variety.cabal view
@@ -1,21 +1,33 @@ cabal-version: 3.0 name: variety-version: 0.1.0.0+version: 0.1.0.1 synopsis: integer arithmetic codes -description: The @Variety@ module provides functions to optimally encode and decode sequences- of value-base pairs assuming uniform probability.+description: The+ [Variety](https://hackage-content.haskell.org/package/variety/docs/Codec-Arithmetic-Variety.html)+ module provides functions to optimally encode and+ decode sequences of value-base pairs assuming+ uniform probability. - If codes get too large and slow to process, @Variety.Bounded@ provides similar- interface with a precision parameter at small cost to code length.+ If codes get too large and slow to process,+ [Variety.Bounded](https://hackage-content.haskell.org/package/variety/docs/Codec-Arithmetic-Variety-Bounded.html)+ provides similar interface with a precision+ parameter at small cost to code length. - The @Combinatorics@ module provides functions to optimally encode and decode- common combinatorial objects through ranking and unranking.+ The+ [Combinatorics](https://hackage-content.haskell.org/package/variety/docs/Codec-Arithmetic-Combinatorics.html)+ module provides functions to optimally encode and+ decode common combinatorial objects through ranking+ and unranking. - The @Elias@ module provides entirely non-parametric encoding and decoding of- positive integers. The usual definition doesn't allow for an encoding of 0, so a- mapping is baked into the functions in @Elias.Natural@ that shifts the number line- by 1.+ The+ [Elias](https://hackage-content.haskell.org/package/variety/docs/Codec-Elias.html)+ module provides entirely non-parametric encoding and+ decoding of positive integers. The usual definition+ doesn't allow for an encoding of 0, so a mapping is+ baked into the functions in+ [Elias.Natural](https://hackage-content.haskell.org/package/variety/docs/Codec-Elias-Natural.html)+ that shifts the number line by 1. license: MIT license-file: LICENSE@@ -23,17 +35,15 @@ maintainer: nbos@nbos.ca homepage: https://github.com/nbos/variety bug-reports: https://github.com/nbos/variety/issues---- copyright: category: Codec build-type: Simple- extra-doc-files: CHANGELOG.md+tested-with: GHC==9.4.8, GHC==9.6.7, GHC==9.8.4, GHC==9.10.1, GHC==9.12.2 source-repository head type: git location: https://github.com/nbos/variety- + common warnings ghc-options: -Wall @@ -48,11 +58,10 @@ Codec.Elias.Natural -- other-modules: -- other-extensions:- build-depends: base ^>=4.17.2.1- , bytestring >= 0.11.5 && < 0.12- , containers >= 0.6.7 && < 0.7+ build-depends: base >= 4.17.2 && < 4.22+ , bytestring >= 0.11.5 && < 0.13+ , containers >= 0.6.7 && < 0.8 , exact-combinatorics >= 0.2.0 && < 0.3- , extra >= 1.8 && < 1.9 hs-source-dirs: src default-language: Haskell2010@@ -66,8 +75,7 @@ hs-source-dirs: test main-is: Main.hs build-depends:- base ^>=4.17.2.1,+ base >= 4.17.2 && < 4.22, variety, QuickCheck, HUnit-