capnp-0.12.0.0: Cap'n Proto for Haskell
Safe HaskellNone
LanguageHaskell2010

Capnp.Bits

Description

This module provides misc. utilities for bitwhacking that are useful in dealing with low-level details of the Cap'N Proto wire format.

This is mostly an implementation detail; users are unlikely to need to use this module directly.

Synopsis

Documentation

newtype BitCount Source #

Wrapper type for a quantity of bits. This along with ByteCount and WordCount are helpful for avoiding mixing up units

Constructors

BitCount Int 

Instances

Instances details
Bounded BitCount Source # 
Instance details

Defined in Capnp.Bits

Enum BitCount Source # 
Instance details

Defined in Capnp.Bits

Eq BitCount Source # 
Instance details

Defined in Capnp.Bits

Integral BitCount Source # 
Instance details

Defined in Capnp.Bits

Num BitCount Source # 
Instance details

Defined in Capnp.Bits

Ord BitCount Source # 
Instance details

Defined in Capnp.Bits

Real BitCount Source # 
Instance details

Defined in Capnp.Bits

Show BitCount Source # 
Instance details

Defined in Capnp.Bits

Bits BitCount Source # 
Instance details

Defined in Capnp.Bits

newtype ByteCount Source #

A quantity of bytes

Constructors

ByteCount Int 

Instances

Instances details
Bounded ByteCount Source # 
Instance details

Defined in Capnp.Bits

Enum ByteCount Source # 
Instance details

Defined in Capnp.Bits

Eq ByteCount Source # 
Instance details

Defined in Capnp.Bits

Integral ByteCount Source # 
Instance details

Defined in Capnp.Bits

Num ByteCount Source # 
Instance details

Defined in Capnp.Bits

Ord ByteCount Source # 
Instance details

Defined in Capnp.Bits

Real ByteCount Source # 
Instance details

Defined in Capnp.Bits

Show ByteCount Source # 
Instance details

Defined in Capnp.Bits

Bits ByteCount Source # 
Instance details

Defined in Capnp.Bits

newtype WordCount Source #

A quantity of 64-bit words

Constructors

WordCount Int 

Instances

Instances details
Bounded WordCount Source # 
Instance details

Defined in Capnp.Bits

Enum WordCount Source # 
Instance details

Defined in Capnp.Bits

Eq WordCount Source # 
Instance details

Defined in Capnp.Bits

Integral WordCount Source # 
Instance details

Defined in Capnp.Bits

Num WordCount Source # 
Instance details

Defined in Capnp.Bits

Ord WordCount Source # 
Instance details

Defined in Capnp.Bits

Real WordCount Source # 
Instance details

Defined in Capnp.Bits

Show WordCount Source # 
Instance details

Defined in Capnp.Bits

Bits WordCount Source # 
Instance details

Defined in Capnp.Bits

newtype Word1 Source #

1 bit datatype, in the tradition of Word8, Word16 et al.

Constructors

Word1 

Fields

Instances

Instances details
Bounded Word1 Source # 
Instance details

Defined in Capnp.Bits

Enum Word1 Source # 
Instance details

Defined in Capnp.Bits

Eq Word1 Source # 
Instance details

Defined in Capnp.Bits

Methods

(==) :: Word1 -> Word1 -> Bool #

(/=) :: Word1 -> Word1 -> Bool #

Integral Word1 Source # 
Instance details

Defined in Capnp.Bits

Num Word1 Source # 
Instance details

Defined in Capnp.Bits

Ord Word1 Source # 
Instance details

Defined in Capnp.Bits

Methods

compare :: Word1 -> Word1 -> Ordering #

(<) :: Word1 -> Word1 -> Bool #

(<=) :: Word1 -> Word1 -> Bool #

(>) :: Word1 -> Word1 -> Bool #

(>=) :: Word1 -> Word1 -> Bool #

max :: Word1 -> Word1 -> Word1 #

min :: Word1 -> Word1 -> Word1 #

Real Word1 Source # 
Instance details

Defined in Capnp.Bits

Methods

toRational :: Word1 -> Rational #

Show Word1 Source # 
Instance details

Defined in Capnp.Bits

Methods

showsPrec :: Int -> Word1 -> ShowS #

show :: Word1 -> String #

showList :: [Word1] -> ShowS #

Bits Word1 Source # 
Instance details

Defined in Capnp.Bits

IsWord Word1 Source # 
Instance details

Defined in Capnp.Classes

bitsToBytesCeil :: BitCount -> ByteCount Source #

Convert bits to bytes. Rounds up.

bytesToWordsCeil :: ByteCount -> WordCount Source #

Convert bytes to words. Rounds up.

bytesToWordsFloor :: ByteCount -> WordCount Source #

Convert bytes to words. Rounds down.

wordsToBytes :: WordCount -> ByteCount Source #

Convert words to bytes.

lo :: Word64 -> Word32 Source #

lo and hi extract the low and high 32 bits of a 64-bit word, respectively.

hi :: Word64 -> Word32 Source #

lo and hi extract the low and high 32 bits of a 64-bit word, respectively.

i32 :: Word32 -> Int32 Source #

iN (where N is 32, 30, or 29) extracts the high N bits of its argument, and treats them as a signed 32-bit integer.

i30 :: Word32 -> Int32 Source #

iN (where N is 32, 30, or 29) extracts the high N bits of its argument, and treats them as a signed 32-bit integer.

i29 :: Word32 -> Int32 Source #

iN (where N is 32, 30, or 29) extracts the high N bits of its argument, and treats them as a signed 32-bit integer.

fromLo :: Word32 -> Word64 Source #

fromLo and fromHi convert a 32-bit word to the low or high portion of a 64-bit word. In general, fromHi (hi w) .|. fromLo (lo w) == w.

fromHi :: Word32 -> Word64 Source #

fromLo and fromHi convert a 32-bit word to the low or high portion of a 64-bit word. In general, fromHi (hi w) .|. fromLo (lo w) == w.

fromI32 :: Int32 -> Word32 Source #

fromIN (where N is 32, 30, or 29) treats its argument as the high N bits of a 32-bit word, returning the word. If w < 2 ** N then fromIN (iN w) == w.

fromI30 :: Int32 -> Word32 Source #

fromIN (where N is 32, 30, or 29) treats its argument as the high N bits of a 32-bit word, returning the word. If w < 2 ** N then fromIN (iN w) == w.

fromI29 :: Int32 -> Word32 Source #

fromIN (where N is 32, 30, or 29) treats its argument as the high N bits of a 32-bit word, returning the word. If w < 2 ** N then fromIN (iN w) == w.

bitRange :: Integral a => Word64 -> Int -> Int -> a Source #

bitRange word lo hi is the unsigned integer represented by the bits of word in the range [lo, hi)

replaceBits :: (Bounded a, Integral a) => a -> Word64 -> Int -> Word64 Source #

replaceBits new orig shift replaces the bits [shift, shift+N) in orig with the N bit integer new.