bitstream-0.2.0.2: Fast, packed, strict and lazy bit streams with stream fusion

Safe HaskellSafe-Infered

Data.Bitstream.Packet

Description

For internal use only.

Synopsis

Documentation

data Left Source

Left bitstreams interpret an octet as a vector of bits whose LSB comes first and MSB comes last e.g.

  • 11110000 => [False, False, False, False, True, True , True , True]
  • 10010100 => [False, False, True , False, True, False, False, True]

Bits operations (like toBits) treat a Left bitstream as a little-endian integer.

data Right Source

Right bitstreams interpret an octet as a vector of bits whose MSB comes first and LSB comes last e.g.

  • 11110000 => [True, True , True , True, False, False, False, False]
  • 10010100 => [True, False, False, True, False, True , False, False]

Bits operations (like toBits) treat a Right bitstream as a big-endian integer.

data Packet d Source

Packets are strict Bitstreams having at most 8 bits.

full :: Packet d -> BoolSource

O(1) full p == True iff length p == 8, otherwise it returns False.

fromOctet :: Word8 -> Packet dSource

O(1) Convert an octet to Packet.

toOctet :: Packet d -> Word8Source

O(1) toOctet p converts a Packet p to an octet, padding with zeroes if length p < 8.

packetLToR :: Packet Left -> Packet RightSource

O(1) Change the direction of Packet from Left to Right. Bit directions only affect octet-based operations such as toOctet.

packetRToL :: Packet Right -> Packet LeftSource

O(1) Change the direction of Packet from Right to Left. Bit directions only affect octet-based operations such as toOctet.