[project @ 1999-12-20 10:34:27 by simonpj]
[ghc-hetmet.git] / ghc / lib / std / PrelArrExtra.lhs
index 5f94e2e..840e9dd 100644 (file)
@@ -15,6 +15,7 @@ module PrelArrExtra where
 
 import Ix
 import PrelArr
+import PrelByteArr
 import PrelST
 import PrelBase
 import PrelGHC
@@ -22,19 +23,19 @@ import PrelGHC
 freezeFloatArray  :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix)
 freezeDoubleArray :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix)
 
-freezeFloatArray (MutableByteArray ixs arr#) = ST $ \ s# ->
-    case rangeSize ixs     of { I# n# ->
+freezeFloatArray (MutableByteArray l u arr#) = ST $ \ s# ->
+    case rangeSize (l,u)   of { I# n# ->
     case freeze arr# n# s# of { (# s2#, frozen# #) ->
-    (# s2#, ByteArray ixs frozen# #) }}
+    (# s2#, ByteArray l u frozen# #) }}
   where
     freeze  :: MutableByteArray# s     -- the thing
            -> Int#                     -- size of thing to be frozen
            -> State# s                 -- the Universe and everything
            -> (# State# s, ByteArray# #)
 
-    freeze arr# end# s#
-      = case (newFloatArray# end# s#)   of { (# s2#, newarr1# #) ->
-       case copy 0# arr# newarr1# s2#  of { (# s3#, newarr2# #) ->
+    freeze arr1# end# s#
+      = case (newFloatArray# end# s#)    of { (# s2#, newarr1# #) ->
+       case copy 0# arr1# newarr1# s2#  of { (# s3#, newarr2# #) ->
        unsafeFreezeByteArray# newarr2# s3#
        }}
       where
@@ -43,28 +44,28 @@ freezeFloatArray (MutableByteArray ixs arr#) = ST $ \ s# ->
             -> State# s
             -> (# State# s, MutableByteArray# s #)
 
-       copy cur# from# to# s#
+       copy cur# from# to# s1#
          | cur# ==# end#
-           = (# s#, to# #)
+           = (# s1#, to# #)
          | otherwise
-           = case (readFloatArray#  from# cur#     s#)  of { (# s1#, ele #) ->
-             case (writeFloatArray# to#   cur# ele s1#) of { s2# ->
-             copy (cur# +# 1#) from# to# s2#
+           = case (readFloatArray#  from# cur#     s1#)  of { (# s2#, ele #) ->
+             case (writeFloatArray# to#   cur# ele s2#)  of { s3# ->
+             copy (cur# +# 1#) from# to# s3#
              }}
 
-freezeDoubleArray (MutableByteArray ixs arr#) = ST $ \ s# ->
-    case rangeSize ixs     of { I# n# ->
+freezeDoubleArray (MutableByteArray l u arr#) = ST $ \ s# ->
+    case rangeSize (l,u)   of { I# n# ->
     case freeze arr# n# s# of { (# s2#, frozen# #) ->
-    (# s2#, ByteArray ixs frozen# #) }}
+    (# s2#, ByteArray l u frozen# #) }}
   where
     freeze  :: MutableByteArray# s     -- the thing
            -> Int#                     -- size of thing to be frozen
            -> State# s                 -- the Universe and everything
            -> (# State# s, ByteArray# #)
 
-    freeze arr# n# s#
-      = case (newDoubleArray# n# s#)              of { (# s2#, newarr1# #) ->
-       case copy 0# n# arr# newarr1# s2#  of { (# s3#, newarr2# #) ->
+    freeze arr1# n# s1#
+      = case (newDoubleArray# n# s1#)             of { (# s2#, newarr1# #) ->
+       case copy 0# n# arr1# newarr1# s2# of { (# s3#, newarr2# #) ->
        unsafeFreezeByteArray# newarr2# s3#
        }}
       where
@@ -73,12 +74,12 @@ freezeDoubleArray (MutableByteArray ixs arr#) = ST $ \ s# ->
             -> State# s
             -> (# State# s, MutableByteArray# s #)
 
-       copy cur# end# from# to# s#
+       copy cur# end# from# to# st#
          | cur# ==# end#
-           = (# s#, to# #)
+           = (# st#, to# #)
          | otherwise
-           = case (readDoubleArray#  from# cur#     s#)  of { (# s1#, ele #) ->
-             case (writeDoubleArray# to#   cur# ele s1#) of { s2# ->
-             copy (cur# +# 1#) end# from# to# s2#
+           = case (readDoubleArray#  from# cur#     st#) of { (# s2#, ele #) ->
+             case (writeDoubleArray# to#   cur# ele s2#) of { s3# ->
+             copy (cur# +# 1#) end# from# to# s3#
              }}
 \end{code}