haskus-binary-1.2: Haskus binary format manipulation

Safe HaskellNone
LanguageHaskell2010

Haskus.Format.Binary.Bits.Shift

Description

Bit shifts

Synopsis

Documentation

class ShiftableBits a where Source #

Bit shifts

Checked means that there is an additional test to ensure that the shift offset is valid (less than the bit count). If you are sure that the offset is valid, use the "unchecked" version which should be faster.

To shift signed numbers, see SignedShiftableBits class methods.

Minimal complete definition

shiftR, shiftL, uncheckedShiftR, uncheckedShiftL

Methods

shiftR :: a -> Word -> a Source #

Checked right shift

shiftL :: a -> Word -> a Source #

Checked left shift

uncheckedShiftR :: a -> Word -> a Source #

Unchecked right shift

uncheckedShiftL :: a -> Word -> a Source #

Unchecked left shift

shift :: a -> Int -> a Source #

Checked shift to the left if positive, to the right if negative

uncheckedShift :: a -> Int -> a Source #

Unchecked shift to the left if positive, to the right if negative

Instances
ShiftableBits Int Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

ShiftableBits Int8 Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

ShiftableBits Int16 Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

ShiftableBits Int32 Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

ShiftableBits Int64 Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

ShiftableBits Integer Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

ShiftableBits Word Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

ShiftableBits Word8 Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

ShiftableBits Word16 Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

ShiftableBits Word32 Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

ShiftableBits Word64 Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

ShiftableBits a => ShiftableBits (AsLittleEndian a) Source # 
Instance details

Defined in Haskus.Format.Binary.Endianness

ShiftableBits a => ShiftableBits (AsBigEndian a) Source # 
Instance details

Defined in Haskus.Format.Binary.Endianness

(Storable a, ShiftableBits a, Bitwise a, FiniteBits a, KnownNat (BitSize a), KnownNat (n * BitSize a), KnownNat n) => ShiftableBits (Vector n a) Source # 
Instance details

Defined in Haskus.Format.Binary.Vector

Methods

shiftR :: Vector n a -> Word -> Vector n a Source #

shiftL :: Vector n a -> Word -> Vector n a Source #

uncheckedShiftR :: Vector n a -> Word -> Vector n a Source #

uncheckedShiftL :: Vector n a -> Word -> Vector n a Source #

shift :: Vector n a -> Int -> Vector n a Source #

uncheckedShift :: Vector n a -> Int -> Vector n a Source #

class SignedShiftableBits a where Source #

Signed bit shifts

Signed means that the sign bit (the higher order bit): - propagates to the right during right shifts and - keeps its value during left shifts (except when all other bits are 0)

Checked means that there is an additional test to ensure that the shift offset is valid (less than the bit count). If you are sure that the offset is valid, use the "unchecked" version which should be faster.

Methods

signedShiftR :: a -> Word -> a Source #

Checked signed right shift

signedShiftL :: a -> Word -> a Source #

Checked signed left shift

uncheckedSignedShiftR :: a -> Word -> a Source #

Unchecked signed right shift

uncheckedSignedShiftL :: a -> Word -> a Source #

Unchecked signed left shift

signedShift :: a -> Int -> a Source #

Checked signed shift to the left if positive, to the right if negative

uncheckedSignedShift :: a -> Int -> a Source #

Unchecked signed shift to the left if positive, to the right if negative

Instances
SignedShiftableBits Int Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

SignedShiftableBits Int8 Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

SignedShiftableBits Int16 Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

SignedShiftableBits Int32 Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift

SignedShiftableBits Int64 Source # 
Instance details

Defined in Haskus.Format.Binary.Bits.Shift