Skip to content

Commit 34ef18b

Browse files
Updating for next release
1 parent f1706a1 commit 34ef18b

File tree

4 files changed

+59
-38
lines changed

4 files changed

+59
-38
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ install:
7777
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
7878
- cabal --version
7979
- cabal update
80+
- cabal configure --enable-coverage --enable-benchmarks --enable-tests
8081

8182
# Overlay Hackage Package Index for GHC HEAD: https://github.com/hvr/head.hackage
8283
- GHCHEAD=${GHCHEAD-false}
@@ -98,14 +99,14 @@ install:
9899
# Install dependencies and utility programs
99100
- |
100101
if $GHCHEAD; then
101-
cabal install --enable-benchmarks --enable-documentation --enable-tests --only-dependencies --allow-newer
102+
cabal install --only-dependencies --allow-newer
102103
else
103104
cabal install --enable-benchmarks --enable-documentation --enable-tests --only-dependencies
104105
fi
106+
105107
- cabal install hpc
106108

107109
script:
108-
- cabal configure --enable-coverage --enable-benchmarks --enable-tests
109110
- cabal sdist
110111
- cabal build
111112
- cabal test --show-details=always

bv-little.cabal

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: bv-little
2-
version: 1.0.1
2+
version: 1.1.0
33
synopsis: Efficient little-endian bit vector library
44
category: Data, Bit Vectors
55
license: BSD3
@@ -38,20 +38,20 @@ source-repository head
3838

3939
library
4040

41-
build-depends: base >= 4.5.1 && < 5
42-
, deepseq
43-
, hashable
44-
, integer-gmp
45-
, keys
46-
, mono-traversable
47-
, mono-traversable-keys
48-
, primitive
49-
, QuickCheck
50-
, text-show
41+
build-depends: base >= 4.5.1 && < 5
42+
, deepseq >= 1.4.1.1
43+
, hashable >= 1.2.3.2
44+
, integer-gmp >= 1.0
45+
, keys >= 3.10.1
46+
, mono-traversable >= 1.0.5.0
47+
, mono-traversable-keys >= 0.1.0
48+
, primitive >= 0.6.4.0
49+
, QuickCheck >= 2.8
50+
, text-show >= 3.2.1
5151

5252
if !impl(ghc >= 8.0)
5353

54-
build-depends: semigroups >= 0.18 && < 0.19
54+
build-depends: semigroups >= 0.18 && < 1.0
5555

5656
default-language: Haskell2010
5757

@@ -104,23 +104,23 @@ Test-Suite test-suite
104104

105105
main-is: TestSuite.hs
106106

107-
build-depends: base >= 4.5.1 && < 5
107+
build-depends: base >= 4.5.1 && < 5
108108
, bv-little
109-
, deepseq
110-
, hashable
111-
, mono-traversable
112-
, mono-traversable-keys
113-
, QuickCheck
114-
, smallcheck >= 1.1.5
109+
, deepseq >= 1.4.1.1
110+
, hashable >= 1.2.3.2
111+
, mono-traversable >= 1.0.5.0
112+
, mono-traversable-keys >= 0.1.0
113+
, QuickCheck >= 2.8
114+
, smallcheck >= 1.1.5
115115
, tasty
116116
, tasty-hunit
117117
, tasty-quickcheck
118118
, tasty-smallcheck
119-
, text-show
119+
, text-show >= 3.2.1
120120

121121
if !impl(ghc >= 8.0)
122122

123-
build-depends: semigroups >= 0.18 && < 0.19
123+
build-depends: semigroups >= 0.18 && < 1.0
124124
, transformers
125125

126126
default-language: Haskell2010
@@ -142,15 +142,15 @@ benchmark benchmark-suite
142142
build-depends: base >= 4.5.1 && < 5
143143
, bv-little
144144
, criterion
145-
, deepseq
146-
, hashable
147-
, mono-traversable
148-
, QuickCheck
145+
, deepseq >= 1.4.1.1
146+
, hashable >= 1.2.3.2
147+
, mono-traversable >= 1.0.5.0
148+
, QuickCheck >= 2.8
149149
, smallcheck >= 1.1.5
150150

151151
if !impl(ghc >= 8.0)
152152

153-
build-depends: semigroups >= 0.18 && < 0.19
153+
build-depends: semigroups >= 0.18 && < 1.0
154154

155155
default-language: Haskell2010
156156

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
* None
44

5+
### [v1.1.0][5]
6+
7+
* Added `rank` and `select` functions
8+
9+
510
### [v1.0.1][4]
611

