HORIZON HASKELLDocslts/ghc-10.0.x04404a62026-10-19Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 04404a6 · 2026-10-19

Modulebase-4.23.0.0Haskell2010

Foreign.Marshal.Array

Marshalling support: routines allocating, storing, and retrieving Haskell lists that are represented as arrays in the foreign language

Contents
  1. Marshalling arrays
  2. Allocation
  3. Marshalling
  4. Combined allocation and marshalling
  5. Copying
  6. Finding the length
  7. Indexing
Synopsis
  • Packagebase-4.23.0.0
  • Exports22
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceArray.hs

Marshalling arrays

Allocation

Marshalling

valuepeekArray :: Storable a => Int -> Ptr a -> IO [a]

Convert an array of given length into a Haskell list. The implementation is tail-recursive and so uses constant stack space.

valuepokeArray0 :: Storable a => a -> Ptr a -> [a] -> IO ()

Write the list elements consecutive into memory and terminate them with the given marker element

Combined allocation and marshalling

valuenewArray :: Storable a => [a] -> IO (Ptr a)

Write a list of storable elements into a newly allocated, consecutive sequence of storable values (like new, but for multiple elements).

valuenewArray0 :: Storable a => a -> [a] -> IO (Ptr a)

Write a list of storable elements into a newly allocated, consecutive sequence of storable values, where the end is fixed by the given end marker

Copying

(argument order: destination, source)

valuecopyArray :: Storable a => Ptr a -> Ptr a -> Int -> IO ()

Copy the given number of elements from the second array (source) into the first array (destination); the copied areas may not overlap

valuemoveArray :: Storable a => Ptr a -> Ptr a -> Int -> IO ()

Copy the given number of elements from the second array (source) into the first array (destination); the copied areas may overlap

Finding the length

Indexing