base-compat-0.11.1: A compatibility layer for base

Safe Haskell | Trustworthy
Language | Haskell98

Foreign.ForeignPtr.Safe.Compat

Contents

- Finalised data pointers
  - Basic operations
  - Low-level operations
  - Allocating managed memory

Synopsis

- data ForeignPtr a
- type FinalizerPtr a = FunPtr (Ptr a -> IO ())
- type FinalizerEnvPtr env a = FunPtr (Ptr env -> Ptr a -> IO ())
- newForeignPtr :: FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
- newForeignPtr_ :: Ptr a -> IO (ForeignPtr a)
- addForeignPtrFinalizer :: FinalizerPtr a -> ForeignPtr a -> IO ()
- newForeignPtrEnv :: FinalizerEnvPtr env a -> Ptr env -> Ptr a -> IO (ForeignPtr a)
- addForeignPtrFinalizerEnv :: FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
- withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b
- finalizeForeignPtr :: ForeignPtr a -> IO ()
- touchForeignPtr :: ForeignPtr a -> IO ()
- castForeignPtr :: ForeignPtr a -> ForeignPtr b
- mallocForeignPtr :: Storable a => IO (ForeignPtr a)
- mallocForeignPtrBytes :: Int -> IO (ForeignPtr a)
- mallocForeignPtrArray :: Storable a => Int -> IO (ForeignPtr a)
- mallocForeignPtrArray0 :: Storable a => Int -> IO (ForeignPtr a)

# Finalised data pointers

data ForeignPtr a #

#### Instances

Instances details

Eq (ForeignPtr a) |
Instance details Defined in GHC.ForeignPtr Methods (==) :: ForeignPtr a -> ForeignPtr a -> Bool (/=) :: ForeignPtr a -> ForeignPtr a -> Bool
Ord (ForeignPtr a) |
Instance details Defined in GHC.ForeignPtr Methods compare :: ForeignPtr a -> ForeignPtr a -> Ordering (<) :: ForeignPtr a -> ForeignPtr a -> Bool (<=) :: ForeignPtr a -> ForeignPtr a -> Bool (>) :: ForeignPtr a -> ForeignPtr a -> Bool (>=) :: ForeignPtr a -> ForeignPtr a -> Bool max :: ForeignPtr a -> ForeignPtr a -> ForeignPtr a min :: ForeignPtr a -> ForeignPtr a -> ForeignPtr a
Show (ForeignPtr a) |
Instance details Defined in GHC.ForeignPtr Methods showsPrec :: Int -> ForeignPtr a -> ShowS show :: ForeignPtr a -> String showList :: [ForeignPtr a] -> ShowS

type FinalizerPtr a = FunPtr (Ptr a -> IO ()) #

type FinalizerEnvPtr env a = FunPtr (Ptr env -> Ptr a -> IO ()) #

## Basic operations

newForeignPtr :: FinalizerPtr a -> Ptr a -> IO (ForeignPtr a) #

newForeignPtr_ :: Ptr a -> IO (ForeignPtr a) #

addForeignPtrFinalizer :: FinalizerPtr a -> ForeignPtr a -> IO () #

newForeignPtrEnv :: FinalizerEnvPtr env a -> Ptr env -> Ptr a -> IO (ForeignPtr a) #

addForeignPtrFinalizerEnv :: FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO () #

withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b #

finalizeForeignPtr :: ForeignPtr a -> IO () #

## Low-level operations

touchForeignPtr :: ForeignPtr a -> IO () #

castForeignPtr :: ForeignPtr a -> ForeignPtr b #

## Allocating managed memory

mallocForeignPtr :: Storable a => IO (ForeignPtr a) #

mallocForeignPtrBytes :: Int -> IO (ForeignPtr a) #

mallocForeignPtrArray :: Storable a => Int -> IO (ForeignPtr a) #

mallocForeignPtrArray0 :: Storable a => Int -> IO (ForeignPtr a) #