{-# LANGUAGE MagicHash, UnboxedTuples, Rank2Types, FlexibleInstances,
    MultiParamTypeClasses, UndecidableInstances, RecursiveDo #-}
{- |
   Module      :  Control.Monad.ST.Trans
   Copyright   :  Josef Svenningsson 2008-2010
                  (c) The University of Glasgow, 1994-2000
   License     :  BSD

   Maintainer  :  josef.svenningsson@gmail.com, Andreas Abel
   Stability   :  stable
   Portability :  non-portable (GHC Extensions)

   This module provides the implementation of the 'STT' type for those
   occasions where it is needed in order to implement new liftings through
   operations in other monads.

   Warning! This monad transformer should not be used with monads that
   can contain multiple answers, like the list monad. The reason is that
   the will be duplicated across the different answers and this cause
   Bad Things to happen (such as loss of referential transparency). Safe
   monads include the monads State, Reader, Writer, Maybe and
   combinations of their corresponding monad transformers.
-}
module Control.Monad.ST.Trans.Internal where

import GHC.Base
import GHC.ST hiding (liftST)

import qualified Control.Monad.Fail as MF
import Control.Monad.Fix
import Control.Monad.Trans
import Control.Monad.Error.Class
import Control.Monad.Reader.Class
import Control.Monad.State.Class
import Control.Monad.Writer.Class

#if __GLASGOW_HASKELL__ <= 708
import Control.Applicative
#endif

import Data.Array.ST
import Data.Array.Base
import GHC.Int    (Int8,  Int16,  Int32,  Int64)
import GHC.Word   (Word8, Word16, Word32, Word64)
import GHC.Ptr    (Ptr, FunPtr)
import GHC.Stable (StablePtr)

-- | 'STT' is the monad transformer providing polymorphic updateable references
newtype STT s m a = STT (State# s -> m (STTRet s a))

unSTT :: STT s m a -> (State# s -> m (STTRet s a))
unSTT :: forall s (m :: * -> *) a. STT s m a -> State# s -> m (STTRet s a)
unSTT (STT State# s -> m (STTRet s a)
f) = State# s -> m (STTRet s a)
f

-- | 'STTRet' is needed to encapsulate the unboxed state token that GHC passes
--   around. This type is essentially a pair, but an ordinary pair is not
--   not allowed to contain unboxed types.
data STTRet s a = STTRet (State# s) a

-- | Lifting the `ST` monad into `STT`. The library uses this function
--   extensively to be able to reuse functions from `ST`.
liftST :: Applicative m => ST s a -> STT s m a
liftST :: forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (ST STRep s a
f) = (State# s -> m (STTRet s a)) -> STT s m a
forall s (m :: * -> *) a. (State# s -> m (STTRet s a)) -> STT s m a
STT (\State# s
s -> let !(# State# s
s', a
a #) = STRep s a
f State# s
s in STTRet s a -> m (STTRet s a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (State# s -> a -> STTRet s a
forall s a. State# s -> a -> STTRet s a
STTRet State# s
s' a
a))
{-# INLINE liftST #-}

-- All instances have to go in this module because otherwise they
-- would be orphan instances.

instance (Monad m, Functor m) => Monad (STT s m) where
  return :: forall a. a -> STT s m a
return = a -> STT s m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
  STT State# s -> m (STTRet s a)
m >>= :: forall a b. STT s m a -> (a -> STT s m b) -> STT s m b
>>= a -> STT s m b
k = (State# s -> m (STTRet s b)) -> STT s m b
forall s (m :: * -> *) a. (State# s -> m (STTRet s a)) -> STT s m a
STT ((State# s -> m (STTRet s b)) -> STT s m b)
-> (State# s -> m (STTRet s b)) -> STT s m b
forall a b. (a -> b) -> a -> b
$ \State# s
st ->
    do STTRet s a
ret <- State# s -> m (STTRet s a)
m State# s
st
       case STTRet s a
ret of
         STTRet State# s
new_st a
a ->
             STT s m b -> State# s -> m (STTRet s b)
forall s (m :: * -> *) a. STT s m a -> State# s -> m (STTRet s a)
unSTT (a -> STT s m b
k a
a) State# s
new_st

instance (MF.MonadFail m, Functor m) => MF.MonadFail (STT s m) where
  fail :: forall a. String -> STT s m a
fail String
msg = m a -> STT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (String -> m a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
msg)

instance MonadTrans (STT s) where
  lift :: forall (m :: * -> *) a. Monad m => m a -> STT s m a
lift m a
m = (State# s -> m (STTRet s a)) -> STT s m a
forall s (m :: * -> *) a. (State# s -> m (STTRet s a)) -> STT s m a
STT ((State# s -> m (STTRet s a)) -> STT s m a)
-> (State# s -> m (STTRet s a)) -> STT s m a
forall a b. (a -> b) -> a -> b
$ \State# s
st ->
   do a
a <- m a
m
      STTRet s a -> m (STTRet s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (State# s -> a -> STTRet s a
forall s a. State# s -> a -> STTRet s a
STTRet State# s
st a
a)

liftSTT :: STT s m a -> State# s -> m (STTRet s a)
liftSTT :: forall s (m :: * -> *) a. STT s m a -> State# s -> m (STTRet s a)
liftSTT (STT State# s -> m (STTRet s a)
m) State# s
s = State# s -> m (STTRet s a)
m State# s
s

instance (MonadFix m, Functor m) => MonadFix (STT s m) where
  mfix :: forall a. (a -> STT s m a) -> STT s m a
mfix a -> STT s m a
k = (State# s -> m (STTRet s a)) -> STT s m a
forall s (m :: * -> *) a. (State# s -> m (STTRet s a)) -> STT s m a
STT ((State# s -> m (STTRet s a)) -> STT s m a)
-> (State# s -> m (STTRet s a)) -> STT s m a
forall a b. (a -> b) -> a -> b
$ \ State# s
s -> mdo
    ans :: STTRet s a
ans@(STTRet State# s
_ a
r) <- STT s m a -> State# s -> m (STTRet s a)
forall s (m :: * -> *) a. STT s m a -> State# s -> m (STTRet s a)
liftSTT (a -> STT s m a
k a
r) State# s
s
    STTRet s a -> m (STTRet s a)
forall (m :: * -> *) a. Monad m => a -> m a
return STTRet s a
ans

instance Functor (STTRet s) where
  fmap :: forall a b. (a -> b) -> STTRet s a -> STTRet s b
fmap a -> b
f (STTRet State# s
s a
a) = State# s -> b -> STTRet s b
forall s a. State# s -> a -> STTRet s a
STTRet State# s
s (a -> b
f a
a)

instance Functor m => Functor (STT s m) where
  fmap :: forall a b. (a -> b) -> STT s m a -> STT s m b
fmap a -> b
f (STT State# s -> m (STTRet s a)
g) = (State# s -> m (STTRet s b)) -> STT s m b
forall s (m :: * -> *) a. (State# s -> m (STTRet s a)) -> STT s m a
STT ((State# s -> m (STTRet s b)) -> STT s m b)
-> (State# s -> m (STTRet s b)) -> STT s m b
forall a b. (a -> b) -> a -> b
$ \State# s
s# -> ((STTRet s a -> STTRet s b) -> m (STTRet s a) -> m (STTRet s b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((STTRet s a -> STTRet s b) -> m (STTRet s a) -> m (STTRet s b))
-> ((a -> b) -> STTRet s a -> STTRet s b)
-> (a -> b)
-> m (STTRet s a)
-> m (STTRet s b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> b) -> STTRet s a -> STTRet s b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap) a -> b
f (State# s -> m (STTRet s a)
g State# s
s#)

instance (Monad m, Functor m) => Applicative (STT s m) where
  pure :: forall a. a -> STT s m a
pure a
a = (State# s -> m (STTRet s a)) -> STT s m a
forall s (m :: * -> *) a. (State# s -> m (STTRet s a)) -> STT s m a
STT ((State# s -> m (STTRet s a)) -> STT s m a)
-> (State# s -> m (STTRet s a)) -> STT s m a
forall a b. (a -> b) -> a -> b
$ \State# s
s# -> STTRet s a -> m (STTRet s a)
forall (m :: * -> *) a. Monad m => a -> m a
return (State# s -> a -> STTRet s a
forall s a. State# s -> a -> STTRet s a
STTRet State# s
s# a
a)
  (STT State# s -> m (STTRet s (a -> b))
m) <*> :: forall a b. STT s m (a -> b) -> STT s m a -> STT s m b
<*> (STT State# s -> m (STTRet s a)
n) = (State# s -> m (STTRet s b)) -> STT s m b
forall s (m :: * -> *) a. (State# s -> m (STTRet s a)) -> STT s m a
STT ((State# s -> m (STTRet s b)) -> STT s m b)
-> (State# s -> m (STTRet s b)) -> STT s m b
forall a b. (a -> b) -> a -> b
$ \State# s
s1 ->
                        do (STTRet State# s
s2 a -> b
f) <- State# s -> m (STTRet s (a -> b))
m State# s
s1
                           (STTRet State# s
s3 a
x) <- State# s -> m (STTRet s a)
n State# s
s2
                           STTRet s b -> m (STTRet s b)
forall (m :: * -> *) a. Monad m => a -> m a
return (State# s -> b -> STTRet s b
forall s a. State# s -> a -> STTRet s a
STTRet State# s
s3 (a -> b
f a
x))

-- Instances of other monad classes

instance (MonadError e m, Functor m) => MonadError e (STT s m) where
  throwError :: forall a. e -> STT s m a
throwError e
e = m a -> STT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (e -> m a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError e
e)
  catchError :: forall a. STT s m a -> (e -> STT s m a) -> STT s m a
catchError (STT State# s -> m (STTRet s a)
m) e -> STT s m a
f = (State# s -> m (STTRet s a)) -> STT s m a
forall s (m :: * -> *) a. (State# s -> m (STTRet s a)) -> STT s m a
STT ((State# s -> m (STTRet s a)) -> STT s m a)
-> (State# s -> m (STTRet s a)) -> STT s m a
forall a b. (a -> b) -> a -> b
$ \State# s
st -> m (STTRet s a) -> (e -> m (STTRet s a)) -> m (STTRet s a)
forall e (m :: * -> *) a.
MonadError e m =>
m a -> (e -> m a) -> m a
catchError (State# s -> m (STTRet s a)
m State# s
st)
                         (\e
e -> STT s m a -> State# s -> m (STTRet s a)
forall s (m :: * -> *) a. STT s m a -> State# s -> m (STTRet s a)
unSTT (e -> STT s m a
f e
e) State# s
st)

instance (MonadReader r m, Functor m) => MonadReader r (STT s m) where
  ask :: STT s m r
ask = m r -> STT s m r
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m r
forall r (m :: * -> *). MonadReader r m => m r
ask
  local :: forall a. (r -> r) -> STT s m a -> STT s m a
local r -> r
f (STT State# s -> m (STTRet s a)
m) = (State# s -> m (STTRet s a)) -> STT s m a
forall s (m :: * -> *) a. (State# s -> m (STTRet s a)) -> STT s m a
STT ((State# s -> m (STTRet s a)) -> STT s m a)
-> (State# s -> m (STTRet s a)) -> STT s m a
forall a b. (a -> b) -> a -> b
$ \State# s
st -> (r -> r) -> m (STTRet s a) -> m (STTRet s a)
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local r -> r
f (State# s -> m (STTRet s a)
m State# s
st)

instance (MonadState s m, Functor m) => MonadState s (STT s1 m) where
  get :: STT s1 m s
get = m s -> STT s1 m s
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m s
forall s (m :: * -> *). MonadState s m => m s
get
  put :: s -> STT s1 m ()
put s
s = m () -> STT s1 m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (s -> m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put s
s)

instance (MonadWriter w m, Functor m) => MonadWriter w (STT s m) where
  tell :: w -> STT s m ()
tell w
w = m () -> STT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (w -> m ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell w
w)
  listen :: forall a. STT s m a -> STT s m (a, w)
listen (STT State# s -> m (STTRet s a)
m)= (State# s -> m (STTRet s (a, w))) -> STT s m (a, w)
forall s (m :: * -> *) a. (State# s -> m (STTRet s a)) -> STT s m a
STT ((State# s -> m (STTRet s (a, w))) -> STT s m (a, w))
-> (State# s -> m (STTRet s (a, w))) -> STT s m (a, w)
forall a b. (a -> b) -> a -> b
$ \State# s
st1 -> do (STTRet State# s
st2 a
a, w
w) <- m (STTRet s a) -> m (STTRet s a, w)
forall w (m :: * -> *) a. MonadWriter w m => m a -> m (a, w)
listen (State# s -> m (STTRet s a)
m State# s
st1)
                                   STTRet s (a, w) -> m (STTRet s (a, w))
forall (m :: * -> *) a. Monad m => a -> m a
return (State# s -> (a, w) -> STTRet s (a, w)
forall s a. State# s -> a -> STTRet s a
STTRet State# s
st2 (a
a,w
w))
  pass :: forall a. STT s m (a, w -> w) -> STT s m a
pass (STT State# s -> m (STTRet s (a, w -> w))
m) = (State# s -> m (STTRet s a)) -> STT s m a
forall s (m :: * -> *) a. (State# s -> m (STTRet s a)) -> STT s m a
STT ((State# s -> m (STTRet s a)) -> STT s m a)
-> (State# s -> m (STTRet s a)) -> STT s m a
forall a b. (a -> b) -> a -> b
$ \State# s
st1 -> m (STTRet s a, w -> w) -> m (STTRet s a)
forall w (m :: * -> *) a. MonadWriter w m => m (a, w -> w) -> m a
pass (do (STTRet State# s
st2 (a
a,w -> w
f)) <- State# s -> m (STTRet s (a, w -> w))
m State# s
st1
                                        (STTRet s a, w -> w) -> m (STTRet s a, w -> w)
forall (m :: * -> *) a. Monad m => a -> m a
return (State# s -> a -> STTRet s a
forall s a. State# s -> a -> STTRet s a
STTRet State# s
st2 a
a, w -> w
f))

-- MArray instances

instance (Applicative m, Monad m) => MArray (STArray s) e (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STArray s i e -> STT s m (i, i)
getBounds STArray s i e
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STArray s i e -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STArray s i e
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STArray s i e -> STT s m Int
getNumElements STArray s i e
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STArray s i e -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STArray s i e
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> e -> STT s m (STArray s i e)
newArray (i, i)
bnds e
e = ST s (STArray s i e) -> STT s m (STArray s i e)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> e -> ST s (STArray s i e)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds e
e)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STArray s i e -> Int -> STT s m e
unsafeRead STArray s i e
arr Int
i = ST s e -> STT s m e
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STArray s i e -> Int -> ST s e
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STArray s i e
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => STArray s i e -> Int -> e -> STT s m ()
unsafeWrite STArray s i e
arr Int
i e
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STArray s i e -> Int -> e -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STArray s i e
arr Int
i e
e)

instance (Applicative m, Monad m) => MArray (STUArray s) Bool (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i Bool -> STT s m (i, i)
getBounds STUArray s i Bool
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Bool -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i Bool
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i Bool -> STT s m Int
getNumElements STUArray s i Bool
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Bool -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i Bool
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Bool -> STT s m (STUArray s i Bool)
newArray (i, i)
bnds Bool
e = ST s (STUArray s i Bool) -> STT s m (STUArray s i Bool)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Bool -> ST s (STUArray s i Bool)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Bool
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Bool)
newArray_ (i, i)
arrBounds = ST s (STUArray s i Bool) -> STT s m (STUArray s i Bool)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Bool)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Bool)
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i Bool) -> STT s m (STUArray s i Bool)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Bool)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i Bool -> Int -> STT s m Bool
unsafeRead STUArray s i Bool
arr Int
i = ST s Bool -> STT s m Bool
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Bool -> Int -> ST s Bool
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i Bool
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => STUArray s i Bool -> Int -> Bool -> STT s m ()
unsafeWrite STUArray s i Bool
arr Int
i Bool
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Bool -> Int -> Bool -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i Bool
arr Int
i Bool
e)

instance (Applicative m, Monad m) => MArray (STUArray s) Char (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i Char -> STT s m (i, i)
getBounds STUArray s i Char
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Char -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i Char
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i Char -> STT s m Int
getNumElements STUArray s i Char
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Char -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i Char
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Char -> STT s m (STUArray s i Char)
newArray (i, i)
bnds Char
e = ST s (STUArray s i Char) -> STT s m (STUArray s i Char)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Char -> ST s (STUArray s i Char)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Char
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Char)
newArray_ (i, i)
arrBounds = ST s (STUArray s i Char) -> STT s m (STUArray s i Char)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Char)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Char)
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i Char) -> STT s m (STUArray s i Char)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Char)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i Char -> Int -> STT s m Char
unsafeRead STUArray s i Char
arr Int
i = ST s Char -> STT s m Char
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Char -> Int -> ST s Char
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i Char
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => STUArray s i Char -> Int -> Char -> STT s m ()
unsafeWrite STUArray s i Char
arr Int
i Char
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Char -> Int -> Char -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i Char
arr Int
i Char
e)

instance (Applicative m, Monad m) => MArray (STUArray s) Int (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i Int -> STT s m (i, i)
getBounds STUArray s i Int
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i Int
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i Int -> STT s m Int
getNumElements STUArray s i Int
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i Int
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Int -> STT s m (STUArray s i Int)
newArray (i, i)
bnds Int
e = ST s (STUArray s i Int) -> STT s m (STUArray s i Int)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Int -> ST s (STUArray s i Int)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Int
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Int)
newArray_ (i, i)
arrBounds = ST s (STUArray s i Int) -> STT s m (STUArray s i Int)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Int)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Int)
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i Int) -> STT s m (STUArray s i Int)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Int)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i Int -> Int -> STT s m Int
unsafeRead STUArray s i Int
arr Int
i = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int -> Int -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i Int
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => STUArray s i Int -> Int -> Int -> STT s m ()
unsafeWrite STUArray s i Int
arr Int
i Int
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int -> Int -> Int -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i Int
arr Int
i Int
e)

instance (Applicative m, Monad m) => MArray (STUArray s) Word (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i Word -> STT s m (i, i)
getBounds STUArray s i Word
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i Word
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i Word -> STT s m Int
getNumElements STUArray s i Word
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i Word
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Word -> STT s m (STUArray s i Word)
newArray (i, i)
bnds Word
e = ST s (STUArray s i Word) -> STT s m (STUArray s i Word)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Word -> ST s (STUArray s i Word)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Word
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Word)
newArray_ (i, i)
arrBounds = ST s (STUArray s i Word) -> STT s m (STUArray s i Word)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Word)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Word)
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i Word) -> STT s m (STUArray s i Word)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Word)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i Word -> Int -> STT s m Word
unsafeRead STUArray s i Word
arr Int
i = ST s Word -> STT s m Word
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word -> Int -> ST s Word
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i Word
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => STUArray s i Word -> Int -> Word -> STT s m ()
unsafeWrite STUArray s i Word
arr Int
i Word
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word -> Int -> Word -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i Word
arr Int
i Word
e)

instance (Applicative m, Monad m) => MArray (STUArray s) (Ptr a) (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i (Ptr a) -> STT s m (i, i)
getBounds STUArray s i (Ptr a)
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i (Ptr a) -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i (Ptr a)
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i (Ptr a) -> STT s m Int
getNumElements STUArray s i (Ptr a)
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i (Ptr a) -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i (Ptr a)
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Ptr a -> STT s m (STUArray s i (Ptr a))
newArray (i, i)
bnds Ptr a
e = ST s (STUArray s i (Ptr a)) -> STT s m (STUArray s i (Ptr a))
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Ptr a -> ST s (STUArray s i (Ptr a))
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Ptr a
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i (Ptr a))
newArray_ (i, i)
arrBounds = ST s (STUArray s i (Ptr a)) -> STT s m (STUArray s i (Ptr a))
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i (Ptr a))
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i (Ptr a))
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i (Ptr a)) -> STT s m (STUArray s i (Ptr a))
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i (Ptr a))
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i (Ptr a) -> Int -> STT s m (Ptr a)
unsafeRead STUArray s i (Ptr a)
arr Int
i = ST s (Ptr a) -> STT s m (Ptr a)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i (Ptr a) -> Int -> ST s (Ptr a)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i (Ptr a)
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i.
Ix i =>
STUArray s i (Ptr a) -> Int -> Ptr a -> STT s m ()
unsafeWrite STUArray s i (Ptr a)
arr Int
i Ptr a
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i (Ptr a) -> Int -> Ptr a -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i (Ptr a)
arr Int
i Ptr a
e)

instance (Applicative m, Monad m) => MArray (STUArray s) (FunPtr a) (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i (FunPtr a) -> STT s m (i, i)
getBounds STUArray s i (FunPtr a)
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i (FunPtr a) -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i (FunPtr a)
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i (FunPtr a) -> STT s m Int
getNumElements STUArray s i (FunPtr a)
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i (FunPtr a) -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i (FunPtr a)
arr)
    {-# INLINE newArray #-}
    newArray :: forall i.
Ix i =>
(i, i) -> FunPtr a -> STT s m (STUArray s i (FunPtr a))
newArray (i, i)
bnds FunPtr a
e = ST s (STUArray s i (FunPtr a)) -> STT s m (STUArray s i (FunPtr a))
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> FunPtr a -> ST s (STUArray s i (FunPtr a))
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds FunPtr a
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i (FunPtr a))
newArray_ (i, i)
arrBounds = ST s (STUArray s i (FunPtr a)) -> STT s m (STUArray s i (FunPtr a))
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i (FunPtr a))
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i (FunPtr a))
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i (FunPtr a)) -> STT s m (STUArray s i (FunPtr a))
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i (FunPtr a))
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i.
Ix i =>
STUArray s i (FunPtr a) -> Int -> STT s m (FunPtr a)
unsafeRead STUArray s i (FunPtr a)
arr Int
i = ST s (FunPtr a) -> STT s m (FunPtr a)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i (FunPtr a) -> Int -> ST s (FunPtr a)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i (FunPtr a)
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i.
Ix i =>
STUArray s i (FunPtr a) -> Int -> FunPtr a -> STT s m ()
unsafeWrite STUArray s i (FunPtr a)
arr Int
i FunPtr a
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i (FunPtr a) -> Int -> FunPtr a -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i (FunPtr a)
arr Int
i FunPtr a
e)

instance (Applicative m, Monad m) => MArray (STUArray s) Float (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i Float -> STT s m (i, i)
getBounds STUArray s i Float
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Float -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i Float
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i Float -> STT s m Int
getNumElements STUArray s i Float
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Float -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i Float
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Float -> STT s m (STUArray s i Float)
newArray (i, i)
bnds Float
e = ST s (STUArray s i Float) -> STT s m (STUArray s i Float)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Float -> ST s (STUArray s i Float)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Float
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Float)
newArray_ (i, i)
arrBounds = ST s (STUArray s i Float) -> STT s m (STUArray s i Float)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Float)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Float)
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i Float) -> STT s m (STUArray s i Float)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Float)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i Float -> Int -> STT s m Float
unsafeRead STUArray s i Float
arr Int
i = ST s Float -> STT s m Float
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Float -> Int -> ST s Float
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i Float
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => STUArray s i Float -> Int -> Float -> STT s m ()
unsafeWrite STUArray s i Float
arr Int
i Float
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Float -> Int -> Float -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i Float
arr Int
i Float
e)

instance (Applicative m, Monad m) => MArray (STUArray s) Double (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i Double -> STT s m (i, i)
getBounds STUArray s i Double
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Double -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i Double
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i Double -> STT s m Int
getNumElements STUArray s i Double
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Double -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i Double
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Double -> STT s m (STUArray s i Double)
newArray (i, i)
bnds Double
e = ST s (STUArray s i Double) -> STT s m (STUArray s i Double)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Double -> ST s (STUArray s i Double)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Double
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Double)
newArray_ (i, i)
arrBounds = ST s (STUArray s i Double) -> STT s m (STUArray s i Double)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Double)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Double)
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i Double) -> STT s m (STUArray s i Double)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Double)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i Double -> Int -> STT s m Double
unsafeRead STUArray s i Double
arr Int
i = ST s Double -> STT s m Double
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Double -> Int -> ST s Double
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i Double
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i.
Ix i =>
STUArray s i Double -> Int -> Double -> STT s m ()
unsafeWrite STUArray s i Double
arr Int
i Double
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Double -> Int -> Double -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i Double
arr Int
i Double
e)

instance (Applicative m, Monad m) => MArray (STUArray s) (StablePtr a) (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i (StablePtr a) -> STT s m (i, i)
getBounds STUArray s i (StablePtr a)
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i (StablePtr a) -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i (StablePtr a)
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i (StablePtr a) -> STT s m Int
getNumElements STUArray s i (StablePtr a)
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i (StablePtr a) -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i (StablePtr a)
arr)
    {-# INLINE newArray #-}
    newArray :: forall i.
Ix i =>
(i, i) -> StablePtr a -> STT s m (STUArray s i (StablePtr a))
newArray (i, i)
bnds StablePtr a
e = ST s (STUArray s i (StablePtr a))
-> STT s m (STUArray s i (StablePtr a))
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> StablePtr a -> ST s (STUArray s i (StablePtr a))
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds StablePtr a
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i (StablePtr a))
newArray_ (i, i)
arrBounds = ST s (STUArray s i (StablePtr a))
-> STT s m (STUArray s i (StablePtr a))
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i (StablePtr a))
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i (StablePtr a))
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i (StablePtr a))
-> STT s m (STUArray s i (StablePtr a))
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i (StablePtr a))
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i.
Ix i =>
STUArray s i (StablePtr a) -> Int -> STT s m (StablePtr a)
unsafeRead STUArray s i (StablePtr a)
arr Int
i = ST s (StablePtr a) -> STT s m (StablePtr a)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i (StablePtr a) -> Int -> ST s (StablePtr a)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i (StablePtr a)
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i.
Ix i =>
STUArray s i (StablePtr a) -> Int -> StablePtr a -> STT s m ()
unsafeWrite STUArray s i (StablePtr a)
arr Int
i StablePtr a
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i (StablePtr a) -> Int -> StablePtr a -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i (StablePtr a)
arr Int
i StablePtr a
e)

instance (Applicative m, Monad m) => MArray (STUArray s) Int8 (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i Int8 -> STT s m (i, i)
getBounds STUArray s i Int8
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int8 -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i Int8
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i Int8 -> STT s m Int
getNumElements STUArray s i Int8
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int8 -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i Int8
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Int8 -> STT s m (STUArray s i Int8)
newArray (i, i)
bnds Int8
e = ST s (STUArray s i Int8) -> STT s m (STUArray s i Int8)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Int8 -> ST s (STUArray s i Int8)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Int8
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Int8)
newArray_ (i, i)
arrBounds = ST s (STUArray s i Int8) -> STT s m (STUArray s i Int8)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Int8)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Int8)
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i Int8) -> STT s m (STUArray s i Int8)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Int8)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i Int8 -> Int -> STT s m Int8
unsafeRead STUArray s i Int8
arr Int
i = ST s Int8 -> STT s m Int8
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int8 -> Int -> ST s Int8
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i Int8
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => STUArray s i Int8 -> Int -> Int8 -> STT s m ()
unsafeWrite STUArray s i Int8
arr Int
i Int8
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int8 -> Int -> Int8 -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i Int8
arr Int
i Int8
e)

instance (Applicative m, Monad m) => MArray (STUArray s) Int16 (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i Int16 -> STT s m (i, i)
getBounds STUArray s i Int16
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int16 -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i Int16
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i Int16 -> STT s m Int
getNumElements STUArray s i Int16
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int16 -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i Int16
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Int16 -> STT s m (STUArray s i Int16)
newArray (i, i)
bnds Int16
e = ST s (STUArray s i Int16) -> STT s m (STUArray s i Int16)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Int16 -> ST s (STUArray s i Int16)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Int16
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Int16)
newArray_ (i, i)
arrBounds = ST s (STUArray s i Int16) -> STT s m (STUArray s i Int16)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Int16)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Int16)
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i Int16) -> STT s m (STUArray s i Int16)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Int16)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i Int16 -> Int -> STT s m Int16
unsafeRead STUArray s i Int16
arr Int
i = ST s Int16 -> STT s m Int16
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int16 -> Int -> ST s Int16
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i Int16
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => STUArray s i Int16 -> Int -> Int16 -> STT s m ()
unsafeWrite STUArray s i Int16
arr Int
i Int16
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int16 -> Int -> Int16 -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i Int16
arr Int
i Int16
e)

instance (Applicative m, Monad m) => MArray (STUArray s) Int32 (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i Int32 -> STT s m (i, i)
getBounds STUArray s i Int32
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int32 -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i Int32
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i Int32 -> STT s m Int
getNumElements STUArray s i Int32
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int32 -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i Int32
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Int32 -> STT s m (STUArray s i Int32)
newArray (i, i)
bnds Int32
e = ST s (STUArray s i Int32) -> STT s m (STUArray s i Int32)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Int32 -> ST s (STUArray s i Int32)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Int32
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Int32)
newArray_ (i, i)
arrBounds = ST s (STUArray s i Int32) -> STT s m (STUArray s i Int32)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Int32)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Int32)
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i Int32) -> STT s m (STUArray s i Int32)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Int32)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i Int32 -> Int -> STT s m Int32
unsafeRead STUArray s i Int32
arr Int
i = ST s Int32 -> STT s m Int32
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int32 -> Int -> ST s Int32
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i Int32
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => STUArray s i Int32 -> Int -> Int32 -> STT s m ()
unsafeWrite STUArray s i Int32
arr Int
i Int32
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int32 -> Int -> Int32 -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i Int32
arr Int
i Int32
e)

