    -- Module      : Basement.PrimType
    -- License     : BSD-style
    -- Maintainer  : Vincent Hanquez <vincent@snarc.org>
    -- Stability   : experimental
    -- Portability : portable
    --
    {-# LANGUAGE DataKinds #-}
    {-# LANGUAGE MagicHash #-}
    {-# LANGUAGE UnboxedTuples #-}
    {-# LANGUAGE FlexibleInstances #-}
    {-# LANGUAGE ScopedTypeVariables #-}
    {-# LANGUAGE CPP #-}
    module Basement.PrimType
        ( PrimType(..)
        , PrimMemoryComparable
        , primBaIndex
        , primMbaRead
        , primMbaWrite
        , primArrayIndex
        , primMutableArrayRead
        , primMutableArrayWrite
        , primOffsetOfE
        , primOffsetRecast
        , sizeRecast
        , offsetAsSize
        , sizeAsOffset
        , sizeInBytes
        , offsetInBytes
        , offsetInElements
        , offsetIsAligned
        , primWordGetByteAndShift
        , primWord64GetByteAndShift
        , primWord64GetHiLo
        ) where

    #include "MachDeps.h"

    import           GHC.Prim
    import           GHC.Int
    import           GHC.Types
    import           GHC.Word
    import           Data.Bits
    import           Data.Proxy
    import           Basement.Compat.Base
    import           Basement.Compat.C.Types
    import           Basement.Numerical.Subtractive
    import           Basement.Types.OffsetSize
    import           Basement.Types.Char7 (Char7(..))
    import           Basement.Endianness
    import           Basement.Types.Word128 (Word128(..))
    import           Basement.Types.Word256 (Word256(..))
    import           Basement.Monad
    import           Basement.Nat
    import qualified Prelude (quot)

    #if WORD_SIZE_IN_BITS < 64
    #if __GLASGOW_HASKELL__ >= 904
    import GHC.Exts
    #else
    import GHC.IntWord64
    #endif
    #endif

    #ifdef FOUNDATION_BOUNDS_CHECK

    divBytes :: PrimType ty => Offset ty -> (Int -> Int)
    divBytes ofs = \x -> x `Prelude.quot` (getSize Proxy ofs)
      where
        getSize :: PrimType ty => Proxy ty -> Offset ty -> Int
        getSize p _ = let (CountOf sz) = primSizeInBytes p in sz

    baLength :: PrimType ty => Offset ty -> ByteArray# -> Int
    baLength ofs ba = divBytes ofs (I# (sizeofByteArray# ba))

    mbaLength :: PrimType ty => Offset ty -> MutableByteArray# st -> Int
    mbaLength ofs ba = divBytes ofs (I# (sizeofMutableByteArray# ba))

    aLength :: Array# ty -> Int
    aLength ba = I# (sizeofArray# ba)

    maLength :: MutableArray# st ty -> Int
    maLength ba = I# (sizeofMutableArray# ba)

    boundCheckError :: [Char] -> Offset ty -> Int -> a
    boundCheckError ty (Offset ofs) len =
        error (ty <> " offset=" <> show ofs <> " len=" <> show len)

    baCheck :: PrimType ty => ByteArray# -> Offset ty -> Bool
    baCheck ba ofs@(Offset o) = o < 0 || o >= baLength ofs ba

    mbaCheck :: PrimType ty => MutableByteArray# st -> Offset ty -> Bool
    mbaCheck mba ofs@(Offset o) = o < 0 || o >= mbaLength ofs mba

    aCheck :: Array# ty -> Offset ty -> Bool
    aCheck ba (Offset o) = o < 0 || o >= aLength ba

    maCheck :: MutableArray# st ty -> Offset ty -> Bool
    maCheck ma (Offset o) = o < 0 || o >= maLength ma

    primBaIndex :: PrimType ty => ByteArray# -> Offset ty -> ty
    primBaIndex ba ofs
        | baCheck ba ofs = boundCheckError "bytearray-index" ofs (baLength ofs ba)
        | otherwise      = primBaUIndex ba ofs
    {-# NOINLINE primBaIndex #-}

    primMbaRead :: (PrimType ty, PrimMonad prim) => MutableByteArray# (PrimState prim) -> Offset ty -> prim ty
    primMbaRead mba ofs
        | mbaCheck mba ofs = boundCheckError "mutablebytearray-read" ofs (mbaLength ofs mba)
        | otherwise        = primMbaURead mba ofs
    {-# NOINLINE primMbaRead #-}

    primMbaWrite :: (PrimType ty, PrimMonad prim) => MutableByteArray# (PrimState prim) -> Offset ty -> ty -> prim ()
    primMbaWrite mba ofs ty
        | mbaCheck mba ofs = boundCheckError "mutablebytearray-write" ofs (mbaLength ofs mba)
        | otherwise        = primMbaUWrite mba ofs ty
    {-# NOINLINE primMbaWrite #-}

    primArrayIndex :: Array# ty -> Offset ty -> ty
    primArrayIndex a o@(Offset (I# ofs))
        | aCheck a o = boundCheckError "array-index" o (aLength a)
        | otherwise  = let !(# v #) = indexArray# a ofs in v
    {-# NOINLINE primArrayIndex #-}

    primMutableArrayRead :: PrimMonad prim => MutableArray# (PrimState prim) ty -> Offset ty -> prim ty
    primMutableArrayRead ma o@(Offset (I# ofs))
        | maCheck ma o = boundCheckError "array-read" o (maLength ma)
        | otherwise    = primitive $ \s1 -> readArray# ma ofs s1
    {-# NOINLINE primMutableArrayRead #-}

    primMutableArrayWrite :: PrimMonad prim => MutableArray# (PrimState prim) ty -> Offset ty -> ty -> prim ()
    primMutableArrayWrite ma o@(Offset (I# ofs)) v
        | maCheck ma o = boundCheckError "array-write" o (maLength ma)
        | otherwise    = primitive $ \s1 -> let !s2 = writeArray# ma ofs v s1 in (# s2, () #)
    {-# NOINLINE primMutableArrayWrite #-}

    #else

    primBaIndex :: PrimType ty => ByteArray# -> Offset ty -> ty
    primBaIndex :: forall ty. PrimType ty => ByteArray# -> Offset ty -> ty
    primBaIndex = ByteArray# -> Offset ty -> ty
    forall ty. PrimType ty => ByteArray# -> Offset ty -> ty
    primBaUIndex
    {-# INLINE primBaIndex #-}

    primMbaRead :: (PrimType ty, PrimMonad prim) => MutableByteArray# (PrimState prim) -> Offset ty -> prim ty
    primMbaRead :: forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    MutableByteArray# (PrimState prim) -> Offset ty -> prim ty
    primMbaRead = MutableByteArray# (PrimState prim) -> Offset ty -> prim ty
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    MutableByteArray# (PrimState prim) -> Offset ty -> prim ty
    forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset ty -> prim ty
    primMbaURead
    {-# INLINE primMbaRead #-}

    primMbaWrite :: (PrimType ty, PrimMonad prim) => MutableByteArray# (PrimState prim) -> Offset ty -> ty -> prim ()
    primMbaWrite :: forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    MutableByteArray# (PrimState prim) -> Offset ty -> ty -> prim ()
    primMbaWrite = MutableByteArray# (PrimState prim) -> Offset ty -> ty -> prim ()
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    MutableByteArray# (PrimState prim) -> Offset ty -> ty -> prim ()
    forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset ty -> ty -> prim ()
    primMbaUWrite
    {-# INLINE primMbaWrite #-}

    primArrayIndex :: Array# ty -> Offset ty -> ty
    primArrayIndex :: forall ty. Array# ty -> Offset ty -> ty
    primArrayIndex Array# ty
    a (Offset (I# Int#
    ofs)) = let !(# ty
    v #) = Array# ty -> Int# -> (# ty #)
    forall a. Array# a -> Int# -> (# a #)
    indexArray# Array# ty
    a Int#
    ofs in ty
    v
    {-# INLINE primArrayIndex #-}

    primMutableArrayRead :: PrimMonad prim => MutableArray# (PrimState prim) ty -> Offset ty -> prim ty
    primMutableArrayRead :: forall (prim :: * -> *) ty.
    PrimMonad prim =>
    MutableArray# (PrimState prim) ty -> Offset ty -> prim ty
    primMutableArrayRead MutableArray# (PrimState prim) ty
    ma (Offset (I# Int#
    ofs)) = (State# (PrimState prim) -> (# State# (PrimState prim), ty #))
    -> prim ty
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), ty #))
     -> prim ty)
    -> (State# (PrimState prim) -> (# State# (PrimState prim), ty #))
    -> prim ty
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> MutableArray# (PrimState prim) ty
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), ty #)
    forall d a.
    MutableArray# d a -> Int# -> State# d -> (# State# d, a #)
    readArray# MutableArray# (PrimState prim) ty
    ma Int#
    ofs State# (PrimState prim)
    s1
    {-# INLINE primMutableArrayRead #-}

    primMutableArrayWrite :: PrimMonad prim => MutableArray# (PrimState prim) ty -> Offset ty -> ty -> prim ()
    primMutableArrayWrite :: forall (prim :: * -> *) ty.
    PrimMonad prim =>
    MutableArray# (PrimState prim) ty -> Offset ty -> ty -> prim ()
    primMutableArrayWrite MutableArray# (PrimState prim) ty
    ma (Offset (I# Int#
    ofs)) ty
    v =
        (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !s2 :: State# (PrimState prim)
    s2 = MutableArray# (PrimState prim) ty
    -> Int# -> ty -> State# (PrimState prim) -> State# (PrimState prim)
    forall d a. MutableArray# d a -> Int# -> a -> State# d -> State# d
    writeArray# MutableArray# (PrimState prim) ty
    ma Int#
    ofs ty
    v State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, () #)
    {-# INLINE primMutableArrayWrite #-}

    #endif

    -- | Represent the accessor for types that can be stored in the UArray and MUArray.
    --
    -- Types need to be a instance of storable and have fixed sized.
    class Eq ty => PrimType ty where
        -- | type level size of the given `ty`
        type PrimSize ty :: Nat

        -- | get the size in bytes of a ty element
        primSizeInBytes :: Proxy ty -> CountOf Word8

        -- | get the shift size
        primShiftToBytes :: Proxy ty -> Int

        -----
        -- ByteArray section
        -----

        -- | return the element stored at a specific index
        primBaUIndex :: ByteArray# -> Offset ty -> ty

        -----
        -- MutableByteArray section
        -----

        -- | Read an element at an index in a mutable array
        primMbaURead :: PrimMonad prim
                    => MutableByteArray# (PrimState prim) -- ^ mutable array to read from
                    -> Offset ty                         -- ^ index of the element to retrieve
                    -> prim ty                           -- ^ the element returned

        -- | Write an element to a specific cell in a mutable array.
        primMbaUWrite :: PrimMonad prim
                     => MutableByteArray# (PrimState prim) -- ^ mutable array to modify
                     -> Offset ty                         -- ^ index of the element to modify
                     -> ty                                 -- ^ the new value to store
                     -> prim ()

        -----
        -- Addr# section
        -----

        -- | Read from Address, without a state. the value read should be considered a constant for all
        -- pratical purpose, otherwise bad thing will happens.
        primAddrIndex :: Addr# -> Offset ty -> ty

        -- | Read a value from Addr in a specific primitive monad
        primAddrRead :: PrimMonad prim
                     => Addr#
                     -> Offset ty
                     -> prim ty
        -- | Write a value to Addr in a specific primitive monad
        primAddrWrite :: PrimMonad prim
                      => Addr#
                      -> Offset ty
                      -> ty
                      -> prim ()

    sizeInt, sizeWord :: CountOf Word8
    shiftInt, shiftWord :: Int
    #if WORD_SIZE_IN_BITS == 64
    sizeInt :: CountOf Word8
    sizeInt = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    8
    sizeWord :: CountOf Word8
    sizeWord = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    8
    shiftInt :: Int
    shiftInt = Int
    3
    shiftWord :: Int
    shiftWord = Int
    3
    #else
    sizeInt = CountOf 4
    sizeWord = CountOf 4
    shiftInt = 2
    shiftWord = 2
    #endif

    {-# SPECIALIZE [3] primBaUIndex :: ByteArray# -> Offset Word8 -> Word8 #-}

    instance PrimType Int where
    #if WORD_SIZE_IN_BITS == 64
        type PrimSize Int = 8
    #else
        type PrimSize Int = 4
    #endif
        primSizeInBytes :: Proxy Int -> CountOf Word8
    primSizeInBytes Proxy Int
    _ = CountOf Word8
    sizeInt
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Int -> Int
    primShiftToBytes Proxy Int
    _ = Int
    shiftInt
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Int -> Int
    primBaUIndex ByteArray#
    ba (Offset (I# Int#
    n)) = Int# -> Int
    I# (ByteArray# -> Int# -> Int#
    indexIntArray# ByteArray#
    ba Int#
    n)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Int -> prim Int
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Int #))
    -> prim Int
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Int #))
     -> prim Int)
    -> (State# (PrimState prim) -> (# State# (PrimState prim), Int #))
    -> prim Int
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Int#
    r #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Int# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
    readIntArray# MutableByteArray# (PrimState prim)
    mba Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Int# -> Int
    I# Int#
    r #)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Int -> Int -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) (I# Int#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Int#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
    writeIntArray# MutableByteArray# (PrimState prim)
    mba Int#
    n Int#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Int -> Int
    primAddrIndex Addr#
    addr (Offset (I# Int#
    n)) = Int# -> Int
    I# (Addr# -> Int# -> Int#
    indexIntOffAddr# Addr#
    addr Int#
    n)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Int -> prim Int
    primAddrRead Addr#
    addr (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Int #))
    -> prim Int
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Int #))
     -> prim Int)
    -> (State# (PrimState prim) -> (# State# (PrimState prim), Int #))
    -> prim Int
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Int#
    r #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Int# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Int# #)
    readIntOffAddr# Addr#
    addr Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Int# -> Int
    I# Int#
    r #)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Int -> Int -> prim ()
    primAddrWrite Addr#
    addr (Offset (I# Int#
    n)) (I# Int#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# Addr#
    -> Int#
    -> Int#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Int# -> State# d -> State# d
    writeIntOffAddr# Addr#
    addr Int#
    n Int#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primAddrWrite #-}

    instance PrimType Word where
    #if WORD_SIZE_IN_BITS == 64
        type PrimSize Word = 8
    #else
        type PrimSize Word = 4
    #endif
        primSizeInBytes :: Proxy Word -> CountOf Word8
    primSizeInBytes Proxy Word
    _ = CountOf Word8
    sizeWord
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Word -> Int
    primShiftToBytes Proxy Word
    _ = Int
    shiftWord
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Word -> Word
    primBaUIndex ByteArray#
    ba (Offset (I# Int#
    n)) = Word# -> Word
    W# (ByteArray# -> Int# -> Word#
    indexWordArray# ByteArray#
    ba Int#
    n)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Word -> prim Word
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Word #))
    -> prim Word
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Word #))
     -> prim Word)
    -> (State# (PrimState prim) -> (# State# (PrimState prim), Word #))
    -> prim Word
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Word#
    r #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)
    readWordArray# MutableByteArray# (PrimState prim)
    mba Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Word# -> Word
    W# Word#
    r #)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Word -> Word -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) (W# Word#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Word#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Word# -> State# d -> State# d
    writeWordArray# MutableByteArray# (PrimState prim)
    mba Int#
    n Word#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Word -> Word
    primAddrIndex Addr#
    addr (Offset (I# Int#
    n)) = Word# -> Word
    W# (Addr# -> Int# -> Word#
    indexWordOffAddr# Addr#
    addr Int#
    n)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word -> prim Word
    primAddrRead Addr#
    addr (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Word #))
    -> prim Word
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Word #))
     -> prim Word)
    -> (State# (PrimState prim) -> (# State# (PrimState prim), Word #))
    -> prim Word
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Word#
    r #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Word# #)
    readWordOffAddr# Addr#
    addr Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Word# -> Word
    W# Word#
    r #)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word -> Word -> prim ()
    primAddrWrite Addr#
    addr (Offset (I# Int#
    n)) (W# Word#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# Addr#
    -> Int#
    -> Word#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Word# -> State# d -> State# d
    writeWordOffAddr# Addr#
    addr Int#
    n Word#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primAddrWrite #-}

    instance PrimType Word8 where
        type PrimSize Word8 = 1
        primSizeInBytes :: Proxy Word8 -> CountOf Word8
    primSizeInBytes Proxy Word8
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    1
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Word8 -> Int
    primShiftToBytes Proxy Word8
    _ = Int
    0
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Word8 -> Word8
    primBaUIndex ByteArray#
    ba (Offset (I# Int#
    n)) = Word8# -> Word8
    W8# (ByteArray# -> Int# -> Word8#
    indexWord8Array# ByteArray#
    ba Int#
    n)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Word8 -> prim Word8
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Word8 #))
    -> prim Word8
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Word8 #))
     -> prim Word8)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Word8 #))
    -> prim Word8
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Word8#
    r #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word8# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Word8# #)
    readWord8Array# MutableByteArray# (PrimState prim)
    mba Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Word8# -> Word8
    W8# Word8#
    r #)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Word8 -> Word8 -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) (W8# Word8#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Word8#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Word8# -> State# d -> State# d
    writeWord8Array# MutableByteArray# (PrimState prim)
    mba Int#
    n Word8#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Word8 -> Word8
    primAddrIndex Addr#
    addr (Offset (I# Int#
    n)) = Word8# -> Word8
    W8# (Addr# -> Int# -> Word8#
    indexWord8OffAddr# Addr#
    addr Int#
    n)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word8 -> prim Word8
    primAddrRead Addr#
    addr (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Word8 #))
    -> prim Word8
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Word8 #))
     -> prim Word8)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Word8 #))
    -> prim Word8
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Word8#
    r #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word8# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Word8# #)
    readWord8OffAddr# Addr#
    addr Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Word8# -> Word8
    W8# Word8#
    r #)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word8 -> Word8 -> prim ()
    primAddrWrite Addr#
    addr (Offset (I# Int#
    n)) (W8# Word8#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# Addr#
    -> Int#
    -> Word8#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Word8# -> State# d -> State# d
    writeWord8OffAddr# Addr#
    addr Int#
    n Word8#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primAddrWrite #-}

    instance PrimType Word16 where
        type PrimSize Word16 = 2
        primSizeInBytes :: Proxy Word16 -> CountOf Word8
    primSizeInBytes Proxy Word16
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    2
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Word16 -> Int
    primShiftToBytes Proxy Word16
    _ = Int
    1
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Word16 -> Word16
    primBaUIndex ByteArray#
    ba (Offset (I# Int#
    n)) = Word16# -> Word16
    W16# (ByteArray# -> Int# -> Word16#
    indexWord16Array# ByteArray#
    ba Int#
    n)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Word16 -> prim Word16
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Word16 #))
    -> prim Word16
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Word16 #))
     -> prim Word16)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Word16 #))
    -> prim Word16
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Word16#
    r #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word16# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Word16# #)
    readWord16Array# MutableByteArray# (PrimState prim)
    mba Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Word16# -> Word16
    W16# Word16#
    r #)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Word16 -> Word16 -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) (W16# Word16#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Word16#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Word16# -> State# d -> State# d
    writeWord16Array# MutableByteArray# (PrimState prim)
    mba Int#
    n Word16#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Word16 -> Word16
    primAddrIndex Addr#
    addr (Offset (I# Int#
    n)) = Word16# -> Word16
    W16# (Addr# -> Int# -> Word16#
    indexWord16OffAddr# Addr#
    addr Int#
    n)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word16 -> prim Word16
    primAddrRead Addr#
    addr (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Word16 #))
    -> prim Word16
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Word16 #))
     -> prim Word16)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Word16 #))
    -> prim Word16
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Word16#
    r #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word16# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Word16# #)
    readWord16OffAddr# Addr#
    addr Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Word16# -> Word16
    W16# Word16#
    r #)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word16 -> Word16 -> prim ()
    primAddrWrite Addr#
    addr (Offset (I# Int#
    n)) (W16# Word16#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# Addr#
    -> Int#
    -> Word16#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Word16# -> State# d -> State# d
    writeWord16OffAddr# Addr#
    addr Int#
    n Word16#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primAddrWrite #-}
    instance PrimType Word32 where
        type PrimSize Word32 = 4
        primSizeInBytes :: Proxy Word32 -> CountOf Word8
    primSizeInBytes Proxy Word32
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    4
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Word32 -> Int
    primShiftToBytes Proxy Word32
    _ = Int
    2
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Word32 -> Word32
    primBaUIndex ByteArray#
    ba (Offset (I# Int#
    n)) = Word32# -> Word32
    W32# (ByteArray# -> Int# -> Word32#
    indexWord32Array# ByteArray#
    ba Int#
    n)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Word32 -> prim Word32
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Word32 #))
    -> prim Word32
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Word32 #))
     -> prim Word32)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Word32 #))
    -> prim Word32
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Word32#
    r #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word32# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Word32# #)
    readWord32Array# MutableByteArray# (PrimState prim)
    mba Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Word32# -> Word32
    W32# Word32#
    r #)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Word32 -> Word32 -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) (W32# Word32#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Word32#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Word32# -> State# d -> State# d
    writeWord32Array# MutableByteArray# (PrimState prim)
    mba Int#
    n Word32#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Word32 -> Word32
    primAddrIndex Addr#
    addr (Offset (I# Int#
    n)) = Word32# -> Word32
    W32# (Addr# -> Int# -> Word32#
    indexWord32OffAddr# Addr#
    addr Int#
    n)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word32 -> prim Word32
    primAddrRead Addr#
    addr (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Word32 #))
    -> prim Word32
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Word32 #))
     -> prim Word32)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Word32 #))
    -> prim Word32
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Word32#
    r #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word32# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Word32# #)
    readWord32OffAddr# Addr#
    addr Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Word32# -> Word32
    W32# Word32#
    r #)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word32 -> Word32 -> prim ()
    primAddrWrite Addr#
    addr (Offset (I# Int#
    n)) (W32# Word32#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# Addr#
    -> Int#
    -> Word32#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Word32# -> State# d -> State# d
    writeWord32OffAddr# Addr#
    addr Int#
    n Word32#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primAddrWrite #-}
    instance PrimType Word64 where
        type PrimSize Word64 = 8
        primSizeInBytes :: Proxy Word64 -> CountOf Word8
    primSizeInBytes Proxy Word64
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    8
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Word64 -> Int
    primShiftToBytes Proxy Word64
    _ = Int
    3
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Word64 -> Word64
    primBaUIndex ByteArray#
    ba (Offset (I# Int#
    n)) = Word64# -> Word64
    W64# (ByteArray# -> Int# -> Word64#
    indexWord64Array# ByteArray#
    ba Int#
    n)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Word64 -> prim Word64
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Word64 #))
    -> prim Word64
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Word64 #))
     -> prim Word64)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Word64 #))
    -> prim Word64
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Word64#
    r #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word64# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64# #)
    readWord64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Word64# -> Word64
    W64# Word64#
    r #)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Word64 -> Word64 -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) (W64# Word64#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Word64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Word64# -> State# d -> State# d
    writeWord64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n Word64#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Word64 -> Word64
    primAddrIndex Addr#
    addr (Offset (I# Int#
    n)) = Word64# -> Word64
    W64# (Addr# -> Int# -> Word64#
    indexWord64OffAddr# Addr#
    addr Int#
    n)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word64 -> prim Word64
    primAddrRead Addr#
    addr (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Word64 #))
    -> prim Word64
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Word64 #))
     -> prim Word64)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Word64 #))
    -> prim Word64
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Word64#
    r #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word64# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Word64# #)
    readWord64OffAddr# Addr#
    addr Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Word64# -> Word64
    W64# Word64#
    r #)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word64 -> Word64 -> prim ()
    primAddrWrite Addr#
    addr (Offset (I# Int#
    n)) (W64# Word64#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# Addr#
    -> Int#
    -> Word64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Word64# -> State# d -> State# d
    writeWord64OffAddr# Addr#
    addr Int#
    n Word64#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primAddrWrite #-}
    instance PrimType Word128 where
        type PrimSize Word128 = 16
        primSizeInBytes :: Proxy Word128 -> CountOf Word8
    primSizeInBytes Proxy Word128
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    16
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Word128 -> Int
    primShiftToBytes Proxy Word128
    _ = Int
    4
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Word128 -> Word128
    primBaUIndex ByteArray#
    ba Offset Word128
    n =
            Word64 -> Word64 -> Word128
    Word128 (Word64# -> Word64
    W64# (ByteArray# -> Int# -> Word64#
    indexWord64Array# ByteArray#
    ba Int#
    n1)) (Word64# -> Word64
    W64# (ByteArray# -> Int# -> Word64#
    indexWord64Array# ByteArray#
    ba Int#
    n2))
          where (# Int#
    n1, Int#
    n2 #) = Offset Word128 -> (# Int#, Int# #)
    offset128_64 Offset Word128
    n
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Word128 -> prim Word128
    primMbaURead MutableByteArray# (PrimState prim)
    mba Offset Word128
    n = (State# (PrimState prim) -> (# State# (PrimState prim), Word128 #))
    -> prim Word128
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim)
      -> (# State# (PrimState prim), Word128 #))
     -> prim Word128)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Word128 #))
    -> prim Word128
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Word64#
    r1 #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word64# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64# #)
    readWord64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n1 State# (PrimState prim)
    s1
                                                    !(# State# (PrimState prim)
    s3, Word64#
    r2 #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word64# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64# #)
    readWord64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n2 State# (PrimState prim)
    s2
                                                 in (# State# (PrimState prim)
    s3, Word64 -> Word64 -> Word128
    Word128 (Word64# -> Word64
    W64# Word64#
    r1) (Word64# -> Word64
    W64# Word64#
    r2) #)
          where (# Int#
    n1, Int#
    n2 #) = Offset Word128 -> (# Int#, Int# #)
    offset128_64 Offset Word128
    n
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Word128 -> Word128 -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba Offset Word128
    n (Word128 (W64# Word64#
    w1) (W64# Word64#
    w2)) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 ->
            let !s2 :: State# (PrimState prim)
    s2 = MutableByteArray# (PrimState prim)
    -> Int#
    -> Word64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Word64# -> State# d -> State# d
    writeWord64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n1 Word64#
    w1 State# (PrimState prim)
    s1
             in (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Word64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Word64# -> State# d -> State# d
    writeWord64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n2 Word64#
    w2 State# (PrimState prim)
    s2, () #)
          where (# Int#
    n1, Int#
    n2 #) = Offset Word128 -> (# Int#, Int# #)
    offset128_64 Offset Word128
    n
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Word128 -> Word128
    primAddrIndex Addr#
    addr Offset Word128
    n = Word64 -> Word64 -> Word128
    Word128 (Word64# -> Word64
    W64# (Addr# -> Int# -> Word64#
    indexWord64OffAddr# Addr#
    addr Int#
    n1)) (Word64# -> Word64
    W64# (Addr# -> Int# -> Word64#
    indexWord64OffAddr# Addr#
    addr Int#
    n2))
          where (# Int#
    n1, Int#
    n2 #) = Offset Word128 -> (# Int#, Int# #)
    offset128_64 Offset Word128
    n
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word128 -> prim Word128
    primAddrRead Addr#
    addr Offset Word128
    n = (State# (PrimState prim) -> (# State# (PrimState prim), Word128 #))
    -> prim Word128
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim)
      -> (# State# (PrimState prim), Word128 #))
     -> prim Word128)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Word128 #))
    -> prim Word128
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Word64#
    r1 #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word64# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Word64# #)
    readWord64OffAddr# Addr#
    addr Int#
    n1 State# (PrimState prim)
    s1
                                                     !(# State# (PrimState prim)
    s3, Word64#
    r2 #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word64# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Word64# #)
    readWord64OffAddr# Addr#
    addr Int#
    n2 State# (PrimState prim)
    s2
                                                  in (# State# (PrimState prim)
    s3, Word64 -> Word64 -> Word128
    Word128 (Word64# -> Word64
    W64# Word64#
    r1) (Word64# -> Word64
    W64# Word64#
    r2) #)
          where (# Int#
    n1, Int#
    n2 #) = Offset Word128 -> (# Int#, Int# #)
    offset128_64 Offset Word128
    n
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word128 -> Word128 -> prim ()
    primAddrWrite Addr#
    addr Offset Word128
    n (Word128 (W64# Word64#
    w1) (W64# Word64#
    w2)) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 ->
            let !s2 :: State# (PrimState prim)
    s2 = Addr#
    -> Int#
    -> Word64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Word64# -> State# d -> State# d
    writeWord64OffAddr# Addr#
    addr Int#
    n1 Word64#
    w1 State# (PrimState prim)
    s1
             in (# Addr#
    -> Int#
    -> Word64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Word64# -> State# d -> State# d
    writeWord64OffAddr# Addr#
    addr Int#
    n2 Word64#
    w2 State# (PrimState prim)
    s2, () #)
          where (# Int#
    n1, Int#
    n2 #) = Offset Word128 -> (# Int#, Int# #)
    offset128_64 Offset Word128
    n
        {-# INLINE primAddrWrite #-}
    instance PrimType Word256 where
        type PrimSize Word256 = 32
        primSizeInBytes :: Proxy Word256 -> CountOf Word8
    primSizeInBytes Proxy Word256
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    32
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Word256 -> Int
    primShiftToBytes Proxy Word256
    _ = Int
    5
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Word256 -> Word256
    primBaUIndex ByteArray#
    ba Offset Word256
    n =
            Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 (Word64# -> Word64
    W64# (ByteArray# -> Int# -> Word64#
    indexWord64Array# ByteArray#
    ba Int#
    n1)) (Word64# -> Word64
    W64# (ByteArray# -> Int# -> Word64#
    indexWord64Array# ByteArray#
    ba Int#
    n2))
                    (Word64# -> Word64
    W64# (ByteArray# -> Int# -> Word64#
    indexWord64Array# ByteArray#
    ba Int#
    n3)) (Word64# -> Word64
    W64# (ByteArray# -> Int# -> Word64#
    indexWord64Array# ByteArray#
    ba Int#
    n4))
          where (# Int#
    n1, Int#
    n2, Int#
    n3, Int#
    n4 #) = Offset Word256 -> (# Int#, Int#, Int#, Int# #)
    offset256_64 Offset Word256
    n
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Word256 -> prim Word256
    primMbaURead MutableByteArray# (PrimState prim)
    mba Offset Word256
    n = (State# (PrimState prim) -> (# State# (PrimState prim), Word256 #))
    -> prim Word256
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim)
      -> (# State# (PrimState prim), Word256 #))
     -> prim Word256)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Word256 #))
    -> prim Word256
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Word64#
    r1 #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word64# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64# #)
    readWord64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n1 State# (PrimState prim)
    s1
                                                    !(# State# (PrimState prim)
    s3, Word64#
    r2 #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word64# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64# #)
    readWord64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n2 State# (PrimState prim)
    s2
                                                    !(# State# (PrimState prim)
    s4, Word64#
    r3 #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word64# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64# #)
    readWord64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n3 State# (PrimState prim)
    s3
                                                    !(# State# (PrimState prim)
    s5, Word64#
    r4 #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word64# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64# #)
    readWord64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n4 State# (PrimState prim)
    s4
                                                 in (# State# (PrimState prim)
    s5, Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 (Word64# -> Word64
    W64# Word64#
    r1) (Word64# -> Word64
    W64# Word64#
    r2) (Word64# -> Word64
    W64# Word64#
    r3) (Word64# -> Word64
    W64# Word64#
    r4) #)
          where (# Int#
    n1, Int#
    n2, Int#
    n3, Int#
    n4 #) = Offset Word256 -> (# Int#, Int#, Int#, Int# #)
    offset256_64 Offset Word256
    n
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Word256 -> Word256 -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba Offset Word256
    n (Word256 (W64# Word64#
    w1) (W64# Word64#
    w2) (W64# Word64#
    w3) (W64# Word64#
    w4)) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 ->
            let !s2 :: State# (PrimState prim)
    s2 = MutableByteArray# (PrimState prim)
    -> Int#
    -> Word64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Word64# -> State# d -> State# d
    writeWord64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n1 Word64#
    w1 State# (PrimState prim)
    s1
                !s3 :: State# (PrimState prim)
    s3 = MutableByteArray# (PrimState prim)
    -> Int#
    -> Word64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Word64# -> State# d -> State# d
    writeWord64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n2 Word64#
    w2 State# (PrimState prim)
    s2
                !s4 :: State# (PrimState prim)
    s4 = MutableByteArray# (PrimState prim)
    -> Int#
    -> Word64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Word64# -> State# d -> State# d
    writeWord64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n3 Word64#
    w3 State# (PrimState prim)
    s3
             in (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Word64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Word64# -> State# d -> State# d
    writeWord64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n4 Word64#
    w4 State# (PrimState prim)
    s4, () #)
          where (# Int#
    n1, Int#
    n2, Int#
    n3, Int#
    n4 #) = Offset Word256 -> (# Int#, Int#, Int#, Int# #)
    offset256_64 Offset Word256
    n
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Word256 -> Word256
    primAddrIndex Addr#
    addr Offset Word256
    n = Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 (Word64# -> Word64
    W64# (Addr# -> Int# -> Word64#
    indexWord64OffAddr# Addr#
    addr Int#
    n1)) (Word64# -> Word64
    W64# (Addr# -> Int# -> Word64#
    indexWord64OffAddr# Addr#
    addr Int#
    n2))
                                       (Word64# -> Word64
    W64# (Addr# -> Int# -> Word64#
    indexWord64OffAddr# Addr#
    addr Int#
    n3)) (Word64# -> Word64
    W64# (Addr# -> Int# -> Word64#
    indexWord64OffAddr# Addr#
    addr Int#
    n4))
          where (# Int#
    n1, Int#
    n2, Int#
    n3, Int#
    n4 #) = Offset Word256 -> (# Int#, Int#, Int#, Int# #)
    offset256_64 Offset Word256
    n
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word256 -> prim Word256
    primAddrRead Addr#
    addr Offset Word256
    n = (State# (PrimState prim) -> (# State# (PrimState prim), Word256 #))
    -> prim Word256
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim)
      -> (# State# (PrimState prim), Word256 #))
     -> prim Word256)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Word256 #))
    -> prim Word256
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Word64#
    r1 #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word64# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Word64# #)
    readWord64OffAddr# Addr#
    addr Int#
    n1 State# (PrimState prim)
    s1
                                                     !(# State# (PrimState prim)
    s3, Word64#
    r2 #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word64# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Word64# #)
    readWord64OffAddr# Addr#
    addr Int#
    n2 State# (PrimState prim)
    s2
                                                     !(# State# (PrimState prim)
    s4, Word64#
    r3 #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word64# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Word64# #)
    readWord64OffAddr# Addr#
    addr Int#
    n3 State# (PrimState prim)
    s3
                                                     !(# State# (PrimState prim)
    s5, Word64#
    r4 #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Word64# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Word64# #)
    readWord64OffAddr# Addr#
    addr Int#
    n4 State# (PrimState prim)
    s4
                                                  in (# State# (PrimState prim)
    s5, Word64 -> Word64 -> Word64 -> Word64 -> Word256
    Word256 (Word64# -> Word64
    W64# Word64#
    r1) (Word64# -> Word64
    W64# Word64#
    r2) (Word64# -> Word64
    W64# Word64#
    r3) (Word64# -> Word64
    W64# Word64#
    r4) #)
          where (# Int#
    n1, Int#
    n2, Int#
    n3, Int#
    n4 #) = Offset Word256 -> (# Int#, Int#, Int#, Int# #)
    offset256_64 Offset Word256
    n
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word256 -> Word256 -> prim ()
    primAddrWrite Addr#
    addr Offset Word256
    n (Word256 (W64# Word64#
    w1) (W64# Word64#
    w2) (W64# Word64#
    w3) (W64# Word64#
    w4)) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 ->
            let !s2 :: State# (PrimState prim)
    s2 = Addr#
    -> Int#
    -> Word64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Word64# -> State# d -> State# d
    writeWord64OffAddr# Addr#
    addr Int#
    n1 Word64#
    w1 State# (PrimState prim)
    s1
                !s3 :: State# (PrimState prim)
    s3 = Addr#
    -> Int#
    -> Word64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Word64# -> State# d -> State# d
    writeWord64OffAddr# Addr#
    addr Int#
    n2 Word64#
    w2 State# (PrimState prim)
    s2
                !s4 :: State# (PrimState prim)
    s4 = Addr#
    -> Int#
    -> Word64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Word64# -> State# d -> State# d
    writeWord64OffAddr# Addr#
    addr Int#
    n3 Word64#
    w3 State# (PrimState prim)
    s3
             in (# Addr#
    -> Int#
    -> Word64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Word64# -> State# d -> State# d
    writeWord64OffAddr# Addr#
    addr Int#
    n4 Word64#
    w4 State# (PrimState prim)
    s4, () #)
          where (# Int#
    n1, Int#
    n2, Int#
    n3, Int#
    n4 #) = Offset Word256 -> (# Int#, Int#, Int#, Int# #)
    offset256_64 Offset Word256
    n
        {-# INLINE primAddrWrite #-}
    instance PrimType Int8 where
        type PrimSize Int8 = 1
        primSizeInBytes :: Proxy Int8 -> CountOf Word8
    primSizeInBytes Proxy Int8
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    1
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Int8 -> Int
    primShiftToBytes Proxy Int8
    _ = Int
    0
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Int8 -> Int8
    primBaUIndex ByteArray#
    ba (Offset (I# Int#
    n)) = Int8# -> Int8
    I8# (ByteArray# -> Int# -> Int8#
    indexInt8Array# ByteArray#
    ba Int#
    n)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Int8 -> prim Int8
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Int8 #))
    -> prim Int8
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Int8 #))
     -> prim Int8)
    -> (State# (PrimState prim) -> (# State# (PrimState prim), Int8 #))
    -> prim Int8
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Int8#
    r #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Int8# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Int8# #)
    readInt8Array# MutableByteArray# (PrimState prim)
    mba Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Int8# -> Int8
    I8# Int8#
    r #)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Int8 -> Int8 -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) (I8# Int8#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Int8#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Int8# -> State# d -> State# d
    writeInt8Array# MutableByteArray# (PrimState prim)
    mba Int#
    n Int8#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Int8 -> Int8
    primAddrIndex Addr#
    addr (Offset (I# Int#
    n)) = Int8# -> Int8
    I8# (Addr# -> Int# -> Int8#
    indexInt8OffAddr# Addr#
    addr Int#
    n)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Int8 -> prim Int8
    primAddrRead Addr#
    addr (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Int8 #))
    -> prim Int8
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Int8 #))
     -> prim Int8)
    -> (State# (PrimState prim) -> (# State# (PrimState prim), Int8 #))
    -> prim Int8
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Int8#
    r #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Int8# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Int8# #)
    readInt8OffAddr# Addr#
    addr Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Int8# -> Int8
    I8# Int8#
    r #)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Int8 -> Int8 -> prim ()
    primAddrWrite Addr#
    addr (Offset (I# Int#
    n)) (I8# Int8#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# Addr#
    -> Int#
    -> Int8#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Int8# -> State# d -> State# d
    writeInt8OffAddr# Addr#
    addr Int#
    n Int8#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primAddrWrite #-}
    instance PrimType Int16 where
        type PrimSize Int16 = 2
        primSizeInBytes :: Proxy Int16 -> CountOf Word8
    primSizeInBytes Proxy Int16
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    2
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Int16 -> Int
    primShiftToBytes Proxy Int16
    _ = Int
    1
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Int16 -> Int16
    primBaUIndex ByteArray#
    ba (Offset (I# Int#
    n)) = Int16# -> Int16
    I16# (ByteArray# -> Int# -> Int16#
    indexInt16Array# ByteArray#
    ba Int#
    n)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Int16 -> prim Int16
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Int16 #))
    -> prim Int16
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Int16 #))
     -> prim Int16)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Int16 #))
    -> prim Int16
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Int16#
    r #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Int16# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Int16# #)
    readInt16Array# MutableByteArray# (PrimState prim)
    mba Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Int16# -> Int16
    I16# Int16#
    r #)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Int16 -> Int16 -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) (I16# Int16#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Int16#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Int16# -> State# d -> State# d
    writeInt16Array# MutableByteArray# (PrimState prim)
    mba Int#
    n Int16#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Int16 -> Int16
    primAddrIndex Addr#
    addr (Offset (I# Int#
    n)) = Int16# -> Int16
    I16# (Addr# -> Int# -> Int16#
    indexInt16OffAddr# Addr#
    addr Int#
    n)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Int16 -> prim Int16
    primAddrRead Addr#
    addr (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Int16 #))
    -> prim Int16
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Int16 #))
     -> prim Int16)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Int16 #))
    -> prim Int16
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Int16#
    r #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Int16# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Int16# #)
    readInt16OffAddr# Addr#
    addr Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Int16# -> Int16
    I16# Int16#
    r #)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Int16 -> Int16 -> prim ()
    primAddrWrite Addr#
    addr (Offset (I# Int#
    n)) (I16# Int16#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# Addr#
    -> Int#
    -> Int16#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Int16# -> State# d -> State# d
    writeInt16OffAddr# Addr#
    addr Int#
    n Int16#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primAddrWrite #-}
    instance PrimType Int32 where
        type PrimSize Int32 = 4
        primSizeInBytes :: Proxy Int32 -> CountOf Word8
    primSizeInBytes Proxy Int32
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    4
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Int32 -> Int
    primShiftToBytes Proxy Int32
    _ = Int
    2
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Int32 -> Int32
    primBaUIndex ByteArray#
    ba (Offset (I# Int#
    n)) = Int32# -> Int32
    I32# (ByteArray# -> Int# -> Int32#
    indexInt32Array# ByteArray#
    ba Int#
    n)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Int32 -> prim Int32
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Int32 #))
    -> prim Int32
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Int32 #))
     -> prim Int32)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Int32 #))
    -> prim Int32
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Int32#
    r #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Int32# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Int32# #)
    readInt32Array# MutableByteArray# (PrimState prim)
    mba Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Int32# -> Int32
    I32# Int32#
    r #)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Int32 -> Int32 -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) (I32# Int32#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Int32#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Int32# -> State# d -> State# d
    writeInt32Array# MutableByteArray# (PrimState prim)
    mba Int#
    n Int32#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Int32 -> Int32
    primAddrIndex Addr#
    addr (Offset (I# Int#
    n)) = Int32# -> Int32
    I32# (Addr# -> Int# -> Int32#
    indexInt32OffAddr# Addr#
    addr Int#
    n)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Int32 -> prim Int32
    primAddrRead Addr#
    addr (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Int32 #))
    -> prim Int32
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Int32 #))
     -> prim Int32)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Int32 #))
    -> prim Int32
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Int32#
    r #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Int32# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Int32# #)
    readInt32OffAddr# Addr#
    addr Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Int32# -> Int32
    I32# Int32#
    r #)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Int32 -> Int32 -> prim ()
    primAddrWrite Addr#
    addr (Offset (I# Int#
    n)) (I32# Int32#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# Addr#
    -> Int#
    -> Int32#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Int32# -> State# d -> State# d
    writeInt32OffAddr# Addr#
    addr Int#
    n Int32#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primAddrWrite #-}
    instance PrimType Int64 where
        type PrimSize Int64 = 8
        primSizeInBytes :: Proxy Int64 -> CountOf Word8
    primSizeInBytes Proxy Int64
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    8
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Int64 -> Int
    primShiftToBytes Proxy Int64
    _ = Int
    3
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Int64 -> Int64
    primBaUIndex ByteArray#
    ba (Offset (I# Int#
    n)) = Int64# -> Int64
    I64# (ByteArray# -> Int# -> Int64#
    indexInt64Array# ByteArray#
    ba Int#
    n)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Int64 -> prim Int64
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Int64 #))
    -> prim Int64
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Int64 #))
     -> prim Int64)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Int64 #))
    -> prim Int64
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Int64#
    r #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Int64# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Int64# #)
    readInt64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Int64# -> Int64
    I64# Int64#
    r #)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Int64 -> Int64 -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) (I64# Int64#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Int64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Int64# -> State# d -> State# d
    writeInt64Array# MutableByteArray# (PrimState prim)
    mba Int#
    n Int64#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Int64 -> Int64
    primAddrIndex Addr#
    addr (Offset (I# Int#
    n)) = Int64# -> Int64
    I64# (Addr# -> Int# -> Int64#
    indexInt64OffAddr# Addr#
    addr Int#
    n)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Int64 -> prim Int64
    primAddrRead Addr#
    addr (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Int64 #))
    -> prim Int64
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Int64 #))
     -> prim Int64)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Int64 #))
    -> prim Int64
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Int64#
    r #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Int64# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Int64# #)
    readInt64OffAddr# Addr#
    addr Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Int64# -> Int64
    I64# Int64#
    r #)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Int64 -> Int64 -> prim ()
    primAddrWrite Addr#
    addr (Offset (I# Int#
    n)) (I64# Int64#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# Addr#
    -> Int#
    -> Int64#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Int64# -> State# d -> State# d
    writeInt64OffAddr# Addr#
    addr Int#
    n Int64#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primAddrWrite #-}

    instance PrimType Float where
        type PrimSize Float = 4
        primSizeInBytes :: Proxy Float -> CountOf Word8
    primSizeInBytes Proxy Float
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    4
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Float -> Int
    primShiftToBytes Proxy Float
    _ = Int
    2
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Float -> Float
    primBaUIndex ByteArray#
    ba (Offset (I# Int#
    n)) = Float# -> Float
    F# (ByteArray# -> Int# -> Float#
    indexFloatArray# ByteArray#
    ba Int#
    n)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Float -> prim Float
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Float #))
    -> prim Float
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Float #))
     -> prim Float)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Float #))
    -> prim Float
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Float#
    r #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Float# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Float# #)
    readFloatArray# MutableByteArray# (PrimState prim)
    mba Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Float# -> Float
    F# Float#
    r #)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Float -> Float -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) (F# Float#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Float#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Float# -> State# d -> State# d
    writeFloatArray# MutableByteArray# (PrimState prim)
    mba Int#
    n Float#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Float -> Float
    primAddrIndex Addr#
    addr (Offset (I# Int#
    n)) = Float# -> Float
    F# (Addr# -> Int# -> Float#
    indexFloatOffAddr# Addr#
    addr Int#
    n)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Float -> prim Float
    primAddrRead Addr#
    addr (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Float #))
    -> prim Float
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Float #))
     -> prim Float)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Float #))
    -> prim Float
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Float#
    r #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Float# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Float# #)
    readFloatOffAddr# Addr#
    addr Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Float# -> Float
    F# Float#
    r #)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Float -> Float -> prim ()
    primAddrWrite Addr#
    addr (Offset (I# Int#
    n)) (F# Float#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# Addr#
    -> Int#
    -> Float#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Float# -> State# d -> State# d
    writeFloatOffAddr# Addr#
    addr Int#
    n Float#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primAddrWrite #-}
    instance PrimType Double where
        type PrimSize Double = 8
        primSizeInBytes :: Proxy Double -> CountOf Word8
    primSizeInBytes Proxy Double
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    8
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Double -> Int
    primShiftToBytes Proxy Double
    _ = Int
    3
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Double -> Double
    primBaUIndex ByteArray#
    ba (Offset (I# Int#
    n)) = Double# -> Double
    D# (ByteArray# -> Int# -> Double#
    indexDoubleArray# ByteArray#
    ba Int#
    n)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Double -> prim Double
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Double #))
    -> prim Double
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Double #))
     -> prim Double)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Double #))
    -> prim Double
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Double#
    r #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Double# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Double# #)
    readDoubleArray# MutableByteArray# (PrimState prim)
    mba Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Double# -> Double
    D# Double#
    r #)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Double -> Double -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) (D# Double#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Double#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Double# -> State# d -> State# d
    writeDoubleArray# MutableByteArray# (PrimState prim)
    mba Int#
    n Double#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Double -> Double
    primAddrIndex Addr#
    addr (Offset (I# Int#
    n)) = Double# -> Double
    D# (Addr# -> Int# -> Double#
    indexDoubleOffAddr# Addr#
    addr Int#
    n)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Double -> prim Double
    primAddrRead Addr#
    addr (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Double #))
    -> prim Double
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Double #))
     -> prim Double)
    -> (State# (PrimState prim)
        -> (# State# (PrimState prim), Double #))
    -> prim Double
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Double#
    r #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Double# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Double# #)
    readDoubleOffAddr# Addr#
    addr Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Double# -> Double
    D# Double#
    r #)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Double -> Double -> prim ()
    primAddrWrite Addr#
    addr (Offset (I# Int#
    n)) (D# Double#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# Addr#
    -> Int#
    -> Double#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Double# -> State# d -> State# d
    writeDoubleOffAddr# Addr#
    addr Int#
    n Double#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primAddrWrite #-}

    instance PrimType Char where
        type PrimSize Char = 4
        primSizeInBytes :: Proxy Char -> CountOf Word8
    primSizeInBytes Proxy Char
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    4
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Char -> Int
    primShiftToBytes Proxy Char
    _ = Int
    2
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Char -> Char
    primBaUIndex ByteArray#
    ba (Offset (I# Int#
    n)) = Char# -> Char
    C# (ByteArray# -> Int# -> Char#
    indexWideCharArray# ByteArray#
    ba Int#
    n)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Char -> prim Char
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Char #))
    -> prim Char
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Char #))
     -> prim Char)
    -> (State# (PrimState prim) -> (# State# (PrimState prim), Char #))
    -> prim Char
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Char#
    r #) = MutableByteArray# (PrimState prim)
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Char# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Char# #)
    readWideCharArray# MutableByteArray# (PrimState prim)
    mba Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Char# -> Char
    C# Char#
    r #)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Char -> Char -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset (I# Int#
    n)) (C# Char#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# MutableByteArray# (PrimState prim)
    -> Int#
    -> Char#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d.
    MutableByteArray# d -> Int# -> Char# -> State# d -> State# d
    writeWideCharArray# MutableByteArray# (PrimState prim)
    mba Int#
    n Char#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Char -> Char
    primAddrIndex Addr#
    addr (Offset (I# Int#
    n)) = Char# -> Char
    C# (Addr# -> Int# -> Char#
    indexWideCharOffAddr# Addr#
    addr Int#
    n)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Char -> prim Char
    primAddrRead Addr#
    addr (Offset (I# Int#
    n)) = (State# (PrimState prim) -> (# State# (PrimState prim), Char #))
    -> prim Char
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), Char #))
     -> prim Char)
    -> (State# (PrimState prim) -> (# State# (PrimState prim), Char #))
    -> prim Char
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> let !(# State# (PrimState prim)
    s2, Char#
    r #) = Addr#
    -> Int#
    -> State# (PrimState prim)
    -> (# State# (PrimState prim), Char# #)
    forall d. Addr# -> Int# -> State# d -> (# State# d, Char# #)
    readWideCharOffAddr# Addr#
    addr Int#
    n State# (PrimState prim)
    s1 in (# State# (PrimState prim)
    s2, Char# -> Char
    C# Char#
    r #)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Char -> Char -> prim ()
    primAddrWrite Addr#
    addr (Offset (I# Int#
    n)) (C# Char#
    w) = (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a.
    (State# (PrimState prim) -> (# State# (PrimState prim), a #))
    -> prim a
    forall (m :: * -> *) a.
    PrimMonad m =>
    (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
    primitive ((State# (PrimState prim) -> (# State# (PrimState prim), () #))
     -> prim ())
    -> (State# (PrimState prim) -> (# State# (PrimState prim), () #))
    -> prim ()
    forall a b. (a -> b) -> a -> b
    $ \State# (PrimState prim)
    s1 -> (# Addr#
    -> Int#
    -> Char#
    -> State# (PrimState prim)
    -> State# (PrimState prim)
    forall d. Addr# -> Int# -> Char# -> State# d -> State# d
    writeWideCharOffAddr# Addr#
    addr Int#
    n Char#
    w State# (PrimState prim)
    s1, () #)
        {-# INLINE primAddrWrite #-}

    instance PrimType CChar where
        type PrimSize CChar = 1
        primSizeInBytes :: Proxy CChar -> CountOf Word8
    primSizeInBytes Proxy CChar
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    1
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy CChar -> Int
    primShiftToBytes Proxy CChar
    _ = Int
    0
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset CChar -> CChar
    primBaUIndex ByteArray#
    ba (Offset Int
    n) = Int8 -> CChar
    CChar (ByteArray# -> Offset Int8 -> Int8
    forall ty. PrimType ty => ByteArray# -> Offset ty -> ty
    primBaUIndex ByteArray#
    ba (Int -> Offset Int8
    forall ty. Int -> Offset ty
    Offset Int
    n))
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset CChar -> prim CChar
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset Int
    n) = Int8 -> CChar
    CChar (Int8 -> CChar) -> prim Int8 -> prim CChar
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MutableByteArray# (PrimState prim) -> Offset Int8 -> prim Int8
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    MutableByteArray# (PrimState prim) -> Offset ty -> prim ty
    forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Int8 -> prim Int8
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Int -> Offset Int8
    forall ty. Int -> Offset ty
    Offset Int
    n)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset CChar -> CChar -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset Int
    n) (CChar Int8
    int8) = MutableByteArray# (PrimState prim)
    -> Offset Int8 -> Int8 -> prim ()
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    MutableByteArray# (PrimState prim) -> Offset ty -> ty -> prim ()
    forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Int8 -> Int8 -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Int -> Offset Int8
    forall ty. Int -> Offset ty
    Offset Int
    n) Int8
    int8
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset CChar -> CChar
    primAddrIndex Addr#
    addr (Offset Int
    n) = Int8 -> CChar
    CChar (Int8 -> CChar) -> Int8 -> CChar
    forall a b. (a -> b) -> a -> b
    $ Addr# -> Offset Int8 -> Int8
    forall ty. PrimType ty => Addr# -> Offset ty -> ty
    primAddrIndex Addr#
    addr (Int -> Offset Int8
    forall ty. Int -> Offset ty
    Offset Int
    n)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset CChar -> prim CChar
    primAddrRead Addr#
    addr (Offset Int
    n) = Int8 -> CChar
    CChar (Int8 -> CChar) -> prim Int8 -> prim CChar
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Addr# -> Offset Int8 -> prim Int8
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    Addr# -> Offset ty -> prim ty
    forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Int8 -> prim Int8
    primAddrRead Addr#
    addr (Int -> Offset Int8
    forall ty. Int -> Offset ty
    Offset Int
    n)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset CChar -> CChar -> prim ()
    primAddrWrite Addr#
    addr (Offset Int
    n) (CChar Int8
    int8) = Addr# -> Offset Int8 -> Int8 -> prim ()
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    Addr# -> Offset ty -> ty -> prim ()
    forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Int8 -> Int8 -> prim ()
    primAddrWrite Addr#
    addr (Int -> Offset Int8
    forall ty. Int -> Offset ty
    Offset Int
    n) Int8
    int8
        {-# INLINE primAddrWrite #-}
    instance PrimType CUChar where
        type PrimSize CUChar = 1
        primSizeInBytes :: Proxy CUChar -> CountOf Word8
    primSizeInBytes Proxy CUChar
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    1
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy CUChar -> Int
    primShiftToBytes Proxy CUChar
    _ = Int
    0
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset CUChar -> CUChar
    primBaUIndex ByteArray#
    ba (Offset Int
    n) = Word8 -> CUChar
    CUChar (ByteArray# -> Offset Word8 -> Word8
    forall ty. PrimType ty => ByteArray# -> Offset ty -> ty
    primBaUIndex ByteArray#
    ba (Int -> Offset Word8
    forall ty. Int -> Offset ty
    Offset Int
    n :: Offset Word8))
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset CUChar -> prim CUChar
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset Int
    n) = Word8 -> CUChar
    CUChar (Word8 -> CUChar) -> prim Word8 -> prim CUChar
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MutableByteArray# (PrimState prim) -> Offset Word8 -> prim Word8
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    MutableByteArray# (PrimState prim) -> Offset ty -> prim ty
    forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Word8 -> prim Word8
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Int -> Offset Word8
    forall ty. Int -> Offset ty
    Offset Int
    n :: Offset Word8)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset CUChar -> CUChar -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset Int
    n) (CUChar Word8
    w8) = MutableByteArray# (PrimState prim)
    -> Offset Word8 -> Word8 -> prim ()
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    MutableByteArray# (PrimState prim) -> Offset ty -> ty -> prim ()
    forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Word8 -> Word8 -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Int -> Offset Word8
    forall ty. Int -> Offset ty
    Offset Int
    n) Word8
    w8
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset CUChar -> CUChar
    primAddrIndex Addr#
    addr (Offset Int
    n) = Word8 -> CUChar
    CUChar (Word8 -> CUChar) -> Word8 -> CUChar
    forall a b. (a -> b) -> a -> b
    $ Addr# -> Offset Word8 -> Word8
    forall ty. PrimType ty => Addr# -> Offset ty -> ty
    primAddrIndex Addr#
    addr (Int -> Offset Word8
    forall ty. Int -> Offset ty
    Offset Int
    n :: Offset Word8)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset CUChar -> prim CUChar
    primAddrRead Addr#
    addr (Offset Int
    n) = Word8 -> CUChar
    CUChar (Word8 -> CUChar) -> prim Word8 -> prim CUChar
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Addr# -> Offset Word8 -> prim Word8
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    Addr# -> Offset ty -> prim ty
    forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word8 -> prim Word8
    primAddrRead Addr#
    addr (Int -> Offset Word8
    forall ty. Int -> Offset ty
    Offset Int
    n :: Offset Word8)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset CUChar -> CUChar -> prim ()
    primAddrWrite Addr#
    addr (Offset Int
    n) (CUChar Word8
    w8) = Addr# -> Offset Word8 -> Word8 -> prim ()
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    Addr# -> Offset ty -> ty -> prim ()
    forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word8 -> Word8 -> prim ()
    primAddrWrite Addr#
    addr (Int -> Offset Word8
    forall ty. Int -> Offset ty
    Offset Int
    n) Word8
    w8
        {-# INLINE primAddrWrite #-}

    instance PrimType Char7 where
        type PrimSize Char7 = 1
        primSizeInBytes :: Proxy Char7 -> CountOf Word8
    primSizeInBytes Proxy Char7
    _ = Int -> CountOf Word8
    forall ty. Int -> CountOf ty
    CountOf Int
    1
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy Char7 -> Int
    primShiftToBytes Proxy Char7
    _ = Int
    0
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset Char7 -> Char7
    primBaUIndex ByteArray#
    ba (Offset Int
    n) = Word8 -> Char7
    Char7 (ByteArray# -> Offset Word8 -> Word8
    forall ty. PrimType ty => ByteArray# -> Offset ty -> ty
    primBaUIndex ByteArray#
    ba (Int -> Offset Word8
    forall ty. Int -> Offset ty
    Offset Int
    n :: Offset Word8))
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Char7 -> prim Char7
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Offset Int
    n) = Word8 -> Char7
    Char7 (Word8 -> Char7) -> prim Word8 -> prim Char7
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MutableByteArray# (PrimState prim) -> Offset Word8 -> prim Word8
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    MutableByteArray# (PrimState prim) -> Offset ty -> prim ty
    forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset Word8 -> prim Word8
    primMbaURead MutableByteArray# (PrimState prim)
    mba (Int -> Offset Word8
    forall ty. Int -> Offset ty
    Offset Int
    n :: Offset Word8)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Char7 -> Char7 -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset Int
    n) (Char7 Word8
    w8) = MutableByteArray# (PrimState prim)
    -> Offset Word8 -> Word8 -> prim ()
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    MutableByteArray# (PrimState prim) -> Offset ty -> ty -> prim ()
    forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset Word8 -> Word8 -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Int -> Offset Word8
    forall ty. Int -> Offset ty
    Offset Int
    n) Word8
    w8
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset Char7 -> Char7
    primAddrIndex Addr#
    addr (Offset Int
    n) = Word8 -> Char7
    Char7 (Word8 -> Char7) -> Word8 -> Char7
    forall a b. (a -> b) -> a -> b
    $ Addr# -> Offset Word8 -> Word8
    forall ty. PrimType ty => Addr# -> Offset ty -> ty
    primAddrIndex Addr#
    addr (Int -> Offset Word8
    forall ty. Int -> Offset ty
    Offset Int
    n :: Offset Word8)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Char7 -> prim Char7
    primAddrRead Addr#
    addr (Offset Int
    n) = Word8 -> Char7
    Char7 (Word8 -> Char7) -> prim Word8 -> prim Char7
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Addr# -> Offset Word8 -> prim Word8
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    Addr# -> Offset ty -> prim ty
    forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word8 -> prim Word8
    primAddrRead Addr#
    addr (Int -> Offset Word8
    forall ty. Int -> Offset ty
    Offset Int
    n :: Offset Word8)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Char7 -> Char7 -> prim ()
    primAddrWrite Addr#
    addr (Offset Int
    n) (Char7 Word8
    w8) = Addr# -> Offset Word8 -> Word8 -> prim ()
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    Addr# -> Offset ty -> ty -> prim ()
    forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset Word8 -> Word8 -> prim ()
    primAddrWrite Addr#
    addr (Int -> Offset Word8
    forall ty. Int -> Offset ty
    Offset Int
    n) Word8
    w8
        {-# INLINE primAddrWrite #-}

    instance PrimType a => PrimType (LE a) where
        type PrimSize (LE a) = PrimSize a
        primSizeInBytes :: Proxy (LE a) -> CountOf Word8
    primSizeInBytes Proxy (LE a)
    _ = Proxy a -> CountOf Word8
    forall ty. PrimType ty => Proxy ty -> CountOf Word8
    primSizeInBytes (Proxy a
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy a)
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy (LE a) -> Int
    primShiftToBytes Proxy (LE a)
    _ = Proxy a -> Int
    forall ty. PrimType ty => Proxy ty -> Int
    primShiftToBytes (Proxy a
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy a)
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset (LE a) -> LE a
    primBaUIndex ByteArray#
    ba (Offset Int
    a) = a -> LE a
    forall a. a -> LE a
    LE (a -> LE a) -> a -> LE a
    forall a b. (a -> b) -> a -> b
    $ ByteArray# -> Offset a -> a
    forall ty. PrimType ty => ByteArray# -> Offset ty -> ty
    primBaUIndex ByteArray#
    ba (Int -> Offset a
    forall ty. Int -> Offset ty
    Offset Int
    a)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset (LE a) -> prim (LE a)
    primMbaURead MutableByteArray# (PrimState prim)
    ba (Offset Int
    a) = a -> LE a
    forall a. a -> LE a
    LE (a -> LE a) -> prim a -> prim (LE a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MutableByteArray# (PrimState prim) -> Offset a -> prim a
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    MutableByteArray# (PrimState prim) -> Offset ty -> prim ty
    forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset a -> prim a
    primMbaURead MutableByteArray# (PrimState prim)
    ba (Int -> Offset a
    forall ty. Int -> Offset ty
    Offset Int
    a)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset (LE a) -> LE a -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset Int
    a) (LE a
    w) = MutableByteArray# (PrimState prim) -> Offset a -> a -> prim ()
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    MutableByteArray# (PrimState prim) -> Offset ty -> ty -> prim ()
    forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset a -> a -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Int -> Offset a
    forall ty. Int -> Offset ty
    Offset Int
    a) a
    w
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset (LE a) -> LE a
    primAddrIndex Addr#
    addr (Offset Int
    a) = a -> LE a
    forall a. a -> LE a
    LE (a -> LE a) -> a -> LE a
    forall a b. (a -> b) -> a -> b
    $ Addr# -> Offset a -> a
    forall ty. PrimType ty => Addr# -> Offset ty -> ty
    primAddrIndex Addr#
    addr (Int -> Offset a
    forall ty. Int -> Offset ty
    Offset Int
    a)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset (LE a) -> prim (LE a)
    primAddrRead Addr#
    addr (Offset Int
    a) = a -> LE a
    forall a. a -> LE a
    LE (a -> LE a) -> prim a -> prim (LE a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Addr# -> Offset a -> prim a
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    Addr# -> Offset ty -> prim ty
    forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset a -> prim a
    primAddrRead Addr#
    addr (Int -> Offset a
    forall ty. Int -> Offset ty
    Offset Int
    a)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset (LE a) -> LE a -> prim ()
    primAddrWrite Addr#
    addr (Offset Int
    a) (LE a
    w) = Addr# -> Offset a -> a -> prim ()
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    Addr# -> Offset ty -> ty -> prim ()
    forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset a -> a -> prim ()
    primAddrWrite Addr#
    addr (Int -> Offset a
    forall ty. Int -> Offset ty
    Offset Int
    a) a
    w
        {-# INLINE primAddrWrite #-}
    instance PrimType a => PrimType (BE a) where
        type PrimSize (BE a) = PrimSize a
        primSizeInBytes :: Proxy (BE a) -> CountOf Word8
    primSizeInBytes Proxy (BE a)
    _ = Proxy a -> CountOf Word8
    forall ty. PrimType ty => Proxy ty -> CountOf Word8
    primSizeInBytes (Proxy a
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy a)
        {-# INLINE primSizeInBytes #-}
        primShiftToBytes :: Proxy (BE a) -> Int
    primShiftToBytes Proxy (BE a)
    _ = Proxy a -> Int
    forall ty. PrimType ty => Proxy ty -> Int
    primShiftToBytes (Proxy a
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy a)
        {-# INLINE primShiftToBytes #-}
        primBaUIndex :: ByteArray# -> Offset (BE a) -> BE a
    primBaUIndex ByteArray#
    ba (Offset Int
    a) = a -> BE a
    forall a. a -> BE a
    BE (a -> BE a) -> a -> BE a
    forall a b. (a -> b) -> a -> b
    $ ByteArray# -> Offset a -> a
    forall ty. PrimType ty => ByteArray# -> Offset ty -> ty
    primBaUIndex ByteArray#
    ba (Int -> Offset a
    forall ty. Int -> Offset ty
    Offset Int
    a)
        {-# INLINE primBaUIndex #-}
        primMbaURead :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset (BE a) -> prim (BE a)
    primMbaURead MutableByteArray# (PrimState prim)
    ba (Offset Int
    a) = a -> BE a
    forall a. a -> BE a
    BE (a -> BE a) -> prim a -> prim (BE a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> MutableByteArray# (PrimState prim) -> Offset a -> prim a
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    MutableByteArray# (PrimState prim) -> Offset ty -> prim ty
    forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset a -> prim a
    primMbaURead MutableByteArray# (PrimState prim)
    ba (Int -> Offset a
    forall ty. Int -> Offset ty
    Offset Int
    a)
        {-# INLINE primMbaURead #-}
        primMbaUWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim)
    -> Offset (BE a) -> BE a -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Offset Int
    a) (BE a
    w) = MutableByteArray# (PrimState prim) -> Offset a -> a -> prim ()
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    MutableByteArray# (PrimState prim) -> Offset ty -> ty -> prim ()
    forall (prim :: * -> *).
    PrimMonad prim =>
    MutableByteArray# (PrimState prim) -> Offset a -> a -> prim ()
    primMbaUWrite MutableByteArray# (PrimState prim)
    mba (Int -> Offset a
    forall ty. Int -> Offset ty
    Offset Int
    a) a
    w
        {-# INLINE primMbaUWrite #-}
        primAddrIndex :: Addr# -> Offset (BE a) -> BE a
    primAddrIndex Addr#
    addr (Offset Int
    a) = a -> BE a
    forall a. a -> BE a
    BE (a -> BE a) -> a -> BE a
    forall a b. (a -> b) -> a -> b
    $ Addr# -> Offset a -> a
    forall ty. PrimType ty => Addr# -> Offset ty -> ty
    primAddrIndex Addr#
    addr (Int -> Offset a
    forall ty. Int -> Offset ty
    Offset Int
    a)
        {-# INLINE primAddrIndex #-}
        primAddrRead :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset (BE a) -> prim (BE a)
    primAddrRead Addr#
    addr (Offset Int
    a) = a -> BE a
    forall a. a -> BE a
    BE (a -> BE a) -> prim a -> prim (BE a)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Addr# -> Offset a -> prim a
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    Addr# -> Offset ty -> prim ty
    forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset a -> prim a
    primAddrRead Addr#
    addr (Int -> Offset a
    forall ty. Int -> Offset ty
    Offset Int
    a)
        {-# INLINE primAddrRead #-}
        primAddrWrite :: forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset (BE a) -> BE a -> prim ()
    primAddrWrite Addr#
    addr (Offset Int
    a) (BE a
    w) = Addr# -> Offset a -> a -> prim ()
    forall ty (prim :: * -> *).
    (PrimType ty, PrimMonad prim) =>
    Addr# -> Offset ty -> ty -> prim ()
    forall (prim :: * -> *).
    PrimMonad prim =>
    Addr# -> Offset a -> a -> prim ()
    primAddrWrite Addr#
    addr (Int -> Offset a
    forall ty. Int -> Offset ty
    Offset Int
    a) a
    w
        {-# INLINE primAddrWrite #-}

    -- | A constraint class for serializable type that have an unique
    -- memory compare representation
    --
    -- e.g. Float and Double have -0.0 and 0.0 which are Eq individual,
    -- yet have a different memory representation which doesn't allow
    -- for memcmp operation
    class PrimMemoryComparable ty where

    instance PrimMemoryComparable Int where
    instance PrimMemoryComparable Word where
    instance PrimMemoryComparable Word8 where
    instance PrimMemoryComparable Word16 where
    instance PrimMemoryComparable Word32 where
    instance PrimMemoryComparable Word64 where
    instance PrimMemoryComparable Word128 where
    instance PrimMemoryComparable Word256 where
    instance PrimMemoryComparable Int8 where
    instance PrimMemoryComparable Int16 where
    instance PrimMemoryComparable Int32 where
    instance PrimMemoryComparable Int64 where
    instance PrimMemoryComparable Char where
    instance PrimMemoryComparable CChar where
    instance PrimMemoryComparable CUChar where
    instance PrimMemoryComparable a => PrimMemoryComparable (LE a) where
    instance PrimMemoryComparable a => PrimMemoryComparable (BE a) where

    offset128_64 :: Offset Word128 -> (# Int#, Int# #)
    offset128_64 :: Offset Word128 -> (# Int#, Int# #)
    offset128_64 (Offset (I# Int#
    i)) = (# Int#
    n , Int#
    n Int# -> Int# -> Int#
    +# Int#
    1# #)
      where !n :: Int#
    n = Int# -> Int# -> Int#
    uncheckedIShiftL# Int#
    i Int#
    1#

    offset256_64 :: Offset Word256 -> (# Int#, Int#, Int#, Int# #)
    offset256_64 :: Offset Word256 -> (# Int#, Int#, Int#, Int# #)
    offset256_64 (Offset (I# Int#
    i)) = (# Int#
    n , Int#
    n Int# -> Int# -> Int#
    +# Int#
    1#, Int#
    n Int# -> Int# -> Int#
    +# Int#
    2#, Int#
    n Int# -> Int# -> Int#
    +# Int#
    3# #)
      where !n :: Int#
    n = Int# -> Int# -> Int#
    uncheckedIShiftL# Int#
    i Int#
    2#

    -- | Cast a CountOf linked to type A (CountOf A) to a CountOf linked to type B (CountOf B)
    sizeRecast :: forall a b . (PrimType a, PrimType b) => CountOf a -> CountOf b
    sizeRecast :: forall a b. (PrimType a, PrimType b) => CountOf a -> CountOf b
    sizeRecast CountOf a
    sz = Int -> CountOf b
    forall ty. Int -> CountOf ty
    CountOf (Int
    bytes Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `Prelude.quot` Int
    szB)
      where !szA :: CountOf Word8
    szA             = Proxy a -> CountOf Word8
    forall ty. PrimType ty => Proxy ty -> CountOf Word8
    primSizeInBytes (Proxy a
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy a)
            !(CountOf Int
    szB)   = Proxy b -> CountOf Word8
    forall ty. PrimType ty => Proxy ty -> CountOf Word8
    primSizeInBytes (Proxy b
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy b)
            !(CountOf Int
    bytes) = CountOf Word8 -> CountOf a -> CountOf Word8
    forall ty. CountOf Word8 -> CountOf ty -> CountOf Word8
    sizeOfE CountOf Word8
    szA CountOf a
    sz
    {-# INLINE [1] sizeRecast #-}
    {-# RULES "sizeRecast from Word8" [2] forall a . sizeRecast a = sizeRecastBytes a #-}

    sizeRecastBytes :: forall b . PrimType b => CountOf Word8 -> CountOf b
    sizeRecastBytes :: forall b. PrimType b => CountOf Word8 -> CountOf b
    sizeRecastBytes (CountOf Int
    w) = Int -> CountOf b
    forall ty. Int -> CountOf ty
    CountOf (Int
    w Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `Prelude.quot` Int
    szB)
      where !(CountOf Int
    szB) = Proxy b -> CountOf Word8
    forall ty. PrimType ty => Proxy ty -> CountOf Word8
    primSizeInBytes (Proxy b
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy b)
    {-# INLINE [1] sizeRecastBytes #-}

    sizeInBytes :: forall a . PrimType a => CountOf a -> CountOf Word8
    sizeInBytes :: forall a. PrimType a => CountOf a -> CountOf Word8
    sizeInBytes CountOf a
    sz = CountOf Word8 -> CountOf a -> CountOf Word8
    forall ty. CountOf Word8 -> CountOf ty -> CountOf Word8
    sizeOfE (Proxy a -> CountOf Word8
    forall ty. PrimType ty => Proxy ty -> CountOf Word8
    primSizeInBytes (Proxy a
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy a)) CountOf a
    sz

    offsetInBytes :: forall a . PrimType a => Offset a -> Offset Word8
    offsetInBytes :: forall a. PrimType a => Offset a -> Offset Word8
    offsetInBytes Offset a
    ofs = Int -> Offset a -> Offset Word8
    forall ty ty2. Int -> Offset ty -> Offset ty2
    offsetShiftL (Proxy a -> Int
    forall ty. PrimType ty => Proxy ty -> Int
    primShiftToBytes (Proxy a
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy a)) Offset a
    ofs
    {-# INLINE [2] offsetInBytes #-}
    {-# SPECIALIZE INLINE [3] offsetInBytes :: Offset Word64 -> Offset Word8 #-}
    {-# SPECIALIZE INLINE [3] offsetInBytes :: Offset Word32 -> Offset Word8 #-}
    {-# SPECIALIZE INLINE [3] offsetInBytes :: Offset Word16 -> Offset Word8 #-}
    {-# RULES "offsetInBytes Bytes" [3] forall x . offsetInBytes x = x #-}

    offsetInElements :: forall a . PrimType a => Offset Word8 -> Offset a
    offsetInElements :: forall a. PrimType a => Offset Word8 -> Offset a
    offsetInElements Offset Word8
    ofs = Int -> Offset Word8 -> Offset a
    forall ty ty2. Int -> Offset ty -> Offset ty2
    offsetShiftR (Proxy a -> Int
    forall ty. PrimType ty => Proxy ty -> Int
    primShiftToBytes (Proxy a
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy a)) Offset Word8
    ofs
    {-# INLINE [2] offsetInElements #-}
    {-# SPECIALIZE INLINE [3] offsetInBytes :: Offset Word64 -> Offset Word8 #-}
    {-# SPECIALIZE INLINE [3] offsetInBytes :: Offset Word32 -> Offset Word8 #-}
    {-# SPECIALIZE INLINE [3] offsetInBytes :: Offset Word16 -> Offset Word8 #-}
    {-# RULES "offsetInElements Bytes" [3] forall x . offsetInElements x = x #-}

    primOffsetRecast :: forall a b . (PrimType a, PrimType b) => Offset a -> Offset b
    primOffsetRecast :: forall a b. (PrimType a, PrimType b) => Offset a -> Offset b
    primOffsetRecast !Offset a
    ofs =
        let !(Offset Int
    bytes) = CountOf Word8 -> Offset a -> Offset Word8
    forall ty. CountOf Word8 -> Offset ty -> Offset Word8
    offsetOfE CountOf Word8
    szA Offset a
    ofs
         in Int -> Offset b
    forall ty. Int -> Offset ty
    Offset (Int
    bytes Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `Prelude.quot` Int
    szB)
      where
        !szA :: CountOf Word8
    szA        = Proxy a -> CountOf Word8
    forall ty. PrimType ty => Proxy ty -> CountOf Word8
    primSizeInBytes (Proxy a
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy a)
        !(CountOf Int
    szB) = Proxy b -> CountOf Word8
    forall ty. PrimType ty => Proxy ty -> CountOf Word8
    primSizeInBytes (Proxy b
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy b)
    {-# INLINE [1] primOffsetRecast #-}
    {-# RULES "primOffsetRecast W8" [3] forall a . primOffsetRecast a = primOffsetRecastBytes a #-}

    offsetIsAligned :: forall a . PrimType a => Proxy a -> Offset Word8 -> Bool
    offsetIsAligned :: forall a. PrimType a => Proxy a -> Offset Word8 -> Bool
    offsetIsAligned Proxy a
    _ (Offset Int
    ofs) = (Int
    ofs Int -> Int -> Int
    forall a. Bits a => a -> a -> a
    .&. Int
    Difference Int
    mask) Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == Int
    0
       where (CountOf Int
    sz) = Proxy a -> CountOf Word8
    forall ty. PrimType ty => Proxy ty -> CountOf Word8
    primSizeInBytes (Proxy a
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy a)
             mask :: Difference Int
    mask = Int
    sz Int -> Int -> Difference Int
    forall a. Subtractive a => a -> a -> Difference a
    - Int
    1
    {-# INLINE [1] offsetIsAligned #-}
    {-# SPECIALIZE [3] offsetIsAligned :: Proxy Word64 -> Offset Word8 -> Bool #-}
    {-# RULES "offsetInAligned Bytes" [3] forall (prx :: Proxy Word8) x . offsetIsAligned prx x = True #-}

    primOffsetRecastBytes :: forall b . PrimType b => Offset Word8 -> Offset b
    primOffsetRecastBytes :: forall a. PrimType a => Offset Word8 -> Offset a
    primOffsetRecastBytes (Offset Int
    0) = Int -> Offset b
    forall ty. Int -> Offset ty
    Offset Int
    0
    primOffsetRecastBytes (Offset Int
    o) = Int -> Offset b
    forall ty. Int -> Offset ty
    Offset (Int
    szA Int -> Int -> Int
    forall a. Integral a => a -> a -> a
    `Prelude.quot` Int
    o)
      where !(CountOf Int
    szA) = Proxy b -> CountOf Word8
    forall ty. PrimType ty => Proxy ty -> CountOf Word8
    primSizeInBytes (Proxy b
    forall {k} (t :: k). Proxy t
    Proxy :: Proxy b)
    {-# INLINE [1] primOffsetRecastBytes #-}

    primOffsetOfE :: forall a . PrimType a => Offset a -> Offset Word8
    primOffsetOfE :: forall a. PrimType a => Offset a -> Offset Word8
    primOffsetOfE = Offset a -> Offset Word8
    forall a. PrimType a => Offset a -> Offset Word8
    offsetInBytes
    {-# DEPRECATED primOffsetOfE "use offsetInBytes" #-}

    primWordGetByteAndShift :: Word# -> (# Word#, Word# #)
    primWordGetByteAndShift :: Word# -> (# Word#, Word# #)
    primWordGetByteAndShift Word#
    w = (# Word# -> Word# -> Word#
    and# Word#
    w Word#
    0xff##, Word# -> Int# -> Word#
    uncheckedShiftRL# Word#
    w Int#
    8# #)
    {-# INLINE primWordGetByteAndShift #-}

    #if WORD_SIZE_IN_BITS == 64
    primWord64GetByteAndShift :: Word# -> (# Word#, Word# #)
    primWord64GetByteAndShift :: Word# -> (# Word#, Word# #)
    primWord64GetByteAndShift = Word# -> (# Word#, Word# #)
    primWord64GetByteAndShift

    primWord64GetHiLo :: Word# -> (# Word#, Word# #)
    primWord64GetHiLo :: Word# -> (# Word#, Word# #)
    primWord64GetHiLo Word#
    w = (# Word# -> Int# -> Word#
    uncheckedShiftRL# Word#
    w Int#
    32# , Word# -> Word# -> Word#
    and# Word#
    w Word#
    0xffffffff## #)
    #else
    primWord64GetByteAndShift :: Word64# -> (# Word#, Word64# #)
    primWord64GetByteAndShift w = (# and# (word64ToWord# w) 0xff##, uncheckedShiftRL64# w 8# #)

    primWord64GetHiLo :: Word64# -> (# Word#, Word# #)
    primWord64GetHiLo w = (# word64ToWord# (uncheckedShiftRL64# w 32#), word64ToWord# w #)
    #endif
    {-# INLINE primWord64GetByteAndShift #-}