{-# LANGUAGE
    FlexibleInstances
  , MultiParamTypeClasses
  , RoleAnnotations
 #-}

{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Data.Array.IO.Internal
-- Copyright   :  (c) The University of Glasgow 2001-2012
-- License     :  BSD-style (see the file libraries/base/LICENSE)
--
-- Maintainer  :  libraries@haskell.org
-- Stability   :  experimental
-- Portability :  non-portable (uses Data.Array.Base)
--
-- Mutable boxed and unboxed arrays in the IO monad.
--
-----------------------------------------------------------------------------

module Data.Array.IO.Internals (
    IOArray(..),         -- instance of: Eq, Typeable
    IOUArray(..),        -- instance of: Eq, Typeable
    castIOUArray,        -- :: IOUArray ix a -> IO (IOUArray ix b)
    unsafeThawIOUArray,
    unsafeFreezeIOUArray
  ) where

import Data.Int
import Data.Word

import Control.Monad.ST         ( RealWorld, stToIO )
import Foreign.Ptr              ( Ptr, FunPtr )
import Foreign.StablePtr        ( StablePtr )

import Data.Array.Base

import GHC.IOArray (IOArray(..))

-----------------------------------------------------------------------------
-- Flat unboxed mutable arrays (IO monad)

-- | Mutable, unboxed, strict arrays 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.  Only certain element types
--    are supported: see "Data.Array.MArray" for a list of instances.
--
newtype IOUArray i e = IOUArray (STUArray RealWorld i e)
-- Both parameters have class-based invariants. See also #9220.
type role IOUArray nominal nominal

instance Eq (IOUArray i e) where
    IOUArray STUArray RealWorld i e
s1 == :: IOUArray i e -> IOUArray i e -> Bool
== IOUArray STUArray RealWorld i e
s2  =  STUArray RealWorld i e
s1 forall a. Eq a => a -> a -> Bool
== STUArray RealWorld i e
s2

instance MArray IOUArray Bool IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i Bool -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i Bool
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i Bool
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i Bool -> IO Int
getNumElements (IOUArray STUArray RealWorld i Bool
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i Bool
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Bool -> IO (IOUArray i Bool)
newArray (i, i)
lu Bool
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Bool
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Bool
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Bool
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Bool)
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Bool
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Bool
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Bool)
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i Bool -> Int -> IO Bool
unsafeRead (IOUArray STUArray RealWorld i Bool
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i Bool
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i Bool -> Int -> Bool -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i Bool
marr) Int
i Bool
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i Bool
marr Int
i Bool
e)

instance MArray IOUArray Char IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i Char -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i Char
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i Char
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i Char -> IO Int
getNumElements (IOUArray STUArray RealWorld i Char
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i Char
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Char -> IO (IOUArray i Char)
newArray (i, i)
lu Char
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Char
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Char
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Char
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Char)
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Char
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Char
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Char)
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i Char -> Int -> IO Char
unsafeRead (IOUArray STUArray RealWorld i Char
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i Char
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i Char -> Int -> Char -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i Char
marr) Int
i Char
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i Char
marr Int
i Char
e)

instance MArray IOUArray Int IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i Int -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i Int
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i Int
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i Int -> IO Int
getNumElements (IOUArray STUArray RealWorld i Int
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i Int
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Int -> IO (IOUArray i Int)
newArray (i, i)
lu Int
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Int
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Int
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Int
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Int)
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Int
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Int
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Int)
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i Int -> Int -> IO Int
unsafeRead (IOUArray STUArray RealWorld i Int
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i Int
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i Int -> Int -> Int -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i Int
marr) Int
i Int
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i Int
marr Int
i Int
e)

instance MArray IOUArray Word IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i Word -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i Word
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i Word
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i Word -> IO Int
getNumElements (IOUArray STUArray RealWorld i Word
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i Word
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Word -> IO (IOUArray i Word)
newArray (i, i)
lu Word
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Word
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Word
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Word
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Word)
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Word
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Word
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Word)
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i Word -> Int -> IO Word
unsafeRead (IOUArray STUArray RealWorld i Word
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i Word
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i Word -> Int -> Word -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i Word
marr) Int
i Word
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i Word
marr Int
i Word
e)

