primitive-unaligned-0.1.1.2: Unaligned access to primitive arrays

Safe Haskell | None
Language | Haskell2010

Data.Primitive.ByteArray.Unaligned

Contents

- Class
- Array access

Synopsis

- class PrimUnaligned a where
  - indexUnalignedByteArray# :: ByteArray# -> Int# -> a
  - readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, a #)
  - writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> a -> State# s -> State# s
- indexUnalignedByteArray :: PrimUnaligned a => ByteArray -> Int -> a
- readUnalignedByteArray :: (PrimMonad m, PrimUnaligned a) => MutableByteArray (PrimState m) -> Int -> m a
- writeUnalignedByteArray :: (PrimMonad m, PrimUnaligned a) => MutableByteArray (PrimState m) -> Int -> a -> m ()

# Class

class PrimUnaligned a where Source #

Class of types supporting primitive array operations that are not necessarily aligned. The offsets for all of the typeclass methods are interpreted as bytes, not elements.

Methods

indexUnalignedByteArray# :: ByteArray# -> Int# -> a Source #

readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, a #) Source #

writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> a -> State# s -> State# s Source #

#### Instances

Instances details

PrimUnaligned CChar Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CChar Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CChar #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CChar -> State# s -> State# s Source #
PrimUnaligned CDouble Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CDouble Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CDouble #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CDouble -> State# s -> State# s Source #
PrimUnaligned CInt Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CInt Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CInt #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CInt -> State# s -> State# s Source #
PrimUnaligned CLLong Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CLLong Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CLLong #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CLLong -> State# s -> State# s Source #
PrimUnaligned CLong Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CLong Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CLong #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CLong -> State# s -> State# s Source #
PrimUnaligned CSChar Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CSChar Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CSChar #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CSChar -> State# s -> State# s Source #
PrimUnaligned CShort Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CShort Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CShort #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CShort -> State# s -> State# s Source #
PrimUnaligned CUInt Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CUInt Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CUInt #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CUInt -> State# s -> State# s Source #
PrimUnaligned CULLong Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CULLong Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CULLong #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CULLong -> State# s -> State# s Source #
PrimUnaligned CULong Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CULong Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CULong #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CULong -> State# s -> State# s Source #
PrimUnaligned Int16 Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Int16 Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int16 #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Int16 -> State# s -> State# s Source #
PrimUnaligned Int32 Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Int32 Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int32 #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Int32 -> State# s -> State# s Source #
PrimUnaligned Int64 Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Int64 Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int64 #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Int64 -> State# s -> State# s Source #
PrimUnaligned Int8 Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Int8 Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int8 #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Int8 -> State# s -> State# s Source #
PrimUnaligned CDev Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CDev Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CDev #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CDev -> State# s -> State# s Source #
PrimUnaligned CIno Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CIno Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CIno #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CIno -> State# s -> State# s Source #
PrimUnaligned CMode Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CMode Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CMode #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CMode -> State# s -> State# s Source #
PrimUnaligned COff Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> COff Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, COff #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> COff -> State# s -> State# s Source #
PrimUnaligned CPid Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CPid Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CPid #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CPid -> State# s -> State# s Source #
PrimUnaligned CSsize Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> CSsize Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, CSsize #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> CSsize -> State# s -> State# s Source #
PrimUnaligned Fd Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Fd Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Fd #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Fd -> State# s -> State# s Source #
PrimUnaligned Word16 Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Word16 Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word16 #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Word16 -> State# s -> State# s Source #
PrimUnaligned Word32 Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Word32 Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word32 #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Word32 -> State# s -> State# s Source #
PrimUnaligned Word64 Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Word64 Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word64 #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Word64 -> State# s -> State# s Source #
PrimUnaligned Word8 Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Word8 Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word8 #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Word8 -> State# s -> State# s Source #
PrimUnaligned Char Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Char Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Char #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Char -> State# s -> State# s Source #
PrimUnaligned Double Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Double Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Double #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Double -> State# s -> State# s Source #
PrimUnaligned Float Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Float Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Float #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Float -> State# s -> State# s Source #
PrimUnaligned Int Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Int Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Int #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Int -> State# s -> State# s Source #
PrimUnaligned Word Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Word Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Word #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Word -> State# s -> State# s Source #
PrimUnaligned (Ptr a) Source # |
Instance details Defined in Data.Primitive.ByteArray.Unaligned Methods indexUnalignedByteArray# :: ByteArray# -> Int# -> Ptr a Source # readUnalignedByteArray# :: MutableByteArray# s -> Int# -> State# s -> (# State# s, Ptr a #) Source # writeUnalignedByteArray# :: MutableByteArray# s -> Int# -> Ptr a -> State# s -> State# s Source #

# Array access

indexUnalignedByteArray Source #

Arguments

:: PrimUnaligned a |
=> ByteArray | Immutable array
-> Int | Offset in bytes
-> a |

Read a primitive value from the byte array. The offset is given in bytes rather than in elements of type `a`.

readUnalignedByteArray Source #

Arguments

:: (PrimMonad m, PrimUnaligned a) |
=> MutableByteArray (PrimState m) | Mutable array
-> Int | Offset in bytes
-> m a |

Read a primitive value from the byte array. The offset is given in bytes rather than in elements of type `a`.

writeUnalignedByteArray Source #

Arguments

:: (PrimMonad m, PrimUnaligned a) |
=> MutableByteArray (PrimState m) | Mutable array
-> Int | Offset in bytes
-> a | Element
-> m () |

Write a primitive value to the byte array. The offset is given in bytes rather than in elements of type `a`.