packages feed

bits-extra 0.0.0.2 → 0.0.0.3

raw patch · 2 files changed

+83/−2 lines, 2 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

bits-extra.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 547b5605d3febfb841362a7a119ad0091b5184712d7fdb7698dc5ae94e7f4249+-- hash: 6cc41f475c233d2d1c9c4bd300ca0f7f274a3964bd2de19b0f2e19e670724c22  name:           bits-extra-version:        0.0.0.2+version:        0.0.0.3 description:    Please see the README on Github at <https://github.com/haskell-works/bits-extra#readme> homepage:       https://github.com/haskell-works/bits-extra#readme bug-reports:    https://github.com/haskell-works/bits-extra/issues@@ -37,6 +37,7 @@   build-depends:       base >=4.7 && <5     , ghc-prim+    , vector   if (flag(bmi2)) && (impl(ghc >=8.4.1))     ghc-options: -mbmi2 -msse4.2     cpp-options: -DBMI2_ENABLED@@ -46,6 +47,7 @@       Data.Bits.Pext       Data.Bits.Pext.Slow   other-modules:+      Data.Bits.BitSize       Data.Bits.Pdep.Prim       Data.Bits.Pext.Prim       Paths_bits_extra
+ src/Data/Bits/BitSize.hs view
@@ -0,0 +1,79 @@+module Data.Bits.BitSize where++import Data.Functor.Identity+import Data.Int+import Data.Word++import qualified Data.Bits            as B+import qualified Data.Vector          as DV+import qualified Data.Vector.Storable as DVS++class BitSize a where+  bitSize :: a -> Int+  bitCount :: a -> Word64+  bitCount = fromIntegral . bitSize+  {-# INLINE bitCount #-}++instance BitSize () where+  bitSize _ = 0+  {-# INLINE bitSize #-}++instance BitSize Bool where+  bitSize = B.finiteBitSize+  {-# INLINE bitSize #-}++instance BitSize Word where+  bitSize = B.finiteBitSize+  {-# INLINE bitSize #-}++instance BitSize Word64 where+  bitSize = B.finiteBitSize+  {-# INLINE bitSize #-}++instance BitSize Word32 where+  bitSize = B.finiteBitSize+  {-# INLINE bitSize #-}++instance BitSize Word16 where+  bitSize = B.finiteBitSize+  {-# INLINE bitSize #-}++instance BitSize Word8 where+  bitSize = B.finiteBitSize+  {-# INLINE bitSize #-}++instance BitSize Int where+  bitSize = B.finiteBitSize+  {-# INLINE bitSize #-}++instance BitSize Int64 where+  bitSize = B.finiteBitSize+  {-# INLINE bitSize #-}++instance BitSize Int32 where+  bitSize = B.finiteBitSize+  {-# INLINE bitSize #-}++instance BitSize Int16 where+  bitSize = B.finiteBitSize+  {-# INLINE bitSize #-}++instance BitSize Int8 where+  bitSize = B.finiteBitSize+  {-# INLINE bitSize #-}++instance BitSize a => BitSize (Identity a) where+  bitSize = foldl (\a b -> a + bitSize b) 0+  {-# INLINE bitSize #-}++instance BitSize a => BitSize [a] where+  bitSize = foldl (\a b -> a + bitSize b) 0+  {-# INLINE bitSize #-}++instance BitSize a => BitSize (DV.Vector a) where+  bitSize = DV.foldl (\a b -> a + bitSize b) 0+  {-# INLINE bitSize #-}++instance (BitSize a, DVS.Storable a) => BitSize (DVS.Vector a) where+  bitSize = DVS.foldl (\a b -> a + bitSize b) 0+  {-# INLINE bitSize #-}