instance MArray IOUArray (Ptr a) IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i (Ptr a) -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i (Ptr a)
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i (Ptr a)
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i (Ptr a) -> IO Int
getNumElements (IOUArray STUArray RealWorld i (Ptr a)
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i (Ptr a)
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Ptr a -> IO (IOUArray i (Ptr a))
newArray (i, i)
lu Ptr a
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i (Ptr a)
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Ptr a
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i (Ptr a)
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i (Ptr a))
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i (Ptr a)
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i (Ptr a)
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i (Ptr a))
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i (Ptr a) -> Int -> IO (Ptr a)
unsafeRead (IOUArray STUArray RealWorld i (Ptr a)
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i (Ptr a)
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i (Ptr a) -> Int -> Ptr a -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i (Ptr a)
marr) Int
i Ptr a
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i (Ptr a)
marr Int
i Ptr a
e)

instance MArray IOUArray (FunPtr a) IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i (FunPtr a) -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i (FunPtr a)
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i (FunPtr a)
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i (FunPtr a) -> IO Int
getNumElements (IOUArray STUArray RealWorld i (FunPtr a)
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i (FunPtr a)
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> FunPtr a -> IO (IOUArray i (FunPtr a))
newArray (i, i)
lu FunPtr a
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i (FunPtr a)
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu FunPtr a
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i (FunPtr a)
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i (FunPtr a))
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i (FunPtr a)
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i (FunPtr a)
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i (FunPtr a))
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i (FunPtr a) -> Int -> IO (FunPtr a)
unsafeRead (IOUArray STUArray RealWorld i (FunPtr a)
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i (FunPtr a)
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i (FunPtr a) -> Int -> FunPtr a -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i (FunPtr a)
marr) Int
i FunPtr a
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i (FunPtr a)
marr Int
i FunPtr a
e)

instance MArray IOUArray Float IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i Float -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i Float
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i Float
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i Float -> IO Int
getNumElements (IOUArray STUArray RealWorld i Float
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i Float
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Float -> IO (IOUArray i Float)
newArray (i, i)
lu Float
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Float
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Float
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Float
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Float)
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Float
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Float
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Float)
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i Float -> Int -> IO Float
unsafeRead (IOUArray STUArray RealWorld i Float
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i Float
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i Float -> Int -> Float -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i Float
marr) Int
i Float
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i Float
marr Int
i Float
e)

instance MArray IOUArray Double IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i Double -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i Double
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i Double
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i Double -> IO Int
getNumElements (IOUArray STUArray RealWorld i Double
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i Double
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Double -> IO (IOUArray i Double)
newArray (i, i)
lu Double
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Double
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Double
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Double
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Double)
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Double
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Double
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Double)
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i Double -> Int -> IO Double
unsafeRead (IOUArray STUArray RealWorld i Double
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i Double
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i Double -> Int -> Double -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i Double
marr) Int
i Double
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i Double
marr Int
i Double
e)

instance MArray IOUArray (StablePtr a) IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i (StablePtr a) -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i (StablePtr a)
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i (StablePtr a)
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i (StablePtr a) -> IO Int
getNumElements (IOUArray STUArray RealWorld i (StablePtr a)
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i (StablePtr a)
arr
    {-# INLINE newArray #-}
    newArray :: forall i.
Ix i =>
(i, i) -> StablePtr a -> IO (IOUArray i (StablePtr a))
newArray (i, i)
lu StablePtr a
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i (StablePtr a)
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu StablePtr a
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i (StablePtr a)
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i (StablePtr a))
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i (StablePtr a)
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i (StablePtr a)
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i (StablePtr a))
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i.
Ix i =>
IOUArray i (StablePtr a) -> Int -> IO (StablePtr a)
unsafeRead (IOUArray STUArray RealWorld i (StablePtr a)
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i (StablePtr a)
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i.
Ix i =>
IOUArray i (StablePtr a) -> Int -> StablePtr a -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i (StablePtr a)
marr) Int
i StablePtr a
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i (StablePtr a)
marr Int
i StablePtr a
e)

instance MArray IOUArray Int8 IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i Int8 -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i Int8
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i Int8
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i Int8 -> IO Int
getNumElements (IOUArray STUArray RealWorld i Int8
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i Int8
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Int8 -> IO (IOUArray i Int8)
newArray (i, i)
lu Int8
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Int8
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Int8
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Int8
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Int8)
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Int8
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Int8
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Int8)
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i Int8 -> Int -> IO Int8
unsafeRead (IOUArray STUArray RealWorld i Int8
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i Int8
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i Int8 -> Int -> Int8 -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i Int8
marr) Int
i Int8
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i Int8
marr Int
i Int8
e)