instance (Applicative m, Monad m) => MArray (STUArray s) Int64 (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i Int64 -> STT s m (i, i)
getBounds STUArray s i Int64
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int64 -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i Int64
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i Int64 -> STT s m Int
getNumElements STUArray s i Int64
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int64 -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i Int64
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Int64 -> STT s m (STUArray s i Int64)
newArray (i, i)
bnds Int64
e = ST s (STUArray s i Int64) -> STT s m (STUArray s i Int64)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Int64 -> ST s (STUArray s i Int64)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Int64
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Int64)
newArray_ (i, i)
arrBounds = ST s (STUArray s i Int64) -> STT s m (STUArray s i Int64)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Int64)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Int64)
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i Int64) -> STT s m (STUArray s i Int64)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Int64)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i Int64 -> Int -> STT s m Int64
unsafeRead STUArray s i Int64
arr Int
i = ST s Int64 -> STT s m Int64
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int64 -> Int -> ST s Int64
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i Int64
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => STUArray s i Int64 -> Int -> Int64 -> STT s m ()
unsafeWrite STUArray s i Int64
arr Int
i Int64
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Int64 -> Int -> Int64 -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i Int64
arr Int
i Int64
e)

instance (Applicative m, Monad m) => MArray (STUArray s) Word8 (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i Word8 -> STT s m (i, i)
getBounds STUArray s i Word8
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word8 -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i Word8
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i Word8 -> STT s m Int
getNumElements STUArray s i Word8
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word8 -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i Word8
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Word8 -> STT s m (STUArray s i Word8)
newArray (i, i)
bnds Word8
e = ST s (STUArray s i Word8) -> STT s m (STUArray s i Word8)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Word8 -> ST s (STUArray s i Word8)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Word8
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Word8)
newArray_ (i, i)
arrBounds = ST s (STUArray s i Word8) -> STT s m (STUArray s i Word8)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Word8)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Word8)
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i Word8) -> STT s m (STUArray s i Word8)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Word8)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i Word8 -> Int -> STT s m Word8
unsafeRead STUArray s i Word8
arr Int
i = ST s Word8 -> STT s m Word8
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word8 -> Int -> ST s Word8
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i Word8
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i. Ix i => STUArray s i Word8 -> Int -> Word8 -> STT s m ()
unsafeWrite STUArray s i Word8
arr Int
i Word8
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word8 -> Int -> Word8 -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i Word8
arr Int
i Word8
e)

