Data.Primitive.Types

primitive-0.6.2.0: Primitive memory-related operations

Copyright | (c) Roman Leshchinskiy 2009-2012
License | BSD-style
Maintainer | Roman Leshchinskiy <rl@cse.unsw.edu.au>
Portability | non-portable
Safe Haskell | None
Language | Haskell2010

Data.Primitive.Types

Description

Basic types and classes for primitive array operations

Synopsis

- class Prim a where
- data Addr = Addr Addr#

# Documentation

class Prim a where #

Class of types supporting primitive array operations

Minimal complete definition

sizeOf#, alignment#, indexByteArray#, readByteArray#, writeByteArray#, setByteArray#, indexOffAddr#, readOffAddr#, writeOffAddr#, setOffAddr#

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.

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

Fill a slice of the mutable array with a value. The offset and length of the chunk are 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.

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

Fill a memory block given by an address, an offset and a length. The offset and length are in elements of type `a` rather than in bytes.

Instances

Prim Char # |
Methods sizeOf# :: Char -> Int# # alignment# :: Char -> Int# # indexByteArray# :: ByteArray# -> Int# -> Char # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Char#) # writeByteArray# :: MutableByteArray# s -> Int# -> Char -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Char -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Char # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Char#) # writeOffAddr# :: Addr# -> Int# -> Char -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Char -> State# s -> State# s #
Prim Double # |
Methods sizeOf# :: Double -> Int# # alignment# :: Double -> Int# # indexByteArray# :: ByteArray# -> Int# -> Double # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Double#) # writeByteArray# :: MutableByteArray# s -> Int# -> Double -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Double -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Double # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Double#) # writeOffAddr# :: Addr# -> Int# -> Double -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Double -> State# s -> State# s #
Prim Float # |
Methods sizeOf# :: Float -> Int# # alignment# :: Float -> Int# # indexByteArray# :: ByteArray# -> Int# -> Float # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Float#) # writeByteArray# :: MutableByteArray# s -> Int# -> Float -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Float -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Float # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Float#) # writeOffAddr# :: Addr# -> Int# -> Float -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Float -> State# s -> State# s #
Prim Int # |
Methods sizeOf# :: Int -> Int# # alignment# :: Int -> Int# # indexByteArray# :: ByteArray# -> Int# -> Int # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Int#) # writeByteArray# :: MutableByteArray# s -> Int# -> Int -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Int -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Int # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Int#) # writeOffAddr# :: Addr# -> Int# -> Int -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Int -> State# s -> State# s #
Prim Int8 # |
Methods sizeOf# :: Int8 -> Int# # alignment# :: Int8 -> Int# # indexByteArray# :: ByteArray# -> Int# -> Int8 # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Int8#) # writeByteArray# :: MutableByteArray# s -> Int# -> Int8 -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Int8 -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Int8 # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Int8#) # writeOffAddr# :: Addr# -> Int# -> Int8 -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Int8 -> State# s -> State# s #
Prim Int16 # |
Methods sizeOf# :: Int16 -> Int# # alignment# :: Int16 -> Int# # indexByteArray# :: ByteArray# -> Int# -> Int16 # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Int16#) # writeByteArray# :: MutableByteArray# s -> Int# -> Int16 -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Int16 -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Int16 # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Int16#) # writeOffAddr# :: Addr# -> Int# -> Int16 -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Int16 -> State# s -> State# s #
Prim Int32 # |
Methods sizeOf# :: Int32 -> Int# # alignment# :: Int32 -> Int# # indexByteArray# :: ByteArray# -> Int# -> Int32 # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Int32#) # writeByteArray# :: MutableByteArray# s -> Int# -> Int32 -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Int32 -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Int32 # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Int32#) # writeOffAddr# :: Addr# -> Int# -> Int32 -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Int32 -> State# s -> State# s #
Prim Int64 # |
Methods sizeOf# :: Int64 -> Int# # alignment# :: Int64 -> Int# # indexByteArray# :: ByteArray# -> Int# -> Int64 # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Int64#) # writeByteArray# :: MutableByteArray# s -> Int# -> Int64 -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Int64 -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Int64 # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Int64#) # writeOffAddr# :: Addr# -> Int# -> Int64 -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Int64 -> State# s -> State# s #
Prim Word # |
Methods sizeOf# :: Word -> Int# # alignment# :: Word -> Int# # indexByteArray# :: ByteArray# -> Int# -> Word # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Word#) # writeByteArray# :: MutableByteArray# s -> Int# -> Word -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Word -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Word # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Word#) # writeOffAddr# :: Addr# -> Int# -> Word -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Word -> State# s -> State# s #
Prim Word8 # |
Methods sizeOf# :: Word8 -> Int# # alignment# :: Word8 -> Int# # indexByteArray# :: ByteArray# -> Int# -> Word8 # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Word8#) # writeByteArray# :: MutableByteArray# s -> Int# -> Word8 -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Word8 -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Word8 # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Word8#) # writeOffAddr# :: Addr# -> Int# -> Word8 -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Word8 -> State# s -> State# s #
Prim Word16 # |
Methods sizeOf# :: Word16 -> Int# # alignment# :: Word16 -> Int# # indexByteArray# :: ByteArray# -> Int# -> Word16 # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Word16#) # writeByteArray# :: MutableByteArray# s -> Int# -> Word16 -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Word16 -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Word16 # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Word16#) # writeOffAddr# :: Addr# -> Int# -> Word16 -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Word16 -> State# s -> State# s #
Prim Word32 # |
Methods sizeOf# :: Word32 -> Int# # alignment# :: Word32 -> Int# # indexByteArray# :: ByteArray# -> Int# -> Word32 # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Word32#) # writeByteArray# :: MutableByteArray# s -> Int# -> Word32 -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Word32 -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Word32 # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Word32#) # writeOffAddr# :: Addr# -> Int# -> Word32 -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Word32 -> State# s -> State# s #
Prim Word64 # |
Methods sizeOf# :: Word64 -> Int# # alignment# :: Word64 -> Int# # indexByteArray# :: ByteArray# -> Int# -> Word64 # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Word64#) # writeByteArray# :: MutableByteArray# s -> Int# -> Word64 -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Word64 -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Word64 # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Word64#) # writeOffAddr# :: Addr# -> Int# -> Word64 -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Word64 -> State# s -> State# s #
Prim Addr # |
Methods sizeOf# :: Addr -> Int# # alignment# :: Addr -> Int# # indexByteArray# :: ByteArray# -> Int# -> Addr # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Addr#) # writeByteArray# :: MutableByteArray# s -> Int# -> Addr -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Addr -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Addr # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Addr#) # writeOffAddr# :: Addr# -> Int# -> Addr -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Addr -> State# s -> State# s #
Prim (Ptr a) # |
Methods sizeOf# :: Ptr a -> Int# # alignment# :: Ptr a -> Int# # indexByteArray# :: ByteArray# -> Int# -> Ptr a # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Ptr a#) # writeByteArray# :: MutableByteArray# s -> Int# -> Ptr a -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Ptr a -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Ptr a # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Ptr a#) # writeOffAddr# :: Addr# -> Int# -> Ptr a -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Ptr a -> State# s -> State# s #
Prim (FunPtr a) # |
Methods sizeOf# :: FunPtr a -> Int# # alignment# :: FunPtr a -> Int# # indexByteArray# :: ByteArray# -> Int# -> FunPtr a # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, FunPtr a#) # writeByteArray# :: MutableByteArray# s -> Int# -> FunPtr a -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> FunPtr a -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> FunPtr a # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, FunPtr a#) # writeOffAddr# :: Addr# -> Int# -> FunPtr a -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> FunPtr a -> State# s -> State# s #

