{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE UnliftedNewtypes #-}
module GHC.Internal.ArrayArray
( ArrayArray#(..), MutableArrayArray#(..)
, newArrayArray#
, unsafeFreezeArrayArray#
, sizeofArrayArray#
, sizeofMutableArrayArray#
, indexByteArrayArray#
, indexArrayArrayArray#
, readByteArrayArray#
, readMutableByteArrayArray#
, readArrayArrayArray#
, readMutableArrayArrayArray#
, writeByteArrayArray#
, writeMutableByteArrayArray#
, writeArrayArrayArray#
, writeMutableArrayArrayArray#
, copyArrayArray#
, copyMutableArrayArray#
, sameArrayArray#
, sameMutableArrayArray#
)
where
import GHC.Prim
import GHC.Prim.PtrEq ( unsafePtrEquality# )
import GHC.Types ( Type, UnliftedType, isTrue# )
import GHC.Internal.Unsafe.Coerce ( unsafeCoerce, unsafeCoerceUnlifted )
default ()
type ArrayArray# :: UnliftedType
newtype ArrayArray# = ArrayArray# (Array# ByteArray#)
type MutableArrayArray# :: Type -> UnliftedType
newtype MutableArrayArray# s = MutableArrayArray# (MutableArray# s ByteArray#)
newArrayArray# :: Int# -> State# s -> (# State# s, MutableArrayArray# s #)
newArrayArray# :: forall s. Int# -> State# s -> (# State# s, MutableArrayArray# s #)
newArrayArray# Int#
sz State# s
s1 =
case Int# -> State# s -> (# State# s, MutableByteArray# s #)
forall d. Int# -> State# d -> (# State# d, MutableByteArray# d #)
newByteArray# Int#
0# State# s
s1 of
(# State# s
s2, MutableByteArray# s
placeholder #) ->
case Int#
-> ByteArray#
-> State# s
-> (# State# s, MutableArray# s ByteArray# #)
forall a d.
Int# -> a -> State# d -> (# State# d, MutableArray# d a #)
newArray# Int#
sz (MutableByteArray# s -> ByteArray#
forall (a :: UnliftedType) (b :: UnliftedType). a -> b
unsafeCoerceUnlifted MutableByteArray# s
placeholder) State# s
s2 of
(# State# s
s3, MutableArray# s ByteArray#
arr #) ->
case MutableArray# s ByteArray# -> Int# -> State# s -> State# s
forall s.
MutableArray# s ByteArray# -> Int# -> State# s -> State# s
write_array_to_array MutableArray# s ByteArray#
arr Int#
0# State# s
s3 of
State# s
s4 -> (# State# s
s4, MutableArray# s ByteArray# -> MutableArrayArray# s
forall s. MutableArray# s ByteArray# -> MutableArrayArray# s
MutableArrayArray# (MutableArray# s ByteArray# -> MutableArray# s ByteArray#
forall (a :: UnliftedType) (b :: UnliftedType). a -> b
unsafeCoerceUnlifted MutableArray# s ByteArray#
arr) #)
where
write_array_to_array :: MutableArray# s ByteArray# -> Int# -> State# s -> State# s
write_array_to_array :: forall s.
MutableArray# s ByteArray# -> Int# -> State# s -> State# s
write_array_to_array MutableArray# s ByteArray#
_ Int#
i State# s
s
| Int# -> Bool
isTrue# (Int#
i Int# -> Int# -> Int#
>=# Int#
sz)
= State# s
s
write_array_to_array MutableArray# s ByteArray#
arr Int#
i State# s
s
= case MutableArray# s ByteArray#
-> Int# -> ByteArray# -> State# s -> State# s
forall d a. MutableArray# d a -> Int# -> a -> State# d -> State# d
writeArray# MutableArray# s ByteArray#
arr Int#
i (MutableArray# s ByteArray# -> ByteArray#
forall (a :: UnliftedType) (b :: UnliftedType). a -> b
unsafeCoerceUnlifted MutableArray# s ByteArray#
arr) State# s
s of
State# s
s' -> MutableArray# s ByteArray# -> Int# -> State# s -> State# s
forall s.
MutableArray# s ByteArray# -> Int# -> State# s -> State# s
write_array_to_array MutableArray# s ByteArray#
arr (Int#
i Int# -> Int# -> Int#
+# Int#
1#) State# s
s'
unsafeFreezeArrayArray# :: MutableArrayArray# s -> State# s -> (# State# s, ArrayArray# #)
unsafeFreezeArrayArray# :: forall s.
MutableArrayArray# s -> State# s -> (# State# s, ArrayArray# #)
unsafeFreezeArrayArray# = (MutableArray# (ZonkAny 25) (ZonkAny 26)
-> State# (ZonkAny 25)
-> (# State# (ZonkAny 25), Array# (ZonkAny 26) #))
-> MutableArrayArray# s -> State# s -> (# State# s, ArrayArray# #)
forall a b. a -> b
unsafeCoerce MutableArray# (ZonkAny 25) (ZonkAny 26)
-> State# (ZonkAny 25)
-> (# State# (ZonkAny 25), Array# (ZonkAny 26) #)
forall d a.
MutableArray# d a -> State# d -> (# State# d, Array# a #)
unsafeFreezeArray#
sizeofArrayArray# :: ArrayArray# -> Int#
sizeofArrayArray# :: ArrayArray# -> Int#
sizeofArrayArray# = (Array# (ZonkAny 24) -> Int#) -> ArrayArray# -> Int#
forall a b. a -> b
unsafeCoerce Array# (ZonkAny 24) -> Int#
forall a. Array# a -> Int#
sizeofArray#
sizeofMutableArrayArray# :: MutableArrayArray# s -> Int#
sizeofMutableArrayArray# :: forall s. MutableArrayArray# s -> Int#
sizeofMutableArrayArray# = (MutableArray# (ZonkAny 22) (ZonkAny 23) -> Int#)
-> MutableArrayArray# s -> Int#
forall a b. a -> b
unsafeCoerce MutableArray# (ZonkAny 22) (ZonkAny 23) -> Int#
forall d a. MutableArray# d a -> Int#
sizeofMutableArray#
indexByteArrayArray# :: ArrayArray# -> Int# -> ByteArray#
indexByteArrayArray# :: ArrayArray# -> Int# -> ByteArray#
indexByteArrayArray# = (Array# (ZonkAny 21) -> Int# -> (# ZonkAny 21 #))
-> ArrayArray# -> Int# -> ByteArray#
forall a b. a -> b
unsafeCoerce Array# (ZonkAny 21) -> Int# -> (# ZonkAny 21 #)
forall a. Array# a -> Int# -> (# a #)
indexArray#
indexArrayArrayArray# :: ArrayArray# -> Int# -> ArrayArray#
indexArrayArrayArray# :: ArrayArray# -> Int# -> ArrayArray#
indexArrayArrayArray# = (Array# (ZonkAny 20) -> Int# -> (# ZonkAny 20 #))
-> ArrayArray# -> Int# -> ArrayArray#
forall a b. a -> b
unsafeCoerce Array# (ZonkAny 20) -> Int# -> (# ZonkAny 20 #)
forall a. Array# a -> Int# -> (# a #)
indexArray#
readByteArrayArray# :: MutableArrayArray# s -> Int# -> State# s -> (# State# s, ByteArray# #)
readByteArrayArray# :: forall s.
MutableArrayArray# s
-> Int# -> State# s -> (# State# s, ByteArray# #)
readByteArrayArray# = (MutableArray# (ZonkAny 18) (ZonkAny 19)
-> Int#
-> State# (ZonkAny 18)
-> (# State# (ZonkAny 18), ZonkAny 19 #))
-> MutableArrayArray# s
-> Int#
-> State# s
-> (# State# s, ByteArray# #)
forall a b. a -> b
unsafeCoerce MutableArray# (ZonkAny 18) (ZonkAny 19)
-> Int#
-> State# (ZonkAny 18)
-> (# State# (ZonkAny 18), ZonkAny 19 #)
forall d a.
MutableArray# d a -> Int# -> State# d -> (# State# d, a #)
readArray#
readMutableByteArrayArray# :: MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
readMutableByteArrayArray# :: forall s.
MutableArrayArray# s
-> Int# -> State# s -> (# State# s, MutableByteArray# s #)
readMutableByteArrayArray# = (MutableArray# (ZonkAny 16) (ZonkAny 17)
-> Int#
-> State# (ZonkAny 16)
-> (# State# (ZonkAny 16), ZonkAny 17 #))
-> MutableArrayArray# s
-> Int#
-> State# s
-> (# State# s, MutableByteArray# s #)
forall a b. a -> b
unsafeCoerce MutableArray# (ZonkAny 16) (ZonkAny 17)
-> Int#
-> State# (ZonkAny 16)
-> (# State# (ZonkAny 16), ZonkAny 17 #)
forall d a.
MutableArray# d a -> Int# -> State# d -> (# State# d, a #)
readArray#
readArrayArrayArray# :: MutableArrayArray# s -> Int# -> State# s -> (# State# s, ArrayArray# #)
readArrayArrayArray# :: forall s.
MutableArrayArray# s
-> Int# -> State# s -> (# State# s, ArrayArray# #)
readArrayArrayArray# = (MutableArray# (ZonkAny 14) (ZonkAny 15)
-> Int#
-> State# (ZonkAny 14)
-> (# State# (ZonkAny 14), ZonkAny 15 #))
-> MutableArrayArray# s
-> Int#
-> State# s
-> (# State# s, ArrayArray# #)
forall a b. a -> b
unsafeCoerce MutableArray# (ZonkAny 14) (ZonkAny 15)
-> Int#
-> State# (ZonkAny 14)
-> (# State# (ZonkAny 14), ZonkAny 15 #)
forall d a.
MutableArray# d a -> Int# -> State# d -> (# State# d, a #)
readArray#
readMutableArrayArrayArray# :: MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableArrayArray# s #)
readMutableArrayArrayArray# :: forall s.
MutableArrayArray# s
-> Int# -> State# s -> (# State# s, MutableArrayArray# s #)
readMutableArrayArrayArray# = (MutableArray# (ZonkAny 12) (ZonkAny 13)
-> Int#
-> State# (ZonkAny 12)
-> (# State# (ZonkAny 12), ZonkAny 13 #))
-> MutableArrayArray# s
-> Int#
-> State# s
-> (# State# s, MutableArrayArray# s #)
forall a b. a -> b
unsafeCoerce MutableArray# (ZonkAny 12) (ZonkAny 13)
-> Int#
-> State# (ZonkAny 12)
-> (# State# (ZonkAny 12), ZonkAny 13 #)
forall d a.
MutableArray# d a -> Int# -> State# d -> (# State# d, a #)
readArray#
writeByteArrayArray# :: MutableArrayArray# s -> Int# -> ByteArray# -> State# s -> State# s
writeByteArrayArray# :: forall s.
MutableArrayArray# s -> Int# -> ByteArray# -> State# s -> State# s
writeByteArrayArray# = (MutableArray# (ZonkAny 10) (ZonkAny 11)
-> Int#
-> ZonkAny 11
-> State# (ZonkAny 10)
-> State# (ZonkAny 10))
-> MutableArrayArray# s
-> Int#
-> ByteArray#
-> State# s
-> State# s
forall a b. a -> b
unsafeCoerce MutableArray# (ZonkAny 10) (ZonkAny 11)
-> Int# -> ZonkAny 11 -> State# (ZonkAny 10) -> State# (ZonkAny 10)
forall d a. MutableArray# d a -> Int# -> a -> State# d -> State# d
writeArray#
writeMutableByteArrayArray# :: MutableArrayArray# s -> Int# -> MutableByteArray# s -> State# s -> State# s
writeMutableByteArrayArray# :: forall s.
MutableArrayArray# s
-> Int# -> MutableByteArray# s -> State# s -> State# s
writeMutableByteArrayArray# = (MutableArray# (ZonkAny 8) (ZonkAny 9)
-> Int# -> ZonkAny 9 -> State# (ZonkAny 8) -> State# (ZonkAny 8))
-> MutableArrayArray# s
-> Int#
-> MutableByteArray# s
-> State# s
-> State# s
forall a b. a -> b
unsafeCoerce MutableArray# (ZonkAny 8) (ZonkAny 9)
-> Int# -> ZonkAny 9 -> State# (ZonkAny 8) -> State# (ZonkAny 8)
forall d a. MutableArray# d a -> Int# -> a -> State# d -> State# d
writeArray#
writeArrayArrayArray# :: MutableArrayArray# s -> Int# -> ArrayArray# -> State# s -> State# s
writeArrayArrayArray# :: forall s.
MutableArrayArray# s -> Int# -> ArrayArray# -> State# s -> State# s
writeArrayArrayArray# = (MutableArray# (ZonkAny 6) (ZonkAny 7)
-> Int# -> ZonkAny 7 -> State# (ZonkAny 6) -> State# (ZonkAny 6))
-> MutableArrayArray# s
-> Int#
-> ArrayArray#
-> State# s
-> State# s
forall a b. a -> b
unsafeCoerce MutableArray# (ZonkAny 6) (ZonkAny 7)
-> Int# -> ZonkAny 7 -> State# (ZonkAny 6) -> State# (ZonkAny 6)
forall d a. MutableArray# d a -> Int# -> a -> State# d -> State# d
writeArray#
writeMutableArrayArrayArray# :: MutableArrayArray# s -> Int# -> MutableArrayArray# s -> State# s -> State# s
writeMutableArrayArrayArray# :: forall s.
MutableArrayArray# s
-> Int# -> MutableArrayArray# s -> State# s -> State# s
writeMutableArrayArrayArray# = (MutableArray# (ZonkAny 4) (ZonkAny 5)
-> Int# -> ZonkAny 5 -> State# (ZonkAny 4) -> State# (ZonkAny 4))
-> MutableArrayArray# s
-> Int#
-> MutableArrayArray# s
-> State# s
-> State# s
forall a b. a -> b
unsafeCoerce MutableArray# (ZonkAny 4) (ZonkAny 5)
-> Int# -> ZonkAny 5 -> State# (ZonkAny 4) -> State# (ZonkAny 4)
forall d a. MutableArray# d a -> Int# -> a -> State# d -> State# d
writeArray#
copyArrayArray# :: ArrayArray# -> Int# -> MutableArrayArray# s -> Int# -> Int# -> State# s -> State# s
copyArrayArray# :: forall s.
ArrayArray#
-> Int#
-> MutableArrayArray# s
-> Int#
-> Int#
-> State# s
-> State# s
copyArrayArray# = (Array# (ZonkAny 2)
-> Int#
-> MutableArray# (ZonkAny 3) (ZonkAny 2)
-> Int#
-> Int#
-> State# (ZonkAny 3)
-> State# (ZonkAny 3))
-> ArrayArray#
-> Int#
-> MutableArrayArray# s
-> Int#
-> Int#
-> State# s
-> State# s
forall a b. a -> b
unsafeCoerce Array# (ZonkAny 2)
-> Int#
-> MutableArray# (ZonkAny 3) (ZonkAny 2)
-> Int#
-> Int#
-> State# (ZonkAny 3)
-> State# (ZonkAny 3)
forall a d.
Array# a
-> Int#
-> MutableArray# d a
-> Int#
-> Int#
-> State# d
-> State# d
copyArray#
copyMutableArrayArray# :: MutableArrayArray# s -> Int# -> MutableArrayArray# s -> Int# -> Int# -> State# s -> State# s
copyMutableArrayArray# :: forall s.
MutableArrayArray# s
-> Int#
-> MutableArrayArray# s
-> Int#
-> Int#
-> State# s
-> State# s
copyMutableArrayArray# = (MutableArray# (ZonkAny 0) (ZonkAny 1)
-> Int#
-> MutableArray# (ZonkAny 0) (ZonkAny 1)
-> Int#
-> Int#
-> State# (ZonkAny 0)
-> State# (ZonkAny 0))
-> MutableArrayArray# s
-> Int#
-> MutableArrayArray# s
-> Int#
-> Int#
-> State# s
-> State# s
forall a b. a -> b
unsafeCoerce MutableArray# (ZonkAny 0) (ZonkAny 1)
-> Int#
-> MutableArray# (ZonkAny 0) (ZonkAny 1)
-> Int#
-> Int#
-> State# (ZonkAny 0)
-> State# (ZonkAny 0)
forall d a.
MutableArray# d a
-> Int#
-> MutableArray# d a
-> Int#
-> Int#
-> State# d
-> State# d
copyMutableArray#
sameArrayArray# :: ArrayArray# -> ArrayArray# -> Int#
sameArrayArray# :: ArrayArray# -> ArrayArray# -> Int#
sameArrayArray# (ArrayArray# Array# ByteArray#
arr1) (ArrayArray# Array# ByteArray#
arr2) = Array# ByteArray# -> Array# ByteArray# -> Int#
forall (a :: UnliftedType) (b :: UnliftedType). a -> b -> Int#
unsafePtrEquality# Array# ByteArray#
arr1 Array# ByteArray#
arr2
sameMutableArrayArray# :: MutableArrayArray# s -> MutableArrayArray# s -> Int#
sameMutableArrayArray# :: forall s. MutableArrayArray# s -> MutableArrayArray# s -> Int#
sameMutableArrayArray# (MutableArrayArray# MutableArray# s ByteArray#
marr1) (MutableArrayArray# MutableArray# s ByteArray#
marr2 ) = MutableArray# s ByteArray# -> MutableArray# s ByteArray# -> Int#
forall (a :: UnliftedType) (b :: UnliftedType). a -> b -> Int#
unsafePtrEquality# MutableArray# s ByteArray#
marr1 MutableArray# s ByteArray#
marr2