-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Immutable arrays with plain integer indicies.
--
-- This package is a thin layer over GHC's low-level array primitives. It
-- provides arrays with zero-origin integers for indicies. (These arrays
-- also lack bounds checks.) They come in two flavours: mutable or
-- immutable. (Both are boxed and lazy, however. There are no unboxed
-- arrays here.) The idea is that you can use this package as a starting
-- point for building a more useful array package, without having to
-- learn all GHC's low-level internals for yourself. Changes: * Now
-- builds with GHC 6.12.1
@package AC-VanillaArray
@version 1.1.2
-- | Two flavours of array: mutable and immutable. All are boxed, lazy, and
-- use zero-origin integers as indicies.
module Data.Array.Vanilla.Unsafe
-- | The type of immutable arrays, with elements of type x.
data IArray x
-- | The type of mutable arrays, with elements of type x. These
-- arrays live in the ST monad, but you can use stToIO
-- to convert this to IO if required.
--
-- Two MArrays are equal as per (==) if they are both
-- the exact same array (i.e., the same block of RAM). Two seperate
-- arrays which merely hold the same data are not considered
-- equal. (This fact could change at any second, after all.)
data MArray s x
-- | Create a brand new MArray, of the specified size, with all
-- elements set to the value provided. If the array size is n,
-- valid indicies are from 0 to n-1.
marray_new :: Int -> x -> ST s (MArray s x)
-- | Read from an MArray.
--
-- Unsafe: No bounds checks. Indicies below 0 or above
-- n-1 will likely result in a program crash.
marray_read :: MArray s x -> Int -> ST s x
-- | Write to an MArray, replacing the element at the specified
-- index.
--
-- Unsafe: No bounds checks. Indicies below 0 or above
-- n-1 will likely result in a program crash (if you're lucky),
-- or weird data corruption (if you're unlucky).
marray_write :: MArray s x -> Int -> x -> ST s ()
-- | Create a new IArray which refers to the same memory block as
-- an existing MArray.
--
-- Unsafe: Mutating the MArray will cause the contents of
-- the IArray to mutate also, violating referential
-- transparency. (Avoid this by explicitly copying the data before
-- freezing.)
marray_freeze :: MArray s x -> ST s (IArray x)
-- | Create a new MArray which refers to the same memory block as
-- an existing IArray.
--
-- Unsafe: Mutating the MArray will cause the contents of
-- the IArray to mutate also, violating referential
-- transparency. (Avoid this by explicitly copying the data after thawing
-- and before mutating it.)
iarray_thaw :: IArray x -> ST s (MArray s x)
-- | Read from an IArray. (Since IArrays are immutable,
-- this is a pure operation.)
--
-- Unsafe: No bounds checks. Indicies below 0 or above
-- n-1 will likely result in a program crash.
iarray_read :: IArray x -> Int -> x
instance Eq (MArray s x)