data Addr #

A machine address

Constructors

Addr Addr# |

Instances

Eq Addr # |
Methods (==) :: Addr -> Addr -> Bool # (/=) :: Addr -> Addr -> Bool #
Data Addr # |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Addr -> c Addr # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Addr # toConstr :: Addr -> Constr # dataTypeOf :: Addr -> DataType # dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Addr) # dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Addr) # gmapT :: (forall b. Data b => b -> b) -> Addr -> Addr # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Addr -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Addr -> r # gmapQ :: (forall d. Data d => d -> u) -> Addr -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Addr -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Addr -> m Addr # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Addr -> m Addr # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Addr -> m Addr #
Ord Addr # |
Methods compare :: Addr -> Addr -> Ordering # (<) :: Addr -> Addr -> Bool # (<=) :: Addr -> Addr -> Bool # (>) :: Addr -> Addr -> Bool # (>=) :: Addr -> Addr -> Bool # max :: Addr -> Addr -> Addr # min :: Addr -> Addr -> Addr #
Prim Addr # |
Methods sizeOf# :: Addr -> Int# # alignment# :: Addr -> Int# # indexByteArray# :: ByteArray# -> Int# -> Addr # readByteArray# :: MutableByteArray# s -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Addr#) # writeByteArray# :: MutableByteArray# s -> Int# -> Addr -> State# s -> State# s # setByteArray# :: MutableByteArray# s -> Int# -> Int# -> Addr -> State# s -> State# s # indexOffAddr# :: Addr# -> Int# -> Addr # readOffAddr# :: Addr# -> Int# -> State# s -> (#TupleRep [RuntimeRep], LiftedRep, State# s, Addr#) # writeOffAddr# :: Addr# -> Int# -> Addr -> State# s -> State# s # setOffAddr# :: Addr# -> Int# -> Int# -> Addr -> State# s -> State# s #