instance (Applicative m, Monad m) => MArray (STUArray s) Word16 (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i Word16 -> STT s m (i, i)
getBounds STUArray s i Word16
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word16 -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i Word16
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i Word16 -> STT s m Int
getNumElements STUArray s i Word16
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word16 -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i Word16
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Word16 -> STT s m (STUArray s i Word16)
newArray (i, i)
bnds Word16
e = ST s (STUArray s i Word16) -> STT s m (STUArray s i Word16)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Word16 -> ST s (STUArray s i Word16)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Word16
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Word16)
newArray_ (i, i)
arrBounds = ST s (STUArray s i Word16) -> STT s m (STUArray s i Word16)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Word16)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Word16)
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i Word16) -> STT s m (STUArray s i Word16)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Word16)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i Word16 -> Int -> STT s m Word16
unsafeRead STUArray s i Word16
arr Int
i = ST s Word16 -> STT s m Word16
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word16 -> Int -> ST s Word16
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i Word16
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i.
Ix i =>
STUArray s i Word16 -> Int -> Word16 -> STT s m ()
unsafeWrite STUArray s i Word16
arr Int
i Word16
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word16 -> Int -> Word16 -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i Word16
arr Int
i Word16
e)

instance (Applicative m, Monad m) => MArray (STUArray s) Word32 (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i Word32 -> STT s m (i, i)
getBounds STUArray s i Word32
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word32 -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i Word32
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i Word32 -> STT s m Int
getNumElements STUArray s i Word32
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word32 -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i Word32
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Word32 -> STT s m (STUArray s i Word32)
newArray (i, i)
bnds Word32
e = ST s (STUArray s i Word32) -> STT s m (STUArray s i Word32)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Word32 -> ST s (STUArray s i Word32)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Word32
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Word32)
newArray_ (i, i)
arrBounds = ST s (STUArray s i Word32) -> STT s m (STUArray s i Word32)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Word32)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Word32)
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i Word32) -> STT s m (STUArray s i Word32)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Word32)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i Word32 -> Int -> STT s m Word32
unsafeRead STUArray s i Word32
arr Int
i = ST s Word32 -> STT s m Word32
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word32 -> Int -> ST s Word32
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i Word32
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i.
Ix i =>
STUArray s i Word32 -> Int -> Word32 -> STT s m ()
unsafeWrite STUArray s i Word32
arr Int
i Word32
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word32 -> Int -> Word32 -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i Word32
arr Int
i Word32
e)