712
* Correcting Eq instance to test for value equality and not construction equality
@@ -72,3 +77,4 @@
7277
[2]: https://github.com/recursion-ninja/bv-little/tree/v0.1.2
7378
[3]: https://github.com/recursion-ninja/bv-little/tree/v1.0.0
7479
[4]: https://github.com/recursion-ninja/bv-little/tree/v1.0.1
80+
[5]: https://github.com/recursion-ninja/bv-little/tree/v1.1.0

src/Data/BitVector/LittleEndian.hs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@
4242
-- convert the 'BitVector' using either 'toSignedNumber' or 'toUnsignedNumber'.
4343
--
4444
-- This module defines 'rank' and 'select' operations for 'BitVector' as a
45-
-- succinct data structure.
45+
-- <https://en.wikipedia.org/wiki/Succinct_data_structure succinct data structure>.
46+
-- These operations are not /o(1)/ so 'BitVector' is not a /true/ succinct data
47+
-- structure. However, it could potentially be extend to support this in the
48+
-- future.
4649
-----------------------------------------------------------------------------
4750

4851
{-# LANGUAGE BangPatterns #-}
52+
{-# LANGUAGE CPP #-}
4953
{-# LANGUAGE DeriveDataTypeable #-}
5054
{-# LANGUAGE DeriveGeneric #-}
5155
{-# LANGUAGE MagicHash #-}
@@ -101,10 +105,20 @@ data BitVector
101105
= BV
102106
{ dim :: {-# UNPACK #-} !Word -- ^ The /dimension/ of a bit vector.
103107
, nat :: !Natural -- ^ The value of a bit vector, as a natural number.
104-
} deriving ( Data
105-
, Generic
106-
, Typeable
107-
)
108+
} deriving
109+
#ifdef MIN_VERSION_GLASGOW_HASKELL
110+
#if MIN_VERSION_GLASGOW_HASKELL(8,2,0,0)
111+
( Data -- ^ @since 0.1.0
112+
, Generic -- ^ @since 0.1.0
113+
, Typeable -- ^ @since 0.1.0
114+
)
115+
#else
116+
( Data
117+
, Generic
118+
, Typeable
119+
)
120+
#endif
121+
#endif
108122

109123

110124
-- |
@@ -141,7 +155,7 @@ instance Arbitrary BitVector where
141155
where
142156
allBitsOn = genBitVector $ Just True
143157
allBitsOff = genBitVector $ Just False
144-
anyBitValue = genBitVector $ Nothing
158+
anyBitValue = genBitVector Nothing
145159

146160
boundaryValue = do
147161
let wrdVal = maxBound :: Word
@@ -1228,7 +1242,7 @@ rank (BV w natVal) k =
12281242
-- >>> select bv 1 -- Find the 0-indexed position of the second one bit
12291243
-- Just 65
12301244
--
1231-
-- >>> select bv 2 -- Out-of-bounds `select` fails
1245+
-- >>> select bv 2 -- There is no 3rd set bit, `select` fails
12321246
-- Nothing
12331247
select
12341248
:: BitVector
@@ -1275,7 +1289,7 @@ wordRank
12751289
-> Word -- ^ THe number of bits set within index "k."
12761290
wordRank v x = toEnum . popCount $ suffixOnes .&. v
12771291
where
1278-
suffixOnes = (1 `shiftL` (fromEnum x)) - 1
1292+
suffixOnes = (1 `shiftL` fromEnum x) - 1
12791293

12801294

12811295
-- |
@@ -1284,7 +1298,7 @@ wordSelect
12841298
:: Word -- ^ Input 'Word'
12851299
-> Word -- ^ Find the k-th set bit, k in range [ 0, finiteBitCount - 1 ]
12861300
-> Word -- ^ The index of the k-th set bit
1287-
wordSelect v k = go 0 63 k
1301+
wordSelect v = go 0 63
12881302
where
12891303
go :: Word -> Word -> Word -> Word
12901304
go lb ub x
@@ -1300,7 +1314,7 @@ wordSelect v k = go 0 63 k
13001314

13011315
makeMask i j = wideMask `xor` thinMask
13021316
where
1303-
thinMask = ((1 `shiftL` fromEnum i) - 1)
1317+
thinMask = (1 `shiftL` fromEnum i) - 1
13041318
wideMask
13051319
| j == bitsInWord - 1 = maxBound :: Word
13061320
| otherwise = (1 `shiftL` (fromEnum j + 1)) - 1

0 commit comments

Comments
 (0)