{-# LANGUAGE Unsafe #-}
{-# LANGUAGE NoImplicitPrelude, DeriveDataTypeable #-}
{-# OPTIONS_GHC -funbox-strict-fields #-}
{-# OPTIONS_HADDOCK hide #-}
------------------------------------------------------------------------------- |-- Module : GHC.IOArray-- Copyright : (c) The University of Glasgow 2008-- License : see libraries/base/LICENSE---- Maintainer : cvs-ghc@haskell.org-- Stability : internal-- Portability : non-portable (GHC Extensions)---- The IOArray type-------------------------------------------------------------------------------
module GHC.IOArray (
IOArray(..),
newIOArray, unsafeReadIOArray, unsafeWriteIOArray,
readIOArray, writeIOArray,
boundsIOArray
) where
import GHC.Base
import GHC.IO
import GHC.Arr
import Data.Typeable.Internal
-- ----------------------------------------------------------------------------- | An 'IOArray' is a mutable, boxed, non-strict array in the 'IO' monad.-- The type arguments are as follows:---- * @i@: the index type of the array (should be an instance of 'Ix')---- * @e@: the element type of the array.----
newtype IOArrayie = IOArray (STArrayRealWorldie) deriving( Typeable )-- explicit instance because Haddock can't figure out a derived one
instance Eq (IOArrayie) where
IOArrayx==IOArrayy = x==y-- |Build a new 'IOArray'newIOArray :: Ix i => (i,i) -> e -> IO (IOArrayie)
{-# INLINE newIOArray #-}newIOArrayluinitial = stToIO$ do {marr <- newSTArrayluinitial; return (IOArraymarr)}
-- | Read a value from an 'IOArray'unsafeReadIOArray :: Ix i =>IOArrayie -> Int -> IOe{-# INLINE unsafeReadIOArray #-}unsafeReadIOArray (IOArraymarr) i = stToIO (unsafeReadSTArraymarri)
-- | Write a new value into an 'IOArray'unsafeWriteIOArray :: Ix i =>IOArrayie -> Int -> e -> IO(){-# INLINE unsafeWriteIOArray #-}unsafeWriteIOArray (IOArraymarr) ie = stToIO (unsafeWriteSTArraymarrie)
-- | Read a value from an 'IOArray'readIOArray :: Ix i =>IOArrayie -> i -> IOereadIOArray (IOArraymarr) i = stToIO (readSTArraymarri)
-- | Write a new value into an 'IOArray'writeIOArray :: Ix i =>IOArrayie -> i -> e -> IO()writeIOArray (IOArraymarr) ie = stToIO (writeSTArraymarrie)
{-# INLINE boundsIOArray #-}boundsIOArray :: IOArrayie -> (i,i)
boundsIOArray (IOArraymarr) = boundsSTArraymarr