basement-0.0.7: Foundation scrap box of array & string

LicenseBSD-style
MaintainerHaskell Foundation
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Basement.Endianness

Contents

Description

Set endianness tag to a given primitive. This will help for serialising data for protocols (such as the network protocols).

Synopsis

Documentation

class ByteSwap a Source #

Class of types that can be byte-swapped.

e.g. Word16, Word32, Word64

Minimal complete definition

byteSwap

Big Endian

newtype BE a Source #

Big Endian value

Constructors

BE 

Fields

Instances

Eq a => Eq (BE a) Source # 

Methods

(==) :: BE a -> BE a -> Bool #

(/=) :: BE a -> BE a -> Bool #

(ByteSwap a, Ord a) => Ord (BE a) Source # 

Methods

compare :: BE a -> BE a -> Ordering #

(<) :: BE a -> BE a -> Bool #

(<=) :: BE a -> BE a -> Bool #

(>) :: BE a -> BE a -> Bool #

(>=) :: BE a -> BE a -> Bool #

max :: BE a -> BE a -> BE a #

min :: BE a -> BE a -> BE a #

Show a => Show (BE a) Source # 

Methods

showsPrec :: Int -> BE a -> ShowS #

show :: BE a -> String #

showList :: [BE a] -> ShowS #

Bits a => Bits (BE a) Source # 

Methods

(.&.) :: BE a -> BE a -> BE a #

(.|.) :: BE a -> BE a -> BE a #

xor :: BE a -> BE a -> BE a #

complement :: BE a -> BE a #

shift :: BE a -> Int -> BE a #

rotate :: BE a -> Int -> BE a #

zeroBits :: BE a #

bit :: Int -> BE a #

setBit :: BE a -> Int -> BE a #

clearBit :: BE a -> Int -> BE a #

complementBit :: BE a -> Int -> BE a #

testBit :: BE a -> Int -> Bool #

bitSizeMaybe :: BE a -> Maybe Int #

bitSize :: BE a -> Int #

isSigned :: BE a -> Bool #

shiftL :: BE a -> Int -> BE a #

unsafeShiftL :: BE a -> Int -> BE a #

shiftR :: BE a -> Int -> BE a #

unsafeShiftR :: BE a -> Int -> BE a #

rotateL :: BE a -> Int -> BE a #

rotateR :: BE a -> Int -> BE a #

popCount :: BE a -> Int #

PrimMemoryComparable a => PrimMemoryComparable (BE a) Source # 
PrimType a => PrimType (BE a) Source # 

Associated Types

type PrimSize (BE a) :: Nat Source #

Methods

primSizeInBytes :: Proxy * (BE a) -> CountOf Word8 Source #

primShiftToBytes :: Proxy * (BE a) -> Int Source #

primBaUIndex :: ByteArray# -> Offset (BE a) -> BE a Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset (BE a) -> prim (BE a) Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset (BE a) -> BE a -> prim () Source #

primAddrIndex :: Addr# -> Offset (BE a) -> BE a Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset (BE a) -> prim (BE a) Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset (BE a) -> BE a -> prim () Source #

NormalForm a => NormalForm (BE a) Source # 

Methods

toNormalForm :: BE a -> () Source #

type PrimSize (BE a) Source # 
type PrimSize (BE a) = PrimSize a

toBE :: ByteSwap a => a -> BE a Source #

Convert a value in cpu endianess to big endian

fromBE :: ByteSwap a => BE a -> a Source #

Convert from a big endian value to the cpu endianness

Little Endian

newtype LE a Source #

Little Endian value

Constructors

LE 

Fields

Instances

Eq a => Eq (LE a) Source # 

Methods

(==) :: LE a -> LE a -> Bool #

(/=) :: LE a -> LE a -> Bool #

(ByteSwap a, Ord a) => Ord (LE a) Source # 

Methods

compare :: LE a -> LE a -> Ordering #

(<) :: LE a -> LE a -> Bool #

(<=) :: LE a -> LE a -> Bool #

(>) :: LE a -> LE a -> Bool #

(>=) :: LE a -> LE a -> Bool #

max :: LE a -> LE a -> LE a #

min :: LE a -> LE a -> LE a #

Show a => Show (LE a) Source # 

Methods

showsPrec :: Int -> LE a -> ShowS #

show :: LE a -> String #

showList :: [LE a] -> ShowS #

Bits a => Bits (LE a) Source # 

Methods

(.&.) :: LE a -> LE a -> LE a #

(.|.) :: LE a -> LE a -> LE a #

xor :: LE a -> LE a -> LE a #

complement :: LE a -> LE a #

shift :: LE a -> Int -> LE a #

rotate :: LE a -> Int -> LE a #

zeroBits :: LE a #

bit :: Int -> LE a #

setBit :: LE a -> Int -> LE a #

clearBit :: LE a -> Int -> LE a #

complementBit :: LE a -> Int -> LE a #

testBit :: LE a -> Int -> Bool #

bitSizeMaybe :: LE a -> Maybe Int #

bitSize :: LE a -> Int #

isSigned :: LE a -> Bool #

shiftL :: LE a -> Int -> LE a #

unsafeShiftL :: LE a -> Int -> LE a #

shiftR :: LE a -> Int -> LE a #

unsafeShiftR :: LE a -> Int -> LE a #

rotateL :: LE a -> Int -> LE a #

rotateR :: LE a -> Int -> LE a #

popCount :: LE a -> Int #

PrimMemoryComparable a => PrimMemoryComparable (LE a) Source # 
PrimType a => PrimType (LE a) Source # 

Associated Types

type PrimSize (LE a) :: Nat Source #

Methods

primSizeInBytes :: Proxy * (LE a) -> CountOf Word8 Source #

primShiftToBytes :: Proxy * (LE a) -> Int Source #

primBaUIndex :: ByteArray# -> Offset (LE a) -> LE a Source #

primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset (LE a) -> prim (LE a) Source #

primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset (LE a) -> LE a -> prim () Source #

primAddrIndex :: Addr# -> Offset (LE a) -> LE a Source #

primAddrRead :: PrimMonad prim => Addr# -> Offset (LE a) -> prim (LE a) Source #

primAddrWrite :: PrimMonad prim => Addr# -> Offset (LE a) -> LE a -> prim () Source #

NormalForm a => NormalForm (LE a) Source # 

Methods

toNormalForm :: LE a -> () Source #

type PrimSize (LE a) Source # 
type PrimSize (LE a) = PrimSize a

toLE :: ByteSwap a => a -> LE a Source #

Convert a value in cpu endianess to little endian

fromLE :: ByteSwap a => LE a -> a Source #

Convert from a little endian value to the cpu endianness

System Endianness

endianness :: Endianness Source #

endianness of the current architecture