Popularity
2.2
Declining
Activity
0.0
Stable
4
1
2

Monthly Downloads: 14
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Data     Bits    
Latest version: v0.1.0

bits-bytestring alternatives and similar packages

Based on the "bits" category.
Alternatively, view bits-bytestring alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of bits-bytestring or a related project?

Add another 'bits' Package

README

bits-bytestring Build Status Release

A ByteString instance for the Bits typeclass, providing bitwise operators for n-bit blocks larger than Word64.

Installation

To install bits-bytestring, use stack and add bits-bytestring-0.1.0.1 to extra-deps in stack.yaml:

extra-deps: [bits-bytestring-0.1.0.1]

Then add bits-bytestring to your cabal file or just run:

stack install bits-bytestring

Usage

bits-bytestring provides a Bits typeclass instance for ByteString, so all the bitwise operators from Data.Bits are available with ByteStrings now. To access the instance, import Data.Bits.ByteString. Example usage could be:

-- Minimal imports
import qualified Data.ByteString as B
import           Data.Bits
import           Data.Bits.ByteString

-- cryptohash example
import qualified Crypto.Hash.SHA512 as SHA512

main :: IO ()
main = do
  let bs1 = SHA512.hash (B.pack [0..255])
  let bs2 = (B.replicate 64 0)
  print $ bs1 .&. bs2
  print $ bs1 .|. bs2
  print $ bs1 `xor` bs2
  print $ shift bs1 5
  print $ rotate bs1 13

Contributions

Pull requests and bug reports are welcome!

If you need to contact me, the following ways are best and in this order: