\begin{code}
module FastMutInt(
FastMutInt, newFastMutInt,
- readFastMutInt, writeFastMutInt,
- incFastMutInt, incFastMutIntBy
+ readFastMutInt, writeFastMutInt
) where
#include "MachDeps.h"
import GHC.Base
import GHC.IOBase
#endif
+
+#if __GLASGOW_HASKELL__ < 411
+newByteArray# = newCharArray#
+#endif
\end{code}
\begin{code}
writeFastMutInt (FastMutInt arr) (I# i) = IO $ \s ->
case writeIntArray# arr 0# i s of { s ->
(# s, () #) }
-
-incFastMutInt :: FastMutInt -> IO Int -- Returns original value
-incFastMutInt (FastMutInt arr) = IO $ \s ->
- case readIntArray# arr 0# s of { (# s, i #) ->
- case writeIntArray# arr 0# (i +# 1#) s of { s ->
- (# s, I# i #) } }
-
-incFastMutIntBy :: FastMutInt -> Int -> IO Int -- Returns original value
-incFastMutIntBy (FastMutInt arr) (I# n) = IO $ \s ->
- case readIntArray# arr 0# s of { (# s, i #) ->
- case writeIntArray# arr 0# (i +# n) s of { s ->
- (# s, I# i #) } }
\end{code}
#endif