byte-order-0.1.3.1: Portable big-endian and little-endian conversions

Safe Haskell | None
Language | Haskell2010

System.ByteOrder.Class

Synopsis

- class FixedOrdering (b :: ByteOrder) where
  - toFixedEndian :: Bytes a => a -> a
- class Bytes a where
  - toBigEndian :: a -> a
  - toLittleEndian :: a -> a

# Documentation

class FixedOrdering (b :: ByteOrder) where Source #

A byte order that can be interpreted as a conversion function. This class is effectively closed. The only instances are for `BigEndian` and `LittleEndian`. It is not possible to write more instances since there are no other inhabitants of `ByteOrder`.

Methods

toFixedEndian :: Bytes a => a -> a Source #

#### Instances

Instances details

FixedOrdering 'BigEndian Source # |
Instance details Defined in System.ByteOrder.Class Methods toFixedEndian :: Bytes a => a -> a Source #
FixedOrdering 'LittleEndian Source # |
Instance details Defined in System.ByteOrder.Class Methods toFixedEndian :: Bytes a => a -> a Source #

class Bytes a where Source #

Types that are represented as a fixed-sized word. For these types, the bytes can be swapped. The instances of this class use byteswapping primitives and compile-time knowledge of native endianness to provide portable endianness conversion functions.

Methods

toBigEndian :: a -> a Source #

Convert from a native-endian word to a big-endian word.

toLittleEndian :: a -> a Source #

Convert from a native-endian word to a little-endian word.

#### Instances

Instances details

Bytes Int16 Source # |
Instance details Defined in System.ByteOrder.Class Methods toBigEndian :: Int16 -> Int16 Source # toLittleEndian :: Int16 -> Int16 Source #
Bytes Int32 Source # |
Instance details Defined in System.ByteOrder.Class Methods toBigEndian :: Int32 -> Int32 Source # toLittleEndian :: Int32 -> Int32 Source #
Bytes Int64 Source # |
Instance details Defined in System.ByteOrder.Class Methods toBigEndian :: Int64 -> Int64 Source # toLittleEndian :: Int64 -> Int64 Source #
Bytes Int8 Source # |
Instance details Defined in System.ByteOrder.Class Methods toBigEndian :: Int8 -> Int8 Source # toLittleEndian :: Int8 -> Int8 Source #
Bytes Word16 Source # |
Instance details Defined in System.ByteOrder.Class Methods toBigEndian :: Word16 -> Word16 Source # toLittleEndian :: Word16 -> Word16 Source #
Bytes Word32 Source # |
Instance details Defined in System.ByteOrder.Class Methods toBigEndian :: Word32 -> Word32 Source # toLittleEndian :: Word32 -> Word32 Source #
Bytes Word64 Source # |
Instance details Defined in System.ByteOrder.Class Methods toBigEndian :: Word64 -> Word64 Source # toLittleEndian :: Word64 -> Word64 Source #
Bytes Word8 Source # |
Instance details Defined in System.ByteOrder.Class Methods toBigEndian :: Word8 -> Word8 Source # toLittleEndian :: Word8 -> Word8 Source #
Bytes Word128 Source # |
Instance details Defined in System.ByteOrder.Class Methods toBigEndian :: Word128 -> Word128 Source # toLittleEndian :: Word128 -> Word128 Source #
Bytes Word256 Source # |
Instance details Defined in System.ByteOrder.Class Methods toBigEndian :: Word256 -> Word256 Source # toLittleEndian :: Word256 -> Word256 Source #
Bytes Word Source # |
Instance details Defined in System.ByteOrder.Class Methods toBigEndian :: Word -> Word Source # toLittleEndian :: Word -> Word Source #