hs-bindgen-runtime
Safe HaskellSafe-Inferred
LanguageGHC2021

HsBindgen.Runtime.Marshal

Description

Marshaling and serialization

Generalizes Storable. For details, see https://github.com/well-typed/hs-bindgen/issues/649.

This module is intended to be imported qualified.

import HsBindgen.Runtime.Prelude
import HsBindgen.Runtime.Marshal qualified as Marshal
Synopsis

Type Classes

class StaticSize a where Source #

Size and alignment for values that have a static size in memory

Types that are instances of Storable can derive this instance.

Minimal complete definition

Nothing

Methods

staticSizeOf :: Proxy a -> Int Source #

Storage requirements (bytes)

default staticSizeOf :: Storable a => Proxy a -> Int Source #

staticAlignment :: Proxy a -> Int Source #

Alignment (bytes)

default staticAlignment :: Storable a => Proxy a -> Int Source #

Instances

Instances details
StaticSize CBool Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CChar Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CClock Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CDouble Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CFloat Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CInt Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CIntMax Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CIntPtr Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CLLong Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CLong Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CPtrdiff Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CSChar Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CSUSeconds Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CShort Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CSigAtomic Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CSize Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CTime Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CUChar Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CUInt Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CUIntMax Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CUIntPtr Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CULLong Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CULong Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CUSeconds Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CUShort Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CWchar Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize Int16 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize Int32 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize Int64 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize Int8 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize Word16 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize Word32 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize Word64 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize Word8 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize CChar16T Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

StaticSize CChar32T Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

StaticSize CTm Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

StaticSize CWctransT Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

StaticSize CWctypeT Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

StaticSize CWintT Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

