Data.Vector.Storable.Internal

vector-0.12.3.1: Efficient Arrays

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

Data.Vector.Storable.Internal

Description

Ugly internal utility functions for implementing `Storable`-based vectors.

Synopsis

- getPtr :: ForeignPtr a -> Ptr a
- setPtr :: ForeignPtr a -> Ptr a -> ForeignPtr a
- updPtr :: (Ptr a -> Ptr a) -> ForeignPtr a -> ForeignPtr a
- unsafeWithForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b

# Documentation

getPtr :: ForeignPtr a -> Ptr a #

setPtr :: ForeignPtr a -> Ptr a -> ForeignPtr a #

updPtr :: (Ptr a -> Ptr a) -> ForeignPtr a -> ForeignPtr a #

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

This is similar to `withForeignPtr` but comes with an important caveat: the user must guarantee that the continuation does not diverge (e.g. loop or throw an exception). In exchange for this loss of generality, this function offers the ability of GHC to optimise more aggressively.

Specifically, applications of the form: `unsafeWithForeignPtr fptr (`forever` something)`

See GHC issue #17760 for more information about the unsoundness behavior that this function can result in.