instance MArray IOUArray Int16 IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i Int16 -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i Int16
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i Int16
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i Int16 -> IO Int
getNumElements (IOUArray STUArray RealWorld i Int16
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i Int16
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Int16 -> IO (IOUArray i Int16)
newArray (i, i)
lu Int16
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Int16
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Int16
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Int16
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Int16)
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Int16
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Int16
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Int16)
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i Int16 -> Int -> IO Int16
unsafeRead (IOUArray STUArray RealWorld i Int16
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i Int16
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i Int16 -> Int -> Int16 -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i Int16
marr) Int
i Int16
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i Int16
marr Int
i Int16
e)

instance MArray IOUArray Int32 IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i Int32 -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i Int32
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i Int32
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i Int32 -> IO Int
getNumElements (IOUArray STUArray RealWorld i Int32
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i Int32
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Int32 -> IO (IOUArray i Int32)
newArray (i, i)
lu Int32
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Int32
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Int32
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Int32
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Int32)
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Int32
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Int32
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Int32)
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i Int32 -> Int -> IO Int32
unsafeRead (IOUArray STUArray RealWorld i Int32
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i Int32
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i Int32 -> Int -> Int32 -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i Int32
marr) Int
i Int32
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i Int32
marr Int
i Int32
e)

instance MArray IOUArray Int64 IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i Int64 -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i Int64
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i Int64
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i Int64 -> IO Int
getNumElements (IOUArray STUArray RealWorld i Int64
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i Int64
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Int64 -> IO (IOUArray i Int64)
newArray (i, i)
lu Int64
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Int64
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Int64
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Int64
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Int64)
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Int64
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Int64
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Int64)
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i Int64 -> Int -> IO Int64
unsafeRead (IOUArray STUArray RealWorld i Int64
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i Int64
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i Int64 -> Int -> Int64 -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i Int64
marr) Int
i Int64
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i Int64
marr Int
i Int64
e)

instance MArray IOUArray Word8 IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i Word8 -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i Word8
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i Word8
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i Word8 -> IO Int
getNumElements (IOUArray STUArray RealWorld i Word8
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i Word8
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Word8 -> IO (IOUArray i Word8)
newArray (i, i)
lu Word8
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Word8
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Word8
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Word8
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Word8)
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Word8
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Word8
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Word8)
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i Word8 -> Int -> IO Word8
unsafeRead (IOUArray STUArray RealWorld i Word8
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i Word8
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i Word8 -> Int -> Word8 -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i Word8
marr) Int
i Word8
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i Word8
marr Int
i Word8
e)

instance MArray IOUArray Word16 IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i Word16 -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i Word16
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i Word16
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i Word16 -> IO Int
getNumElements (IOUArray STUArray RealWorld i Word16
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i Word16
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Word16 -> IO (IOUArray i Word16)
newArray (i, i)
lu Word16
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Word16
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Word16
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Word16
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Word16)
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Word16
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Word16
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Word16)
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i Word16 -> Int -> IO Word16
unsafeRead (IOUArray STUArray RealWorld i Word16
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i Word16
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i Word16 -> Int -> Word16 -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i Word16
marr) Int
i Word16
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i Word16
marr Int
i Word16
e)

instance MArray IOUArray Word32 IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i Word32 -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i Word32
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i Word32
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i Word32 -> IO Int
getNumElements (IOUArray STUArray RealWorld i Word32
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i Word32
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Word32 -> IO (IOUArray i Word32)
newArray (i, i)
lu Word32
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Word32
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Word32
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Word32
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Word32)
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Word32
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Word32
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Word32)
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i Word32 -> Int -> IO Word32
unsafeRead (IOUArray STUArray RealWorld i Word32
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i Word32
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i Word32 -> Int -> Word32 -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i Word32
marr) Int
i Word32
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i Word32
marr Int
i Word32
e)