StaticSize () Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize Bool Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize Char Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize Double Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize Float Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize Int Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize Word Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize a => StaticSize (Complex a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize (FunPtr a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize (Ptr a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize (StablePtr a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

StaticSize (PtrConst a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

(Storable a, KnownNat n) => StaticSize (ConstantArray n a) Source # 
Instance details

Defined in HsBindgen.Runtime.ConstantArray

class ReadRaw a where Source #

Values that can be read from memory

Types that are instances of Storable can derive this instance.

Minimal complete definition

Nothing

Methods

readRaw :: Ptr a -> IO a Source #

Read a value from the given memory location

This function might require a properly aligned address to function correctly, depending on the architecture.

default readRaw :: Storable a => Ptr a -> IO a Source #

Instances

Instances details
ReadRaw CBool Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CChar Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CClock Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CDouble Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CFloat Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CInt Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

readRaw :: Ptr CInt -> IO CInt Source #

ReadRaw CIntMax Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CIntPtr Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CLLong Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CLong Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CPtrdiff Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CSChar Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CSUSeconds Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CShort Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CSigAtomic Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CSize Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CTime Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CUChar Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CUInt Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CUIntMax Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CUIntPtr Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CULLong Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CULong Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CUSeconds Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CUShort Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CWchar Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw Int16 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw Int32 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw Int64 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw Int8 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

readRaw :: Ptr Int8 -> IO Int8 Source #

ReadRaw Word16 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw Word32 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw Word64 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw Word8 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw CChar16T Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

ReadRaw CChar32T Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

ReadRaw CTm Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

Methods

readRaw :: Ptr CTm -> IO CTm Source #

ReadRaw CWctransT Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

ReadRaw CWctypeT Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

ReadRaw CWintT Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

ReadRaw () Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

readRaw :: Ptr () -> IO () Source #

ReadRaw Bool Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

readRaw :: Ptr Bool -> IO Bool Source #

ReadRaw Char Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

readRaw :: Ptr Char -> IO Char Source #

ReadRaw Double Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw Float Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

ReadRaw Int Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

readRaw :: Ptr Int -> IO Int Source #

ReadRaw Word Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

readRaw :: Ptr Word -> IO Word Source #

(ReadRaw a, StaticSize a) => ReadRaw (Complex a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

readRaw :: Ptr (Complex a) -> IO (Complex a) Source #

ReadRaw (FunPtr a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

readRaw :: Ptr (FunPtr a) -> IO (FunPtr a) Source #

ReadRaw (Ptr a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

readRaw :: Ptr (Ptr a) -> IO (Ptr a) Source #

ReadRaw (StablePtr a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

readRaw :: Ptr (StablePtr a) -> IO (StablePtr a) Source #

ReadRaw (PtrConst a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

readRaw :: Ptr (PtrConst a) -> IO (PtrConst a) Source #

(Storable a, KnownNat n) => ReadRaw (ConstantArray n a) Source # 
Instance details

Defined in HsBindgen.Runtime.ConstantArray

Methods

readRaw :: Ptr (ConstantArray n a) -> IO (ConstantArray n a) Source #

(Storable aux, Storable elem, NumElems elem aux) => ReadRaw (WithFlam elem aux) Source # 
Instance details

Defined in HsBindgen.Runtime.FLAM

Methods

readRaw :: Ptr (WithFlam elem aux) -> IO (WithFlam elem aux) Source #

class WriteRaw a where Source #

Values that can be written to memory

Types that are instances of Storable can derive this instance.

Minimal complete definition

Nothing

Methods

writeRaw :: Ptr a -> a -> IO () Source #

Write a value to the given memory location

This function might require a properly aligned address to function correctly, depending on the architecture.

default writeRaw :: Storable a => Ptr a -> a -> IO () Source #

Instances

Instances details
WriteRaw CBool Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CBool -> CBool -> IO () Source #

WriteRaw CChar Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CChar -> CChar -> IO () Source #

WriteRaw CClock Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CClock -> CClock -> IO () Source #

WriteRaw CDouble Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CDouble -> CDouble -> IO () Source #

WriteRaw CFloat Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CFloat -> CFloat -> IO () Source #

WriteRaw CInt Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CInt -> CInt -> IO () Source #

WriteRaw CIntMax Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CIntMax -> CIntMax -> IO () Source #

WriteRaw CIntPtr Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CIntPtr -> CIntPtr -> IO () Source #

WriteRaw CLLong Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CLLong -> CLLong -> IO () Source #

WriteRaw CLong Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CLong -> CLong -> IO () Source #

WriteRaw CPtrdiff Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CPtrdiff -> CPtrdiff -> IO () Source #

WriteRaw CSChar Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CSChar -> CSChar -> IO () Source #

WriteRaw CSUSeconds Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

WriteRaw CShort Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CShort -> CShort -> IO () Source #

WriteRaw CSigAtomic Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

WriteRaw CSize Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CSize -> CSize -> IO () Source #

WriteRaw CTime Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CTime -> CTime -> IO () Source #

WriteRaw CUChar Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CUChar -> CUChar -> IO () Source #

WriteRaw CUInt Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CUInt -> CUInt -> IO () Source #

WriteRaw CUIntMax Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CUIntMax -> CUIntMax -> IO () Source #

WriteRaw CUIntPtr Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CUIntPtr -> CUIntPtr -> IO () Source #

WriteRaw CULLong Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CULLong -> CULLong -> IO () Source #

WriteRaw CULong Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CULong -> CULong -> IO () Source #

WriteRaw CUSeconds Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

WriteRaw CUShort Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CUShort -> CUShort -> IO () Source #

WriteRaw CWchar Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr CWchar -> CWchar -> IO () Source #

WriteRaw Int16 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr Int16 -> Int16 -> IO () Source #

WriteRaw Int32 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr Int32 -> Int32 -> IO () Source #

WriteRaw Int64 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr Int64 -> Int64 -> IO () Source #

WriteRaw Int8 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr Int8 -> Int8 -> IO () Source #

WriteRaw Word16 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr Word16 -> Word16 -> IO () Source #

WriteRaw Word32 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr Word32 -> Word32 -> IO () Source #

WriteRaw Word64 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr Word64 -> Word64 -> IO () Source #

WriteRaw Word8 Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr Word8 -> Word8 -> IO () Source #

WriteRaw CChar16T Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

Methods

writeRaw :: Ptr CChar16T -> CChar16T -> IO () Source #

WriteRaw CChar32T Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

Methods

writeRaw :: Ptr CChar32T -> CChar32T -> IO () Source #

WriteRaw CWctransT Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

WriteRaw CWctypeT Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

Methods

writeRaw :: Ptr CWctypeT -> CWctypeT -> IO () Source #

WriteRaw CWintT Source # 
Instance details

Defined in HsBindgen.Runtime.Internal.LibC.Auxiliary

Methods

writeRaw :: Ptr CWintT -> CWintT -> IO () Source #

WriteRaw () Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr () -> () -> IO () Source #

WriteRaw Bool Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr Bool -> Bool -> IO () Source #

WriteRaw Char Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr Char -> Char -> IO () Source #

WriteRaw Double Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr Double -> Double -> IO () Source #

WriteRaw Float Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr Float -> Float -> IO () Source #

WriteRaw Int Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr Int -> Int -> IO () Source #

WriteRaw Word Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr Word -> Word -> IO () Source #

(StaticSize a, WriteRaw a) => WriteRaw (Complex a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr (Complex a) -> Complex a -> IO () Source #

WriteRaw (FunPtr a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr (FunPtr a) -> FunPtr a -> IO () Source #

WriteRaw (Ptr a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr (Ptr a) -> Ptr a -> IO () Source #

WriteRaw (StablePtr a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr (StablePtr a) -> StablePtr a -> IO () Source #

WriteRaw (PtrConst a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Methods

writeRaw :: Ptr (PtrConst a) -> PtrConst a -> IO () Source #

(Storable a, KnownNat n) => WriteRaw (ConstantArray n a) Source # 
Instance details

Defined in HsBindgen.Runtime.ConstantArray

Methods

writeRaw :: Ptr (ConstantArray n a) -> ConstantArray n a -> IO () Source #

(Storable aux, Storable elem, NumElems elem aux) => WriteRaw (WithFlam elem aux) Source # 
Instance details

Defined in HsBindgen.Runtime.FLAM

Methods

writeRaw :: Ptr (WithFlam elem aux) -> WithFlam elem aux -> IO () Source #

newtype EquivStorable a Source #

Type used to derive a Storable instance when the type has StaticSize, ReadRaw, and WriteRaw instances

Use the DerivingVia GHC extension as follows:

{-# LANGUAGE DerivingVia #-}

data Foo = Foo { ... }
  deriving Storable via EquivStorable Foo

Constructors

EquivStorable a 

Instances

Instances details
(ReadRaw a, StaticSize a, WriteRaw a) => Storable (EquivStorable a) Source # 
Instance details

Defined in HsBindgen.Runtime.Marshal

Utility Functions

readRawByteOff :: ReadRaw a => Ptr b -> Int -> IO a Source #

Read a value from the given memory location, given by a base address and an offset

writeRawByteOff :: WriteRaw a => Ptr b -> Int -> a -> IO () Source #

Write a value to the given memory location, given by a base address and an offset

readRawElemOff :: forall a. (ReadRaw a, StaticSize a) => Ptr a -> Int -> IO a Source #

Read a value from a memory area regarded as an array of values of the same kind

The first argument specifies the start address of the array. The second specifies the (zero-based) index into the array.

writeRawElemOff :: forall a. (StaticSize a, WriteRaw a) => Ptr a -> Int -> a -> IO () Source #

Write a value to a memory area regarded as an array of values of the same kind

The first argument specifies the start address of the array. The second specifies the (zero-based) index into the array.

maybeReadRaw :: ReadRaw a => Ptr a -> IO (Maybe a) Source #

Read a value from memory when passed a non-null pointer

with :: forall a b. (StaticSize a, WriteRaw a) => a -> (Ptr a -> IO b) -> IO b Source #

Allocate local memory, write the specified value, and call a function with the pointer

The allocated memory is aligned.

Memory that is not written to by poke may contain arbitrary data.

The allocated memory is freed when the function terminates, either normally or via an exception. The passed pointer must therefore not be used after this.

withZero :: forall a b. (StaticSize a, WriteRaw a) => a -> (Ptr a -> IO b) -> IO b Source #

Allocate local memory, write the specified value, and call a function with the pointer

The allocated memory is aligned.

The memory is filled with bytes of value zero before the value is written. Memory that is not written to by poke contains zeros, not arbitrary data.

The allocated memory is freed when the function terminates, either normally or via an exception. The passed pointer must therefore not be used after this.

new :: forall a. (StaticSize a, WriteRaw a) => a -> IO (ForeignPtr a) Source #

Allocate memory, write the specified value, and the ForeignPtr

The allocated memory is aligned.

Memory that is not written to by writeRaw may contain arbitrary data.

newZero :: forall a. (StaticSize a, WriteRaw a) => a -> IO (ForeignPtr a) Source #

Allocate memory, write the specified value, and the ForeignPtr

The allocated memory is aligned.

The memory is filled with bytes of value zero before the value is written. Memory that is not written to by writeRaw contains zeros, not arbitrary data.