Data.Primitive.Types

primitive-0.3.1: Wrappers for primitive operations

Portability | non-portable
Maintainer | Roman Leshchinskiy <rl@cse.unsw.edu.au>

Data.Primitive.Types

Description

Basic types and classes for primitive array operations

Synopsis

- class Prim a where
  - sizeOf# :: a -> Int#
  - alignment# :: a -> Int#
  - indexByteArray# :: ByteArray# -> Int# -> a
  - readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#State# s, a#)
  - writeByteArray# :: MutableByteArray# s -> Int# -> a -> State# s -> State# s
  - indexOffAddr# :: Addr# -> Int# -> a
  - readOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, a#)
  - writeOffAddr# :: Addr# -> Int# -> a -> State# s -> State# s
- data Addr = Addr Addr#

# Documentation

class Prim a where

Class of types supporting primitive array operations

Methods

sizeOf# :: a -> Int#

Size of values of type `a`. The argument is not used.

alignment# :: a -> Int#

Alignment of values of type `a`. The argument is not used.

indexByteArray# :: ByteArray# -> Int# -> a

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

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

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

writeByteArray# :: MutableByteArray# s -> Int# -> a -> State# s -> State# s

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

indexOffAddr# :: Addr# -> Int# -> a

Read a value from a memory position given by an address and an offset. The memory block the address refers to must be immutable. The offset is in elements of type `a` rather than in bytes.

readOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, a#)

Read a value from a memory position given by an address and an offset. The offset is in elements of type `a` rather than in bytes.

writeOffAddr# :: Addr# -> Int# -> a -> State# s -> State# s

Write a value to a memory position given by an address and an offset. The offset is in elements of type `a` rather than in bytes.

Instances

Prim Char |
Prim Double |
Prim Float |
Prim Int |
Prim Int8 |
Prim Int16 |
Prim Int32 |
Prim Int64 |
Prim Word |
Prim Word8 |
Prim Word16 |
Prim Word32 |
Prim Word64 |
Prim Addr |

data Addr

A machine address

Constructors

Addr Addr# |

Instances

Eq Addr |
Data Addr |
Ord Addr |
Typeable Addr |
Prim Addr |