Safe Haskell | None |
---|---|
Language | Haskell2010 |
Byte order ("endianness")
Indicate in which order bytes are stored in memory for multi-bytes types. Big-endian means that most-significant bytes come first. Little-endian means that least-significant bytes come first.
Synopsis
- data Endianness
- data WordGetters = WordGetters {}
- data WordPutters = WordPutters {
- wordPutter8 :: Word8 -> Put
- wordPutter16 :: Word16 -> Put
- wordPutter32 :: Word32 -> Put
- wordPutter64 :: Word64 -> Put
- getWordGetters :: Endianness -> WordGetters
- getWordPutters :: Endianness -> WordPutters
- data WordSize
- data ExtendedWordGetters = ExtendedWordGetters {}
- data ExtendedWordPutters = ExtendedWordPutters {
- extwordPutter8 :: Word8 -> Put
- extwordPutter16 :: Word16 -> Put
- extwordPutter32 :: Word32 -> Put
- extwordPutter64 :: Word64 -> Put
- extwordPutterN :: Word64 -> Put
- getExtendedWordGetters :: Endianness -> WordSize -> ExtendedWordGetters
- getExtendedWordPutters :: Endianness -> WordSize -> ExtendedWordPutters
- getHostEndianness :: IO Endianness
- hostEndianness :: Endianness
- class ByteReversable w where
- reverseBytes :: w -> w
- hostToBigEndian :: w -> w
- bigEndianToHost :: w -> w
- hostToLittleEndian :: w -> w
- littleEndianToHost :: w -> w
- newtype AsBigEndian a = AsBigEndian a
- newtype AsLittleEndian a = AsLittleEndian a
Documentation
data Endianness Source #
Endianness
LittleEndian | Less significant bytes first |
BigEndian | Most significant bytes first |
Instances
Enum Endianness Source # | |
Defined in Haskus.Binary.Endianness succ :: Endianness -> Endianness # pred :: Endianness -> Endianness # toEnum :: Int -> Endianness # fromEnum :: Endianness -> Int # enumFrom :: Endianness -> [Endianness] # enumFromThen :: Endianness -> Endianness -> [Endianness] # enumFromTo :: Endianness -> Endianness -> [Endianness] # enumFromThenTo :: Endianness -> Endianness -> Endianness -> [Endianness] # | |
Eq Endianness Source # | |
Defined in Haskus.Binary.Endianness (==) :: Endianness -> Endianness -> Bool # (/=) :: Endianness -> Endianness -> Bool # | |
Show Endianness Source # | |
Defined in Haskus.Binary.Endianness showsPrec :: Int -> Endianness -> ShowS # show :: Endianness -> String # showList :: [Endianness] -> ShowS # | |
CEnum Endianness Source # | |
Defined in Haskus.Binary.Endianness fromCEnum :: Integral b => Endianness -> b Source # toCEnum :: Integral b => b -> Endianness Source # |
data WordGetters Source #
Word getter
WordGetters | |
|
data WordPutters Source #
Word putters
WordPutters | |
|
getWordGetters :: Endianness -> WordGetters Source #
Get getters for the given endianness
getWordPutters :: Endianness -> WordPutters Source #
Get putters for the given endianness
Size of a machine word
WordSize32 | 32-bit |
WordSize64 | 64-bit |
data ExtendedWordGetters Source #
Extended word getters
ExtendedWordGetters | |
|
data ExtendedWordPutters Source #
Extended word putters
ExtendedWordPutters | |
|
getExtendedWordGetters :: Endianness -> WordSize -> ExtendedWordGetters Source #
Return extended getters
getExtendedWordPutters :: Endianness -> WordSize -> ExtendedWordPutters Source #
Return extended putters
getHostEndianness :: IO Endianness Source #
Detect the endianness of the host memory
hostEndianness :: Endianness Source #
Detected host endianness
TODO: use targetByteOrder in GHC.ByteOrder (should be introduced in GHC 8.4)
class ByteReversable w where Source #
Reverse bytes in a word
reverseBytes :: w -> w Source #
hostToBigEndian :: w -> w Source #
bigEndianToHost :: w -> w Source #
hostToLittleEndian :: w -> w Source #
littleEndianToHost :: w -> w Source #
Instances
newtype AsBigEndian a Source #
Force a data to be read/stored as big-endian
Instances
newtype AsLittleEndian a Source #
Force a data to be read/stored as little-endian