instance (Applicative m, Monad m) => MArray (STUArray s) Word64 (STT s m) where
    {-# INLINE getBounds #-}
    getBounds :: forall i. Ix i => STUArray s i Word64 -> STT s m (i, i)
getBounds STUArray s i Word64
arr = ST s (i, i) -> STT s m (i, i)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word64 -> ST s (i, i)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m (i, i)
getBounds STUArray s i Word64
arr)
    {-# INLINE getNumElements #-}
    getNumElements :: forall i. Ix i => STUArray s i Word64 -> STT s m Int
getNumElements STUArray s i Word64
arr = ST s Int -> STT s m Int
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word64 -> ST s Int
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> m Int
getNumElements STUArray s i Word64
arr)
    {-# INLINE newArray #-}
    newArray :: forall i. Ix i => (i, i) -> Word64 -> STT s m (STUArray s i Word64)
newArray (i, i)
bnds Word64
e = ST s (STUArray s i Word64) -> STT s m (STUArray s i Word64)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> Word64 -> ST s (STUArray s i Word64)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> e -> m (a i e)
newArray (i, i)
bnds Word64
e)
    {-# INLINE newArray_ #-}
    newArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Word64)
newArray_ (i, i)
arrBounds = ST s (STUArray s i Word64) -> STT s m (STUArray s i Word64)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Word64)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
newArray_ (i, i)
arrBounds)
    {-# INLINE unsafeNewArray_ #-}
    unsafeNewArray_ :: forall i. Ix i => (i, i) -> STT s m (STUArray s i Word64)
unsafeNewArray_ (i, i)
bnds = ST s (STUArray s i Word64) -> STT s m (STUArray s i Word64)
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST ((i, i) -> ST s (STUArray s i Word64)
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
(i, i) -> m (a i e)
unsafeNewArray_ (i, i)
bnds)
    {-# INLINE unsafeRead #-}
    unsafeRead :: forall i. Ix i => STUArray s i Word64 -> Int -> STT s m Word64
unsafeRead STUArray s i Word64
arr Int
i = ST s Word64 -> STT s m Word64
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word64 -> Int -> ST s Word64
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> m e
unsafeRead STUArray s i Word64
arr Int
i)
    {-# INLINE unsafeWrite #-}
    unsafeWrite :: forall i.
Ix i =>
STUArray s i Word64 -> Int -> Word64 -> STT s m ()
unsafeWrite STUArray s i Word64
arr Int
i Word64
e = ST s () -> STT s m ()
forall (m :: * -> *) s a. Applicative m => ST s a -> STT s m a
liftST (STUArray s i Word64 -> Int -> Word64 -> ST s ()
forall (a :: * -> * -> *) e (m :: * -> *) i.
(MArray a e m, Ix i) =>
a i e -> Int -> e -> m ()
unsafeWrite STUArray s i Word64
arr Int
i Word64
e)