H      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFG#Bas van Dijk <v.dijk.bas@gmail.com>IA regional handle to memory. This should provide a safer replacement for   Foreign.Ptr.H I3Construct a regional pointer from a native pointer  and an IO. computation that finalizes the pointer (like free ptr) 0 which is performed when the region terminates. 0This function is unsafe because this library can't guarantee that the > finalizer will actually finalize the pointer (suppose having  return () as G the finalizer). You have to verify the correct finalisation yourself. 3Construct a regional pointer from a native pointer & without registering a finalizer like free ptr. 0This function is unsafe because this library can't guarantee the finalisation G of the pointer, you have to verify the correct finalisation yourself. &Note that the region parameter of the  is set to J M which is the ancestor of any region. This allows the regional pointer to be  used in any region. 5Retrieve the native pointer from a regional pointer. 6This function is unsafe because it both allows you to free the pointer M before the region terminates and use the pointer outside the region when it  is already freed.  I II #Bas van Dijk <v.dijk.bas@gmail.com>  #Bas van Dijk <v.dijk.bas@gmail.com>  The constant nullPtr# contains a distinguished value of  6 that is not associated with a valid memory location.  Note that nullPtr5 is a pure value. This means it does not perform the - side-effect of registering a finalizer like  free nullPtr  in the K monad. .Finally note that the region parameter of the  is set to  J2 which is the ancestor of any region. This allows   to be  used in any region. Apply a pure6 function to the inner pointer of a regional pointer. The castPtr4 function casts a pointer from one type to another. Wraps:  Foreign.Ptr.L 9Advances the given address by the given offset in bytes. Wraps:  Foreign.Ptr.M 8Given an arbitrary address and an alignment constraint, alignPtr yields N the next higher address that fulfills the alignment constraint. An alignment  constraint x* is fulfilled by any address divisible by x. This operation  is idempotent. Wraps:  Foreign.Ptr.N AComputes the offset required to get from the second to the first  argument. We have  ' p2 == p1 `plusPtr` (p2 `minusPtr` p1) Wraps:  Foreign.Ptr.O PQRSKTUVJ   #Bas van Dijk <v.dijk.bas@gmail.com>IConvenience function which allocates sufficient memory to hold values of type D, applies the given continuation function to the resulting regional 'pointer and runs the resulting region. -This should provide a safer replacement for: Foreign.Marshal.Alloc.W.  Note that:  alloca =  $ X (undefined :: ) LConvenience function which allocates the given number of bytes, applies the Kgiven continuation function to the resulting regional pointer and runs the resulting region. -This should provide a safer replacement for: Foreign.Marshal.Alloc.Y.  Note that: allocaBytes size f = S $  size >>= f IConvenience function which allocates sufficient memory to hold values of type ) and returns a regional pointer to them. -This should provide a safer replacement for: Foreign.Marshal.Alloc.Z.  Note that:  malloc =  $ X (undefined :: ) LAllocates the given number of bytes and returns a regional pointer to them. -This should provide a safer replacement for: Foreign.Marshal.Alloc.[. #Bas van Dijk <v.dijk.bas@gmail.com>KRead a value from a memory area regarded as an array of values of the same K kind. The first argument specifies the start address of the array and the K second the index into the array (the first element of the array has index  0!). The following equality holds,  2 peekElemOff addr idx = IOExts.fixIO $ \result -> / peek (addr `plusPtr` (idx * sizeOf result)) ENote that this is only a specification, not necessarily the concrete ! implementation of the function. Wraps: Foreign.Storable.\. JWrite a value to a memory area regarded as an array of values of the same & kind. The following equality holds:   pokeElemOff addr idx x = , poke (addr `plusPtr` (idx * sizeOf x)) x Wraps: Foreign.Storable.]. HRead a value from a memory location given by a base address and offset.  The following equality holds:  2 peekByteOff addr off = peek (addr `plusPtr` off) Wraps: Foreign.Storable.^. LWrite a value to a memory location given by a base address and offset. The  following equality holds:  6 pokeByteOff addr off x = poke (addr `plusPtr` off) x Wraps: Foreign.Storable._. -Read a value from the given memory location. ENote that the peek and poke functions might require properly aligned I addresses to function correctly. This is architecture dependent; thus, M portable code should ensure that when peeking or poking values of some type  a, the alignment constraint for a, as given by the function  alignment  is fulfilled. Wraps: Foreign.Storable.`. LWrite the given value to the given memory location. Alignment restrictions  might apply; see . Wraps: Foreign.Storable.a. #Bas van Dijk <v.dijk.bas@gmail.com> val f executes the computation f!, passing as argument a regional ? pointer to a temporarily allocated block of memory into which val has been  marshalled (the combination of  and ). The memory is freed when f' terminates (either normally or via an  exception). &This provides a safer replacement for Foreign.Marshal.Utils.b. KAllocate a block of memory and marshal a value into it (the combination of   and 8). The size of the area allocated is determined by the  X method from the instance of c for the appropriate type. &This provides a safer replacement for Foreign.Marshal.Utils.d. HCopies the given number of bytes from the second area (source) into the + first (destination); the copied areas may not overlap Wraps: Foreign.Marshal.Utils.e.  Destination Source Number of bytes to copy HCopies the given number of bytes from the second area (source) into the ' first (destination); the copied areas may overlap Wraps: Foreign.Marshal.Utils.f.  Destination Source Number of bytes to move #Bas van Dijk <v.dijk.bas@gmail.com>FAllocate storage for the given number of elements of a storable type. Like , but for multiple elements. Like :, but add an extra position to hold a special termination  element. !BTemporarily allocate space for the given number of elements (like ,  but for multiple elements). "Like !:, but add an extra position to hold a special termination  element. g#6Convert an array of given length into a Haskell list. M(This version traverses the array backwards using an accumulating parameter, = which uses constant stack space. The previous version using mapM needed  linear stack space.) Wraps: Foreign.Marshal.Array.h. $IConvert an array terminated by the given end marker into a Haskell list. Wraps: Foreign.Marshal.Array.i. %1Write the list elements consecutive into memory. Wraps: Foreign.Marshal.Array.j. &LWrite the list elements consecutive into memory and terminate them with the  given marker element. Wraps: Foreign.Marshal.Array.k. 'FWrite a list of storable elements into a newly allocated, consecutive  sequence of storable values. Like , but for multiple elements. (FWrite a list of storable elements into a newly allocated, consecutive N sequence of storable values, where the end is fixed by the given end marker. )7Temporarily store a list of storable values in memory. Like , but for multiple elements. *Like )3, but a terminator indicates where the array ends. +Like )<, but the action gets the number of values as an additional  parameter. ,Like +3, but a terminator indicates where the array ends. -JCopy the given number of elements from the second array (source) into the 1 first array (destination); the copied areas may not overlap. Wraps: Foreign.Marshal.Array.l.  Destination Source  Number of elements to copy. .JCopy the given number of elements from the second array (source) into the - first array (destination); the copied areas may overlap. Wraps: Foreign.Marshal.Array.m.  Destination Source  Number of elements to move. /EReturn the number of elements in an array, excluding the terminator. Wraps: Foreign.Marshal.Array.n. 0AAdvance a pointer into an array by the given number of elements. Wraps: Foreign.Marshal.Array.o.  !"#$%&'()*+,-./0 !"#$%&'()*+,-./0 !"#$%&'()*+,-./0#Bas van Dijk <v.dijk.bas@gmail.com>1KHandy type synonym for a regional pointer to an array of C wide characters N which is paired with the length of the array instead of terminated by a NUL. < (Thus allowing NUL characters in the middle of the string) ,This should provide a safer replacement for Foreign.C.String.p. 2KHandy type synonym for a regional pointer to an array of C wide characters  terminated by a NUL. ,This should provide a safer replacement for Foreign.C.String.q. 3LHandy type synonym for a regional pointer to an array of C characters which H is paired with the length of the array instead of terminated by a NUL. < (Thus allowing NUL characters in the middle of the string) ,This should provide a safer replacement for Foreign.C.String.r. 4FHandy type synonym for a regional pointer to an array of C characters  terminated by a NUL. ,This should provide a safer replacement for Foreign.C.String.s. 59Marshal a NUL terminated C string into a Haskell string. Wraps: Foreign.C.String.t 6?Marshal a C string with explicit length into a Haskell string. Wraps: Foreign.C.String.u. 79Marshal a Haskell string into a NUL terminated C string. The Haskell string may not contain any NUL characters Wraps: Foreign.C.String.v. 8DMarshal a Haskell string into a C string (ie, character array) with  explicit length information. Wraps: Foreign.C.String.w. 9HMarshal a Haskell string into a NUL terminated C string using temporary  storage.  the Haskell string may not contain any NUL characters L the memory is freed when the subcomputation terminates (either normally or  via an exception). Wraps: Foreign.C.String.x. :LMarshal a Haskell string into a C string (ie, character array) in temporary , storage, with explicit length information. L the memory is freed when the subcomputation terminates (either normally or  via an exception). Wraps: Foreign.C.String.y. ; Generalizes Foreign.C.String.z to any  {. <9Marshal a NUL terminated C string into a Haskell string. Wraps: Foreign.C.String.|. =?Marshal a C string with explicit length into a Haskell string. Wraps: Foreign.C.String.}. >9Marshal a Haskell string into a NUL terminated C string. The Haskell string may not contain any NUL characters Wraps: Foreign.C.String.~. ?DMarshal a Haskell string into a C string (ie, character array) with  explicit length information. Wraps: Foreign.C.String.. @HMarshal a Haskell string into a NUL terminated C string using temporary  storage.  the Haskell string may not contain any NUL characters L the memory is freed when the subcomputation terminates (either normally or  via an exception). Wraps: Foreign.C.String.. ALMarshal a Haskell string into a C string (ie, character array) in temporary , storage, with explicit length information. L the memory is freed when the subcomputation terminates (either normally or  via an exception). Wraps: Foreign.C.String.. B>Marshal a NUL terminated C wide string into a Haskell string. Wraps: Foreign.C.String.. CDMarshal a C wide string with explicit length into a Haskell string. Wraps: Foreign.C.String.. D>Marshal a Haskell string into a NUL terminated C wide string. The Haskell string may not contain any NUL characters. Wraps: Foreign.C.String.. EIMarshal a Haskell string into a C wide string (ie, wide character array) # with explicit length information. Wraps: Foreign.C.String.. FCMarshal a Haskell string into a NUL terminated C wide string using  temporary storage.  the Haskell string may not contain any NUL characters @ the memory is freed when the subcomputation terminates (either " normally or via an exception). Wraps: Foreign.C.String.. GCMarshal a Haskell string into a NUL terminated C wide string using  temporary storage.  the Haskell string may not contain any NUL characters. @ the memory is freed when the subcomputation terminates (either " normally or via an exception). Wraps: Foreign.C.String.. Lallocate an array to hold the list and pair it with the number of elements. 123456789:;<=>?@ABCDEFG4356789:;<=>?@A21BCDEFG123456789:;<=>?@ABCDEFG   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRS TUVWXVWY T T T TVWZVW[VW\VW]VW^VW_VW` a bc a a a b! b" b# b$ b% b& ' bd ( ) *e f/ f0 f1 f2 f9 f: f; f< g h i j A B C D E F Gklm H I J K L M N O P Q R Snopqrstregional-pointers-0.5Foreign.C.String.RegionForeign.Marshal.Utils.RegionForeign.Ptr.RegionForeign.Ptr.Region.UnsafeForeign.Marshal.Alloc.RegionForeign.Storable.RegionForeign.Marshal.Array.RegionForeign.Ptr.Region.InternalbaseForeign.C.StringcastCharToCCharcastCCharToCharForeign.Marshal.UtilstoBoolfromBool RegionalPtrunsafeRegionalPtrunsafePureRegionalPtr unsafePtr unsafeWrap unsafeWrap2 unsafeWrap3nullPtrmapRegionalPtrcastPtrplusPtralignPtrminusPtralloca allocaBytesmalloc mallocBytes peekElemOff pokeElemOff peekByteOff pokeByteOffpeekpokewithnew copyBytes moveBytes mallocArray mallocArray0 allocaArray allocaArray0 peekArray peekArray0 pokeArray pokeArray0newArray newArray0 withArray withArray0 withArrayLen withArrayLen0 copyArray moveArray lengthArray0 advancePtrRegionalCWStringLenRegionalCWStringRegionalCStringLenRegionalCString peekCStringpeekCStringLen newCString newCStringLen withCStringwithCStringLencharIsRepresentable peekCAStringpeekCAStringLen newCAStringnewCAStringLen withCAStringwithCAStringLen peekCWStringpeekCWStringLen newCWStringnewCWStringLen withCWStringwithCWStringLenGHC.PtrPtr regions-0.8.1#Control.Monad.Trans.Region.Internal RootRegionRegionT liftCatch mapRegionT liftCallCC runRegionTdupDupAncestorRegionForeign.Marshal.AllocForeign.StorablesizeOfStorableunsafeWrap2flpForeign.Marshal.Array CWStringLenCWString CStringLenCStringtransformers-0.2.2.0Control.Monad.IO.ClassMonadIOnULwNUL newArrayLen charsToCCharscharsToCWcharscastCharToCWchar