-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Efficient high-level bit operations not found in Data.Bits -- -- This package contains efficient implementations of high-level bit -- operations missing from Data.Bits. The implementation is based on GCC -- builtins, which translate to specialized instructions where available. -- -- All operations in this package can also be (less efficiently) -- implemented in terms of Data.Bits operations. -- -- Issues: A GCC-provided library, libgcc_s, is -- dynamically linked to provide software fallbacks on architectures -- without instructions corresponding to specific operations. This is -- currently only expected to work on Linux systems, and even there can -- lead to issues with GHCi's custom linker. A workaround for GHCi on a -- linux system: ln -s /lib/libgcc_s.so.1 /lib/libgcc_s.so. -- -- The current plan for broader support is to replace the libgcc -- dependency with built-in fallbacks in C or Haskell code. This needs to -- closely follow GCC's fall-back behaviour for each architecture. -- Alternative ideas would be appreciated. -- -- Relevant Hackage tickets: -- -- @package bits-extras @version 0.1.2 -- | Extended bit operations, implemented using GCC builtins (see -- http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html). module Data.Bits.Extras -- | Instances provided: Word, Word8, Word16, -- Word32, Word64, Int, Int8, Int16, -- Int32, Int64 class (Bits x) => ExtraBits x lowestBitPlus1 :: (ExtraBits x) => x -> Word32 leadingZeros :: (ExtraBits x) => x -> Word32 trailingZeros :: (ExtraBits x) => x -> Word32 populationCount :: (ExtraBits x) => x -> Word32 parity :: (ExtraBits x) => x -> Word32 byteSwap :: (ExtraBits x) => x -> x instance ExtraBits Int64 instance ExtraBits Int32 instance ExtraBits Int16 instance ExtraBits Int8 instance ExtraBits Int instance ExtraBits Word64 instance ExtraBits Word32 instance ExtraBits Word16 instance ExtraBits Word8 instance ExtraBits Word