foundation-0.0.8: Alternative prelude with batteries and no dependencies

LicenseBSD-style
MaintainerVincent Hanquez <vincent@snarc.org>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Foundation.Foreign

Description

 

Synopsis

Documentation

data FinalPtr a Source #

Create a pointer with an associated finalizer

Constructors

FinalPtr (Ptr a) 
FinalForeign (ForeignPtr a) 

Instances

Eq (FinalPtr a) Source # 

Methods

(==) :: FinalPtr a -> FinalPtr a -> Bool #

(/=) :: FinalPtr a -> FinalPtr a -> Bool #

Ord (FinalPtr a) Source # 

Methods

compare :: FinalPtr a -> FinalPtr a -> Ordering #

(<) :: FinalPtr a -> FinalPtr a -> Bool #

(<=) :: FinalPtr a -> FinalPtr a -> Bool #

(>) :: FinalPtr a -> FinalPtr a -> Bool #

(>=) :: FinalPtr a -> FinalPtr a -> Bool #

max :: FinalPtr a -> FinalPtr a -> FinalPtr a #

min :: FinalPtr a -> FinalPtr a -> FinalPtr a #

Show (FinalPtr a) Source # 

Methods

showsPrec :: Int -> FinalPtr a -> ShowS #

show :: FinalPtr a -> String #

showList :: [FinalPtr a] -> ShowS #

finalPtrSameMemory :: FinalPtr a -> FinalPtr b -> Bool Source #

Check if 2 final ptr points on the same memory bits

it stand to reason that provided a final ptr that is still being referenced and thus have the memory still valid, if 2 final ptrs have the same address, they should be the same final ptr

castFinalPtr :: FinalPtr a -> FinalPtr b Source #

Cast a finalized pointer from type a to type b

toFinalPtr :: PrimMonad prim => Ptr a -> (Ptr a -> IO ()) -> prim (FinalPtr a) Source #

create a new FinalPtr from a Pointer

toFinalPtrForeign :: ForeignPtr a -> FinalPtr a Source #

Create a new FinalPtr from a ForeignPtr

withFinalPtr :: PrimMonad prim => FinalPtr p -> (Ptr p -> prim a) -> prim a Source #

Looks at the raw pointer inside a FinalPtr, making sure the data pointed by the pointer is not finalized during the call to f

withUnsafeFinalPtr :: PrimMonad prim => FinalPtr p -> (Ptr p -> prim a) -> a Source #

Unsafe version of withFinalPtr

withFinalPtrNoTouch :: FinalPtr p -> (Ptr p -> a) -> a Source #

foreignMem Source #

Arguments

:: PrimType ty 
=> FinalPtr ty

the start pointer with a finalizer

-> Int

the number of elements (in elements, not bytes)

-> UArray ty 

mutableForeignMem Source #

Arguments

:: (PrimMonad prim, PrimType ty) 
=> FinalPtr ty

the start pointer with a finalizer

-> Int

the number of elements (in elements, not bytes)

-> prim (MUArray ty (PrimState prim))