packages feed

bitset-word8 0.1.1.0 → 0.1.1.1

raw patch · 8 files changed

+123/−92 lines, 8 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

− CHANGELOG.md
@@ -1,12 +0,0 @@-## Bitset-word8 0.1.1.0--* Changed backend from ByteString to unboxed Word64 based on benchmark result.-* Added benchmarks with some backend implementations.--## Bitset-word8 0.1.0.1--* Minor modifications in documents.--## Bitset-word8 0.1.0.0--* Initial release.
+ ChangeLog.md view
@@ -0,0 +1,16 @@+## Bitset-word8 0.1.1.1++* Move to hpack from hand written cabal project file.++## Bitset-word8 0.1.1.0++* Changed backend from ByteString to unboxed Word64 based on benchmark result.+* Added benchmarks with some backend implementations.++## Bitset-word8 0.1.0.1++* Minor modifications in documents.++## Bitset-word8 0.1.0.0++* Initial release.
bench/Bench.hs view
@@ -1,13 +1,11 @@ {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveGeneric  #-}-{-# LANGUAGE MagicHash      #-}-{-# LANGUAGE UnboxedTuples  #-}  import           Control.DeepSeq     (NFData, force) import           Criterion.Main import           Data.Bits           (testBit) import           Data.ByteString     (ByteString, index, pack)-import           Data.Vector.Unboxed (Vector (..), (!), fromList)+import           Data.Vector.Unboxed (Vector, fromList, (!)) import           Data.Word           (Word64, Word8) import           GHC.Generics        (Generic) @@ -63,7 +61,7 @@ newtype BitSetWord8Vector64 = BitSetWord8Vector64 (Vector Word64) deriving (Eq, Generic, NFData, Show)  memberVector64 :: BitSetWord8Vector64 -> Word8 -> Bool-memberVector64 (BitSetWord8Vector64 v) w = testBit (v ! (fromIntegral (w `div` 64))) (fromIntegral (w `mod` 64))+memberVector64 (BitSetWord8Vector64 v) w = testBit (v ! fromIntegral (w `div` 64)) (fromIntegral (w `mod` 64))  allZeroVector64 :: BitSetWord8Vector64 allZeroVector64 = force $ BitSetWord8Vector64 $ fromList [ 0,0,0,0 ]@@ -77,7 +75,7 @@ newtype BitSetWord8Vector8 = BitSetWord8Vector8 (Vector Word8) deriving (Eq, Generic, NFData, Show)  memberVector8 :: BitSetWord8Vector8 -> Word8 -> Bool-memberVector8 (BitSetWord8Vector8 v) w = testBit (v ! (fromIntegral (w `div` 8))) (fromIntegral (w `mod` 8))+memberVector8 (BitSetWord8Vector8 v) w = testBit (v ! fromIntegral (w `div` 8)) (fromIntegral (w `mod` 8))  allZeroVector8 :: BitSetWord8Vector8 allZeroVector8 = force $ BitSetWord8Vector8 $ fromList [ 0,0,0,0,0,0,0,0
bitset-word8.cabal view
@@ -1,55 +1,84 @@-name:                bitset-word8-version:             0.1.1.0-synopsis:            Space efficient set of Word8 and some pre-canned sets useful for parsing HTTP-description:         This package is intended to provide O(1) membership test on any subset of ASCII-                     and Latin-1 character set in order to write efficient HTTP related parser.-homepage:            https://github.com/nshimaza/bitset-word8#readme-license:             MIT-license-file:        LICENSE-author:              Naoto Shimazaki-maintainer:          Naoto.Shimazaki@gmail.com-copyright:           Copyright: (c) 2017 Naoto Shimazaki-category:            Data-build-type:          Simple-extra-source-files:  CHANGELOG.md-                   , README.md-cabal-version:       >=1.10+cabal-version: 1.12 +-- This file has been generated from package.yaml by hpack version 0.31.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 6ddab4e773037869bcf89a8b168d28296949766d6abfd03c9bfa0886b18700dc++name:           bitset-word8+version:        0.1.1.1+synopsis:       Space efficient set of Word8 and some pre-canned sets useful for parsing HTTP+description:    Please see the README on GitHub at <https://github.com/nshimaza/bitset-word8#readme>+category:       Concurrency+homepage:       https://github.com/nshimaza/bitset-word8#readme+bug-reports:    https://github.com/nshimaza/bitset-word8/issues+author:         Naoto Shimazaki+maintainer:     Naoto.Shimazaki@gmail.com+copyright:      2017,2018 Naoto Shimazaki+license:        MIT+license-file:   LICENSE+build-type:     Simple+extra-source-files:+    README.md+    ChangeLog.md++source-repository head+  type: git+  location: https://github.com/nshimaza/bitset-word8+ library-  hs-source-dirs:      src-  exposed-modules:     Data.BitSetWord8-                     , Data.BitSetWord8.CharSets-                     , Data.BitSetWord8.Internal-  build-depends:       base >= 4.7 && < 5-                     , containers-                     , template-haskell-                     , th-lift-instances-  default-language:    Haskell2010+  exposed-modules:+      Data.BitSetWord8+      Data.BitSetWord8.CharSets+      Data.BitSetWord8.Internal+  other-modules:+      Paths_bitset_word8+  hs-source-dirs:+      src+  ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints+  build-depends:+      base >=4.7 && <5+    , containers+    , template-haskell+    , th-lift-instances+  default-language: Haskell2010  test-suite bitset-word8-test-  type:                exitcode-stdio-1.0-  hs-source-dirs:      test-  main-is:             Spec.hs-  other-modules:       Data.BitSetWord8Spec-  build-depends:       base-                     , hspec-                     , QuickCheck-                     , bitset-word8-  ghc-options:         -threaded -rtsopts -with-rtsopts=-N-  default-language:    Haskell2010+  type: exitcode-stdio-1.0+  main-is: Spec.hs+  other-modules:+      Data.BitSetWord8Spec+      Paths_bitset_word8+  hs-source-dirs:+      test+  ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N+  build-depends:+      QuickCheck+    , base >=4.7 && <5+    , bitset-word8+    , containers+    , hspec+    , template-haskell+    , th-lift-instances+  default-language: Haskell2010  benchmark bitset-word8-bench-  type:                exitcode-stdio-1.0-  hs-source-dirs:      bench-  main-is:             Bench.hs-  build-depends:       base-                     , bytestring-                     , criterion-                     , deepseq-                     , vector-  ghc-options:         -threaded -rtsopts -with-rtsopts=-N-  default-language:    Haskell2010--source-repository head-  type:     git-  location: https://github.com/nshimaza/bitset-word8+  type: exitcode-stdio-1.0+  main-is: Bench.hs+  other-modules:+      Paths_bitset_word8+  hs-source-dirs:+      bench+  ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -threaded -rtsopts -with-rtsopts=-N+  build-depends:+      base >=4.7 && <5+    , bitset-word8+    , bytestring+    , containers+    , criterion+    , deepseq+    , template-haskell+    , th-lift-instances+    , vector+  default-language: Haskell2010
src/Data/BitSetWord8.hs view
@@ -40,8 +40,6 @@ @ -} -{-# LANGUAGE DeriveLift         #-}- module Data.BitSetWord8     (     -- * Types@@ -75,5 +73,5 @@     , member     ) where -import Data.BitSetWord8.Internal-import Data.BitSetWord8.CharSets+import           Data.BitSetWord8.CharSets+import           Data.BitSetWord8.Internal
src/Data/BitSetWord8/CharSets.hs view
@@ -20,7 +20,7 @@     , rfc7230QuotedPair     ) where -import           Language.Haskell.TH.Syntax (Lift, lift)+import           Language.Haskell.TH.Syntax (lift)  import           Data.BitSetWord8.Internal @@ -39,6 +39,3 @@ -- | quoted-string of RFC7230 in BitSetWord8.  Evaluated at compile time. rfc7230QuotedPair :: BitSetWord8 rfc7230QuotedPair = $(lift $ fromList rfc7230QuotedPair')---
src/Data/BitSetWord8/Internal.hs view
@@ -10,9 +10,7 @@ This file contains additional useful character sets but they aren't evaluated at compile time. -} -{-# LANGUAGE DeriveLift    #-}-{-# LANGUAGE MagicHash     #-}-{-# LANGUAGE UnboxedTuples #-}+{-# LANGUAGE DeriveLift #-}  module Data.BitSetWord8.Internal where @@ -21,8 +19,7 @@ import           Data.List                  (foldl', splitAt) import           Data.Semigroup             ((<>)) import qualified Data.Set                   as Set (Set, fromList, member)-import           Data.Word                  (Word8, Word64)-import           Instances.TH.Lift+import           Data.Word                  (Word64, Word8) import           Language.Haskell.TH.Syntax (Lift)  @@ -115,6 +112,7 @@     doMember (BitSetWord8 _ w _ _) 1 ind = testBit w (fromIntegral ind)     doMember (BitSetWord8 _ _ w _) 2 ind = testBit w (fromIntegral ind)     doMember (BitSetWord8 _ _ _ w) 3 ind = testBit w (fromIntegral ind)+    doMember _                     _ _   = error "Impossible happen.  Word8 `dev` 64 cannot be greater than 3."  -- | Convert given list of 'Char' into 'Set' of 'Word8'.  Any 'Char' having code point greater than 0xff is ignored. toWord8Set :: [Char] -> Set.Set Word8@@ -138,6 +136,14 @@     Any 'Char' having code point greater than 0xff is ignored. -} fromList :: [Char] -> BitSetWord8-fromList cs = BitSetWord8 w0 w1 w2 w3+fromList = fromWord64List . toWord64List . toBoolList . toWord8Set   where-    (w0:w1:w2:w3:_) = toWord64List . toBoolList . toWord8Set $ cs+    -- Convert 4 packed 'Word64' list into single 'BitSetWord8'+    fromWord64List :: [Word64] -> BitSetWord8+    fromWord64List (w0:w1:w2:w3:_) = BitSetWord8 w0 w1 w2 w3+    fromWord64List [_, _, _]       = raiseError+    fromWord64List [_, _]          = raiseError+    fromWord64List [_]             = raiseError+    fromWord64List []              = raiseError++    raiseError      = error "Impossible happen.  Arg of fromList must be converted to 4 elements list."
test/Data/BitSetWord8Spec.hs view
@@ -12,35 +12,34 @@ spec :: Spec spec = do     describe "fromList" $ do-        prop "creates empty BitSetWord8 from empty list" $ forAll (choose (0, 0xff :: Word8)) $ \n -> do+        prop "creates empty BitSetWord8 from empty list" $ forAll (choose (0, 0xff :: Word8)) $ \n ->             member (fromList []) n `shouldBe` False -        prop "creates fullfilled BitSetWord8 from fullfilled list" $ forAll (choose (0, 0xff :: Word8)) $ \n -> do+        prop "creates fullfilled BitSetWord8 from fullfilled list" $ forAll (choose (0, 0xff :: Word8)) $ \n ->             member (fromList [chr 0 .. chr 0xff]) n `shouldBe` True      describe "rfc5234Digit'" $ do-        prop "recognizes any digit" $ forAll (choose (0x30, 0x39 :: Word8)) $ \n -> do+        prop "recognizes any digit" $ forAll (choose (0x30, 0x39 :: Word8)) $ \n ->             member (fromList rfc5234Digit') n `shouldBe` True -        prop "unrecognizes any non-digit characters (lower)" $ forAll (choose (0, 0x2f :: Word8)) $ \n -> do+        prop "unrecognizes any non-digit characters (lower)" $ forAll (choose (0, 0x2f :: Word8)) $ \n ->             member (fromList rfc5234Digit') n `shouldBe` False -        prop "unrecognizes any non-digit characters (higher)" $ forAll (choose (0x3a, 0xff :: Word8)) $ \n -> do+        prop "unrecognizes any non-digit characters (higher)" $ forAll (choose (0x3a, 0xff :: Word8)) $ \n ->             member (fromList rfc5234Digit') n `shouldBe` False      describe "rfc5234Alpha'" $ do-        prop "recognizes any upper case alphabet" $ forAll (choose (0x41, 0x5a :: Word8)) $ \n -> do+        prop "recognizes any upper case alphabet" $ forAll (choose (0x41, 0x5a :: Word8)) $ \n ->             member (fromList rfc5234Alpha') n `shouldBe` True -        prop "recognizes any lower case alphabet" $ forAll (choose (0x61, 0x7a :: Word8)) $ \n -> do+        prop "recognizes any lower case alphabet" $ forAll (choose (0x61, 0x7a :: Word8)) $ \n ->             member (fromList rfc5234Alpha') n `shouldBe` True -        prop "unrecognizes any non-alphabet (lower)" $ forAll (choose (0, 0x40 :: Word8)) $ \n -> do+        prop "unrecognizes any non-alphabet (lower)" $ forAll (choose (0, 0x40 :: Word8)) $ \n ->             member (fromList rfc5234Alpha') n `shouldBe` False -        prop "unrecognizes any non-alphabet (middle)" $ forAll (choose (0x5b, 0x60 :: Word8)) $ \n -> do+        prop "unrecognizes any non-alphabet (middle)" $ forAll (choose (0x5b, 0x60 :: Word8)) $ \n ->             member (fromList rfc5234Alpha') n `shouldBe` False -        prop "unrecognizes any non-alphabet (higher)" $ forAll (choose (0x7b, 0xff :: Word8)) $ \n -> do+        prop "unrecognizes any non-alphabet (higher)" $ forAll (choose (0x7b, 0xff :: Word8)) $ \n ->             member (fromList rfc5234Alpha') n `shouldBe` False-