{-# LANGUAGE Unsafe #-}
{-# LANGUAGE NoImplicitPrelude, AutoDeriveTypeable, RoleAnnotations #-}
{-# OPTIONS_GHC -funbox-strict-fields #-}
{-# OPTIONS_HADDOCK hide #-}
module GHC.IOArray (
IOArray(..),
newIOArray, unsafeReadIOArray, unsafeWriteIOArray,
readIOArray, writeIOArray,
boundsIOArray
) where
import GHC.Base
import GHC.IO
import GHC.Arr
import Data.Typeable.Internal
newtype IOArray i e = IOArray (STArray RealWorld i e) deriving( Typeable )
type role IOArray nominal representational
instance Eq (IOArray i e) where
IOArray x == IOArray y = x == y
newIOArray :: Ix i => (i,i) -> e -> IO (IOArray i e)
{-# INLINE newIOArray #-}
newIOArray lu initial = stToIO $ do {marr <- newSTArray lu initial; return (IOArray marr)}
unsafeReadIOArray :: Ix i => IOArray i e -> Int -> IO e
{-# INLINE unsafeReadIOArray #-}
unsafeReadIOArray (IOArray marr) i = stToIO (unsafeReadSTArray marr i)
unsafeWriteIOArray :: Ix i => IOArray i e -> Int -> e -> IO ()
{-# INLINE unsafeWriteIOArray #-}
unsafeWriteIOArray (IOArray marr) i e = stToIO (unsafeWriteSTArray marr i e)
readIOArray :: Ix i => IOArray i e -> i -> IO e
readIOArray (IOArray marr) i = stToIO (readSTArray marr i)
writeIOArray :: Ix i => IOArray i e -> i -> e -> IO ()
writeIOArray (IOArray marr) i e = stToIO (writeSTArray marr i e)
{-# INLINE boundsIOArray #-}
boundsIOArray :: IOArray i e -> (i,i)
boundsIOArray (IOArray marr) = boundsSTArray marr