1
module Foreign.Marshal (
2
-- | The module "Foreign.Marshal" re-exports the other modules in the
3
-- @Foreign.Marshal@ hierarchy:
5
module Foreign.Marshal.Alloc,
6
module Foreign.Marshal.Array,
7
module Foreign.Marshal.Error,
8
-- Not in Haskell 2010:
9
-- , module Foreign.Marshal.Pool
10
module Foreign.Marshal.Utils,
11
-- | and provides one function:
15
import "this" Foreign.Marshal.Alloc
16
import "this" Foreign.Marshal.Array
17
import "this" Foreign.Marshal.Error
18
-- Not in Haskell 2010:
19
-- import "this" Foreign.Marshal.Pool
20
import "this" Foreign.Marshal.Utils
22
import "base" System.IO.Unsafe
25
Sometimes an external entity is a pure function, except that it passes
26
arguments and/or results via pointers. The function
27
@unsafeLocalState@ permits the packaging of such entities as pure
30
The only IO operations allowed in the IO action passed to
31
@unsafeLocalState@ are (a) local allocation (@alloca@, @allocaBytes@
32
and derived operations such as @withArray@ and @withCString@), and (b)
33
pointer operations (@Foreign.Storable@ and @Foreign.Ptr@) on the
34
pointers to local storage, and (c) foreign functions whose only
35
observable effect is to read and/or write the locally allocated
36
memory. Passing an IO operation that does not obey these rules
37
results in undefined behaviour.
39
It is expected that this operation will be
40
replaced in a future revision of Haskell.
42
unsafeLocalState :: IO a -> a
43
unsafeLocalState = unsafePerformIO