module FastMutInt(
FastMutInt, newFastMutInt,
readFastMutInt, writeFastMutInt
) where
#define SIZEOF_HSINT 4
import GHC.Base
import GHC.IOBase
data FastMutInt = FastMutInt (MutableByteArray# RealWorld)
newFastMutInt :: IO FastMutInt
newFastMutInt = IO $ \s_in ->
case newByteArray# size s_in of { (# s, arr #) ->
(# s, FastMutInt arr #) }
where I# size = SIZEOF_HSINT
readFastMutInt :: FastMutInt -> IO Int
readFastMutInt (FastMutInt arr) = IO $ \s_in ->
case readIntArray# arr 0# s_in of { (# s, i #) ->
(# s, I# i #) }
writeFastMutInt :: FastMutInt -> Int -> IO ()
writeFastMutInt (FastMutInt arr) (I# i) = IO $ \s_in ->
case writeIntArray# arr 0# i s_in of { s ->
(# s, () #) }