X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fstd%2FPrelArrExtra.lhs;h=840e9dd7c890bdd118a57b32343c2664c54f6f9e;hb=e921b2e307532e0f30eefa88b11a124be592bde4;hp=5f94e2e9b1219c1d5c111700a05ca35a97024dd5;hpb=438596897ebbe25a07e1c82085cfbc5bdb00f09e;p=ghc-hetmet.git diff --git a/ghc/lib/std/PrelArrExtra.lhs b/ghc/lib/std/PrelArrExtra.lhs index 5f94e2e..840e9dd 100644 --- a/ghc/lib/std/PrelArrExtra.lhs +++ b/ghc/lib/std/PrelArrExtra.lhs @@ -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}