instance MArray IOUArray Word64 IO where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => IOUArray i Word64 -> IO (i, i)
getBounds (IOUArray STUArray RealWorld i Word64
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray RealWorld i Word64
arr
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => IOUArray i Word64 -> IO Int
getNumElements (IOUArray STUArray RealWorld i Word64
arr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray RealWorld i Word64
arr
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Word64 -> IO (IOUArray i Word64)
newArray (i, i)
lu Word64
initialValue = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Word64
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
lu Word64
initialValue; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Word64
marr)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Word64)
unsafeNewArray_ (i, i)
lu = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
        STUArray RealWorld i Word64
marr <- forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
lu; forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld i Word64
marr)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> IO (IOUArray i Word64)
newArray_ = forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => IOUArray i Word64 -> Int -> IO Word64
unsafeRead (IOUArray STUArray RealWorld i Word64
marr) Int
i = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray RealWorld i Word64
marr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => IOUArray i Word64 -> Int -> Word64 -> IO ()
unsafeWrite (IOUArray STUArray RealWorld i Word64
marr) Int
i Word64
e = forall a. ST RealWorld a -> IO a
stToIO (forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray RealWorld i Word64
marr Int
i Word64
e)

-- | Casts an 'IOUArray' with one element type into one with a
-- different element type.  All the elements of the resulting array
-- are undefined (unless you know what you\'re doing...).
castIOUArray :: IOUArray ix a -> IO (IOUArray ix b)
castIOUArray :: forall ix a b. IOUArray ix a -> IO (IOUArray ix b)
castIOUArray (IOUArray STUArray RealWorld ix a
marr) = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
    STUArray RealWorld ix b
marr' <- forall s ix a b. STUArray s ix a -> ST s (STUArray s ix b)
castSTUArray STUArray RealWorld ix a
marr
    forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld ix b
marr')

{-# INLINE unsafeThawIOUArray #-}
unsafeThawIOUArray :: UArray ix e -> IO (IOUArray ix e)
unsafeThawIOUArray :: forall ix e. UArray ix e -> IO (IOUArray ix e)
unsafeThawIOUArray UArray ix e
arr = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
    STUArray RealWorld ix e
marr <- forall i e s. UArray i e -> ST s (STUArray s i e)
unsafeThawSTUArray UArray ix e
arr
    forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld ix e
marr)

{-# RULES
"unsafeThaw/IOUArray" unsafeThaw = unsafeThawIOUArray
    #-}

thawIOUArray :: UArray ix e -> IO (IOUArray ix e)
thawIOUArray :: forall ix e. UArray ix e -> IO (IOUArray ix e)
thawIOUArray UArray ix e
arr = forall a. ST RealWorld a -> IO a
stToIO forall a b. (a -> b) -> a -> b
$ do
    STUArray RealWorld ix e
marr <- forall i e s. UArray i e -> ST s (STUArray s i e)
thawSTUArray UArray ix e
arr
    forall (m :: * -> *) a. Monad m => a -> m a
return (forall i e. STUArray RealWorld i e -> IOUArray i e
IOUArray STUArray RealWorld ix e
marr)

{-# RULES
"thaw/IOUArray" thaw = thawIOUArray
    #-}

{-# INLINE unsafeFreezeIOUArray #-}
unsafeFreezeIOUArray :: IOUArray ix e -> IO (UArray ix e)
unsafeFreezeIOUArray :: forall ix e. IOUArray ix e -> IO (UArray ix e)
unsafeFreezeIOUArray (IOUArray STUArray RealWorld ix e
marr) = forall a. ST RealWorld a -> IO a
stToIO (forall s i e. STUArray s i e -> ST s (UArray i e)
unsafeFreezeSTUArray STUArray RealWorld ix e
marr)

{-# RULES
"unsafeFreeze/IOUArray" unsafeFreeze = unsafeFreezeIOUArray
    #-}

freezeIOUArray :: IOUArray ix e -> IO (UArray ix e)
freezeIOUArray :: forall ix e. IOUArray ix e -> IO (UArray ix e)
freezeIOUArray (IOUArray STUArray RealWorld ix e
marr) = forall a. ST RealWorld a -> IO a
stToIO (forall s i e. STUArray s i e -> ST s (UArray i e)
freezeSTUArray STUArray RealWorld ix e
marr)

{-# RULES
"freeze/IOUArray" freeze = freezeIOUArray
    #-}