!o      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ (c) Alexey Kuleshevich 2020BSD3(Alexey Kuleshevich <alexey@kuleshevi.ch> experimental non-portableNone.>FHISUVXK primal-memoryJMutable region of memory which was allocated either as pinned or unpinned.=Constructor is not exported for safety. Violating type level 0 kind is very dangerous. Type safe constructor   and unwrapper  [ should be used instead. As a backdoor, of course, the actual constructor is available in Data.Prim.Memory.Internal' module and specially unsafe function  was crafted. primal-memoryOAn immutable region of memory which was allocated either as pinned or unpinned.=Constructor is not exported for safety. Violating type level 0 kind is very dangerous. Type safe constructor   and unwrapper  ] should be used instead. As a backdoor, of course, the actual constructor is available from Data.Prim.Memory.Internal primal-memoryAIn GHC there is a distinction between pinned and unpinned memory.Pinned memory is such that when allocated, it is guaranteed not to move throughout the lifetime of a program. In other words the address pointer that refers to allocated bytes will not change until the associated  or  is no longer referenced anywhere in the program at which point it gets garbage collected. On the other hand unpinned memory can be moved around during GC, which helps to reduce memory fragmentation.cPinned/unpinnned choice during allocation is a bit of a lie, because when attempt is made to allocate memory as unpinned, but requested size is a bit more than a certain threshold (somewhere around 3KiB) it might still be allocated as pinned. Because of that fact through out the "primal" universe there is a distinction between memory that is either ned or  onclusive.It is possible to use one of  or  to get a conclusive type. primal-memory;Pinned, which indicates that allocated memory will not move primal-memory5Inconclusive, thus memory could be pinned or unpinned( primal-memoryShrink mutable bytes to new specified count of elements. The new count must be less than or equal to the current count as reported by 0.) primal-memory)Attempt to resize mutable bytes in place.:New bytes might be allocated, with the copy of an old one.@Old references should not be kept around to allow GC to claim it=Old references should not be used to avoid undefined behavior/ primal-memoryHow many elements of type aU fits into bytes completely. In order to get a possible count of leftover bytes use  countRemBytes0 primal-memoryHow many elements of type aO fits into bytes completely. In order to get any number of leftover bytes use  countRemBytes: primal-memoryPointer access to immutable l should be for read only purposes, but it is not enforced. Any mutation will break referential transparency; primal-memorySame as :2, but is suitable for actions that don't terminate primal-memoryThis function will only cast a pointer that was allocated on Haskell heap and it is cerain that the ForeignPtr has no finalizers associated with it.@ primal-memoryKCheck if two byte arrays refer to pinned memory and compare their pointers.A primal-memory#Perform pointer equality on pinned ." primal-memorySize in number of bytes# primal-memorySize in number of bytes7 primal-memoryChunk of memory to fill primal-memoryOffset in number of elements primal-memoryNumber of cells to fill primal-memoryA value to fill the cells with5 !"#$%&'()*+,-./0123456789:;<=>?@AB(c) Alexey Kuleshevich 2020BSD3(Alexey Kuleshevich <alexey@kuleshevi.ch> experimental non-portableNone.=>?@AFHVXN      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuCDEFGHIJKLMN CIEGKDJFHLMN(c) Alexey Kuleshevich 2020BSD3(Alexey Kuleshevich <alexey@kuleshevi.ch> experimental non-portableNone.F^ O primal-memoryMutable version of a  Q primal-memoryO(1) - Cast immutable  to an immutable  v primal-memoryO(1) - Cast an immutable   to immutable . Only unsliced  s that are backed by a M allocated on Haskell heap without finilizers can be converted without copy.R primal-memoryO(1) - Cast an immutable  to an immutable  S primal-memoryO(1) - Cast an immutable   to an immutable T primal-memoryConvert  into a bytestring  U primal-memoryO(n) - Allocate " and fill them using the supplied  V primal-memoryO(n) - Allocate + and fill them with the contents of a lazy wW primal-memoryO(n) - Convert a strict   to .  BOPQRSTUVWXYOP TU QWVXY RSB(c) Alexey Kuleshevich 2020BSD3(Alexey Kuleshevich <alexey@kuleshevi.ch> experimental non-portableNone .=>?@AFX Z primal-memoryFFor memory allocated as pinned it is possible to operate on it with a :. Any data type that is backed by such memory can have a Z3 instance. The simplest way is to convert it to a ( and other functions will come for free.[ primal-memory Convert to .\ primal-memory"Apply an action to the raw memory  to which the data type point to. Type of data stored in memory is left ambiguous intentionaly, so that the user can choose how to treat the memory content.] primal-memory See this GHC  /https://gitlab.haskell.org/ghc/ghc/issues/17746 issue #17746D and related to it in order to get more insight why this is needed.^ primal-memoryApply an action to the raw pointer. It is unsafe to return the actual pointer back from the action because memory itself might get garbage collected or cleaned up by finalizers.DIt is also important not to run non-terminating actions, because GHC can optimize away the logic that runs after the action and GC will happen before the action get's a chance to finish resulting in corrupt memory. Whenever you have an action that runs an infinite loop or ends in an exception throwing, make sure to use _ instead._ primal-memorySame thing as ^9 except it should be used for never ending actions. See ]0 for more information on how this differes from ^.` primal-memoryLifted version of x.a primal-memoryLifted version of y.b primal-memoryLifted version of z.c primal-memoryLifted version of {.d primal-memory Simila to |, except it operates on s , instead of Storable.e primal-memory Similar to , except instead of Storable we use s.f primal-memory Just like e*, but memory is also aligned according to s instanceg primal-memoryLifted version of }.h primal-memoryLifted version of ~.i primal-memoryLifted version of j primal-memoryLifted version of k primal-memory Similar to , except instead of Storable we use s and we are not restricted to ), since finalizers are not possible with  PlaintPtrl primal-memory Similar to , except instead of Storable we use s.m primal-memory Just like e*, but memory is also aligned according to s instancen primal-memoryLifted version of }.o primal-memoryLifted version of ~.p primal-memoryUnlifted version of q primal-memoryUnlifted version of r primal-memoryLifted version of .s primal-memoryAdvances the given address by the given offset in number of elemeents. This operation does not affect associated finalizers in any way.t primal-memoryzAdvances the given address by the given offset in bytes. This operation does not affect associated finalizers in any way.u primal-memorycFind the offset in bytes that is between the two pointers by subtracting one address from another.v primal-memoryFind the offset in number of elements that is between the two pointers by subtracting one address from another and dividing the result by the size of an element.w primal-memorySame as vA, but will also return the remainder in bytes that is left over.y primal-memory3Read-only access, but immutability is not enforced.{ primal-memory3Read-only access, but immutability is not enforced.h primal-memoryNumber of bytes to allocate primal-memoryAlignment in byteso primal-memoryNumber of bytes to allocate primal-memoryAlignment in bytes* >?Z[\]^_`abcdefghijklmnopqrstuvw*Z[\]stvwu^_klmnorac`defghi bjpq>?(c) Alexey Kuleshevich 2020BSD3(Alexey Kuleshevich <alexey@kuleshevi.ch> experimental non-portableNone.F} primal-memoryMutable version of a }~}~(c) Alexey Kuleshevich 2020BSD3(Alexey Kuleshevich <alexey@kuleshevi.ch> experimental non-portableNone.=>?@AHISVXTd; primal-memoryA wrapper that adds a phantom state token. It can be used with types that either doesn't have such state token or are designed to work in  and therefore restricted to tT. Using this wrapper is very much unsafe, so make sure you know what you are doing. primal-memory@Generalized memory allocation and pure/mutable state conversion. primal-memoryMemory region in the immutable state. Types for frozen and thawed states of memory region are in one-to-one correspondence, therefore ma  - FrozeMem mas will always uniquely identify each other, which is an extremely useful property when it comes to type inference. primal-memoryTExtract from the mutable memory region information about how many bytes it can hold. primal-memoryAllocate a mutable memory region for specified number of elements. Memory is not reset and will likely hold some garbage data, therefore prefer to use L, unless it is guaranteed that all of allocated memory will be overwritten. UnsafeWhen precondition for memCount^ argument is violated the outcome is upredictable. One possible outcome is termination with C async exception. In a pure setting, such as when executed within , if memory is not fully overwritten it can result in violation of referential transparency, because content of newly allocated region is non-determinstic. primal-memoryConvert the state of an immutable memory region to the mutable one. This is a no copy operation, as such it is fast, but dangerous. See  for a safe alternative. UnsafeIt makes it possible to break referential transparency, because any subsequent destructive operation to the mutable region of memory will also be reflected in the frozen immutable type as well. primal-memoryConvert the state of a mutable memory region to the immutable one. This is a no copy operation, as such it is fast, but dangerous. See  for a safe alternative. UnsafeIt makes it possible to break referential transparency, because any subsequent destructive operation to the mutable region of memory will also be reflected in the frozen immutable type as well. primal-memoryEither grow or shrink currently allocated mutable region of memory. For some implementations it might be possible to change the size of the allocated region in-place, i.e. without copy. However in all implementations there is a good chance that the memory region has to be allocated anew, in which case all of the contents up to the minimum of new and old sizes will get copied over. After the resize operation is complete the supplied  memSource region must not be used anymore. Moreover, no reference to the old one should be kept in order to allow garbage collection of the original in case a new one had to be allocated. UnsafeUndefined behavior when  memSource4 is used afterwards. The same unsafety notice from  with regards to memCount is applcable here as well. primal-memorypType class that can be implemented for a mutable data type that provides direct read and write access to memory primal-memory`Read an element with an offset in number of elements, rather than bytes as it is the case with . Unsafe.Bounds are not checked. When precondition for off\ argument is violated the result is either unpredictable output or failure with a segfault. primal-memory2Read an element with an offset in number of bytes. Unsafe.Bounds are not checked. When precondition for off\ argument is violated the result is either unpredictable output or failure with a segfault. primal-memoryaWrite an element with an offset in number of elements, rather than bytes as it is the case with . Unsafe.Bounds are not checked. When precondition for offX argument is violated the outcome is either heap corruption or failure with a segfault. primal-memory3Write an element with an offset in number of bytes. Unsafe.Bounds are not checked. When precondition for offX argument is violated the outcome is either heap corruption or failure with a segfault. primal-memoryXCopy contiguous chunk of memory from the source mutable memory into the target mutable . Source and target may% refer to overlapping memory regions. Unsafe-When any precondition for one of the offsets  memSourceOff,  memTargetOff or the element count memCountY is violated a call to this function can result in: copy of data that doesn't belong to  memSource., heap corruption or failure with a segfault. primal-memoryPCopy contiguous chunk of memory from the source mutable memory into the target . Source and target may% refer to overlapping memory regions. Unsafe-When any precondition for one of the offsets  memSourceOff or  memTargetOff, a target pointer  memTarget or the element count memCountZ is violated a call to this function can result in: copy of data that doesn't belong to  memSource-, heap corruption or failure with a segfault. primal-memory{Copy contiguous chunk of memory from the read only memory region into the target mutable memory region. Source and target must not refer to the same memory region, otherwise that would imply that the source is not immutable which would be a violation of some other invariant elsewhere in the code. Unsafe-When any precondition for one of the offsets  memSourceOff,  memTargetOff or the element count memCountY is violated a call to this function can result in: copy of data that doesn't belong to  memSourceRead., heap corruption or failure with a segfault. primal-memorywCopy contiguous chunk of memory from a mutable memory region into the target mutable memory region. Source and target may! refer to the same memory region. Unsafe-When any precondition for one of the offsets  memSourceOff,  memTargetOff or the element count memCountY is violated a call to this function can result in: copy of data that doesn't belong to  memSourceRead., heap corruption or failure with a segfault. primal-memoryWrite the same value memCount times into each cell of  memTarget starting at an offset  memTargetOff. Unsafe.Bounds are not checked. When precondition for  memTargetOffX argument is violated the outcome is either heap corruption or failure with a segfault. primal-memorynType class that can be implemented for an immutable data type that provides read-only direct access to memory primal-memoryANumber of bytes allocated by the data type available for reading.Example:set -XDataKindsimport Data.Prim.Memory4byteCountMem (fromByteListMem [1,2,3] :: Bytes 'Inc)Count {unCount = 3} primal-memory]Read an element with an offset in number of elements, rather than bytes as is the case with . Unsafe.Bounds are not checked. When precondition for off\ argument is violated the result is either unpredictable output or failure with a segfault. primal-memoryJRead an element with an offset in number of bytes. Bounds are not checked. UnsafeWhen precondition for off\ argument is violated the result is either unpredictable output or failure with a segfault. primal-memorySCopy contiguous chunk of memory from the read only memory into the target mutable . Source and target must not refer to the same memory region, otherwise that would imply that the source is not immutable which would be a violation of some other invariant elsewhere in the code. Unsafe.When a precondition for either of the offsets  memSourceOff,  memTargetOff or the element count memCountS is violated the result is either unpredictable output or failure with a segfault. primal-memorySCopy contiguous chunk of memory from the read only memory into the target mutable . Source and target must not refer to the same memory region, otherwise that would imply that the source is not immutable which would be a violation of some other invariant elsewhere in the code. Unsafe-When any precondition for one of the offsets  memSourceOff,  memTargetOff or the element count memCountY is violated a call to this function can result in: copy of data that doesn't belong to  memSourceRead., heap corruption or failure with a segfault. primal-memorySame as F, but compare the read-only memory region to a region addressed by a  inside of a u. Unsafe0When any precondition for either of the offsets memOff1, memOff2, the pointer memRead2 or the element count memCountS is violated the result is either unpredictable output or failure with a segfault. primal-memorySame as -, but compare the read-only memory region to . Unsafe0When any precondition for either of the offsets memOff1, memOff2 or the element count memCountS is violated the result is either unpredictable output or failure with a segfault. primal-memoryzCompare two read-only regions of memory byte-by-byte. The very first mismatched byte will cause this function to produce  if the byte in memRead1 is smaller than the one in memRead2 and  if it is bigger. It is not a requirement to short-circuit on the first mismatch, but it is a good optimization to have for non-sensitive data. Memory regions that store security critical data may choose to implement this function to work in constant time.6This function is usually implemented by either one of  or , depending on the nature of mrr type. However it differs from the aforementioned functions with a fact that it is pure non-monadic computation. Unsafe0When any precondition for either of the offsets memOff1, memOff2 or the element count memCountS is violated the result is either unpredictable output or failure with a segfault. primal-memoryPlace nt copies of supplied region of memory one after another in a newly allocated contiguous chunk of memory. Similar to , but the source memory memRead% does not have to match the type of  ma.Example:set -XTypeApplications:set -XDataKindsimport Data.Prim.MemoryBlet b = fromListMem @Word8 @(MBytes 'Inc) [0xde, 0xad, 0xbe, 0xef]cycleMemN @(MBytes 'Inc) 2 b)[0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef] primal-memoryGConstruct an immutable memory region that can't hold any data. Same as  ::  maExample:set -XTypeApplications:set -XDataKindsimport Data.Prim.Memory,toListMem (emptyMem @(MBytes 'Inc)) :: [Int][] primal-memoryBAllocate a region of immutable memory that holds a single element.Example:set -XTypeApplications:set -XDataKindsimport Data.Prim.MemoryAtoListMem (singletonMem @Word16 @(MBytes 'Inc) 0xffff) :: [Word8] [255,255] primal-memorySame as , but also use 2 to reset all of newly allocated memory to zeros. UnsafeWhen precondition for memCount] argument is violated the outcome is upredictable. One possible outcome is termination with  async exception.Example:set -XTypeApplications:set -XDataKindsimport Data.Prim.Memory)mb <- allocZeroMem @Int @(MBytes 'Inc) 10b <- freezeMem mbtoListMem b :: [Int][0,0,0,0,0,0,0,0,0,0] primal-memorySame as Q, except it ensures that the memory gets reset with zeros prior to applying the ST filling action  fillAction. UnsafeSame reasons as  : violation of precondition for memCount& may result in undefined behavior or  async exception.ExampleJNote that this example will work correctly only on little-endian machines::set -XTypeApplicationsimport Data.Primimport Control.MonadTlet ibs = zip [0, 4 ..] [0x48,0x61,0x73,0x6b,0x65,0x6c,0x6c] :: [(Off Word8, Word8)](let c = Count (length ibs) :: Count Charblet bc = createZeroMemST_ @_ @(MBytes 'Inc) c $ \m -> forM_ ibs $ \(i, b) -> writeByteOffMem m i btoListMem bc :: String "Haskell" primal-memory\Copy all of the data from the source into a newly allocate memory region of identical size.Examples:set -XDataKindsimport Data.Prim.Memory=let xs = fromByteListMem @(MBytes 'Pin) [0..15] :: Bytes 'Pinlet ys = cloneMem xsblet report bEq pEq = print $ "Bytes equal: " ++ show bEq ++ ", their pointers equal: " ++ show pEq\withPtrBytes xs $ \ xsPtr -> withPtrBytes ys $ \ ysPtr -> report (xs == ys) (xsPtr == ysPtr)0"Bytes equal: True, their pointers equal: False" primal-memory Similar to , but supply offsets in number of elements instead of bytes. Copy contiguous chunk of memory from the read only memory region into the target mutable memory region. Source and target must not refer to the same memory region, otherwise that would imply that the source is not immutable which would be a violation of some other invariant elsewhere in the code. Unsafe-When any precondition for one of the offsets  memSourceOff,  memTargetOff or the element count memCountY is violated a call to this function can result in: copy of data that doesn't belong to  memSourceRead., heap corruption or failure with a segfault. primal-memoryO(n)X - Convert a read-only memory region into a newly allocated other type of memory regionimport Data.ByteString (pack)bs = pack [0x10 .. 0x20]bs>"\DLE\DC1\DC2\DC3\DC4\NAK\SYN\ETB\CAN\EM\SUB\ESC\FS\GS\RS\US "convertMem bs :: Bytes 'IncV[0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20] primal-memoryFigure out how many elements fits into the immutable region of memory. It is possible that there is a remainder of bytes left, see  for getting that too.Examples/b = fromListMem [0 .. 5 :: Word8] :: Bytes 'Pinb[0x00,0x01,0x02,0x03,0x04,0x05]countMem b :: Count Word16Count {unCount = 3}countMem b :: Count Word32Count {unCount = 1} primal-memory[Compute how many elements and a byte size remainder that can fit into the region of memory.Examples/b = fromListMem [0 .. 5 :: Word8] :: Bytes 'Pinb[0x00,0x01,0x02,0x03,0x04,0x05]countRemMem @Word16 b)(Count {unCount = 3},Count {unCount = 0})countRemMem @Word32 b)(Count {unCount = 1},Count {unCount = 2}) primal-memory)Compare two memory regions byte-by-byte. 1 is returned immediately when sizes reported by T do not match. Computation may be short-circuited on the first mismatch, but it is  implementation specific. primal-memory;Compare two regions of memory byte-by-byte. It will return 1 whenever both regions are exactly the same and  or  as soon as the first byte is reached that is less than or greater than respectfully in the first region when compared to the second one. It is safe for both regions to refer to the same part of memory, since this is a pure function and both regions of memory are read-only. primal-memoryConvert an immutable memory region to a list. Whenever memory byte count is not exactly divisible by the size of the element there will be some slack left unaccounted for. In order to get a hold of this slack use  instead.Examplesimport Data.Prim.Memoryimport Numeric (showHex)Jlet b = fromByteListMem [0x48,0x61,0x73,0x6b,0x65,0x6c,0x6c] :: Bytes 'InctoListMem b :: [Int8][72,97,115,107,101,108,108] let xs = toListMem b :: [Word32]xs [1802723656]showHex (head xs) "" "6b736148" primal-memorySame as , except when there is some slack towards the end of the memory region that didn't fit into a list it will be returned as a list of bytes.Examplesimport Data.Word:set -XDataKinds0a = fromListMem [0 .. 10 :: Word8] :: Bytes 'Pina8[0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a]&toListSlackMem a :: ([Word8], [Word8])([0,1,2,3,4,5,6,7,8,9,10],[])'toListSlackMem a :: ([Word16], [Word8])([256,770,1284,1798,2312],[10])'toListSlackMem a :: ([Word32], [Word8])([50462976,117835012],[8,9,10])'toListSlackMem a :: ([Word64], [Word8])([506097522914230528],[8,9,10]) primal-memoryRRight fold that is useful for converting to a list while tapping into list fusion. UnsafehSupplying Count larger than memory holds will result in reading out of bounds and a potential segfault. primal-memory Just like , except it ensures safety by using the length of the list for allocation. Because it has to figure out the length of the list first it will be just a little bit slower, but that much safer.Examplesimport Data.Prim.Memory:set -XDataKindsfromListMem "Hi" :: Bytes 'Inc)[0x48,0x00,0x00,0x00,0x69,0x00,0x00,0x00] primal-memorySame as  but restricted to a list of L. Load a list of bytes into a newly allocated memory region. Equivalent to  for Examples%fromByteListMem [0..10] :: Bytes 'Pin8[0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a] primal-memory Similarly to  load a list into a newly allocated memory region, but unlike the aforementioned function it also accepts a hint of how many elements is expected to be in the list. Because the number of expected an actual elements might not match we return not only the frozen memory region, but also:4either a list with leftover elements from the input listm, if it did not fully fit into the allocated region. An empty list would indicate that it did fit exactly.  unCount memCount <= length list hor an exact count of how many elements have been loaded when there was no enough elements in the listOIn the latter case a zero value would indicate that the list did fit into the newly allocated memory region exactly, which is perfectly fine. But a positive value would mean that the tail of the memory region is still unset and might contain garbage data. Make sure to overwrite the surplus memory yourself or use the safe version # that fills the surplus with zeros. Unsafe Whenever memCount precodition is violated, because on each call with the same input it can produce different output therefore it will break referential transparency.Examples:set -XTypeApplications+fromListMemN @Char @(MBytes 'Inc) 3 "Hello"I(Left "lo",[0x48,0x00,0x00,0x00,0x65,0x00,0x00,0x00,0x6c,0x00,0x00,0x00])(fromListMemN @Char @(MBytes 'Inc) 2 "Hi"3(Left "",[0x48,0x00,0x00,0x00,0x69,0x00,0x00,0x00]).fst $ fromListMemN @Char @(MBytes 'Inc) 5 "Hi"Right (Count {unCount = 2}) primal-memory Just like ], except it ensures safety by filling tail with zeros, whenever the list is not long enough.Examplesimport Data.Prim.Memory:set -XTypeApplications,fromListZeroMemN @Char @(MBytes 'Inc) 3 "Hi"[(Right (Count {unCount = 2}),[0x48,0x00,0x00,0x00,0x69,0x00,0x00,0x00,0x00,0x00,0x00,0x00]) primal-memorySame as >, but ignore the extra information about how the loading went.Examplesimport Data.Prim.Memory&fromListZeroMemN_ 3 "Hi" :: Bytes 'Inc=[0x48,0x00,0x00,0x00,0x69,0x00,0x00,0x00,0x00,0x00,0x00,0x00] primal-memoryLoad elements from the supplied list into a mutable memory region. Loading will start at the supplied offset in number of bytes and will stop when either supplied  elemCount number is reached or there are no more elements left in the list to load. This action returns a list of elements that did not get loaded and the count of how many elements did get loaded. Unsafe,When any precondition for either the offset  memTargetOff or the element count memCountd is violated then a call to this function can result in heap corruption or failure with a segfault.ExamplesFor example load the Hell somewhere in the middle of :;ma <- allocZeroMem (6 :: Count Char) :: IO (MBytes 'Inc RW)=loadListByteOffMemN 4 "Hello!" ma (toByteOff (1 :: Off Char))("o!",Count {unCount = 4}) freezeMem may[0x00,0x00,0x00,0x00,0x48,0x00,0x00,0x00,0x65,0x00,0x00,0x00,0x6c,0x00,0x00,0x00,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00]@Or something more usful like loading prefixes from nested lists:import Control.MonadsfoldM_ (\o xs -> (+ o) . countToByteOff . snd <$> loadListByteOffMemN 4 xs ma o) 2 [[x..] | x <- [1..5] :: [Word8]] freezeMem may[0x00,0x00,0x01,0x02,0x03,0x04,0x02,0x03,0x04,0x05,0x03,0x04,0x05,0x06,0x04,0x05,0x06,0x07,0x05,0x06,0x07,0x08,0x00,0x00] primal-memorySame as Z, but infer the count from number of bytes that is available in the target memory region. Unsafe*When a precondition for the element count memCountd is violated then a call to this function can result in heap corruption or failure with a segfault.Examples:set -XDataKindsimport Data.Prim.Memory;ma <- allocZeroMem (5 :: Count Char) :: IO (MBytes 'Inc RW) freezeMem mae[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]%loadListByteOffMem "Hello World" ma 0(" World",Count {unCount = 5}) freezeMem mae[0x48,0x00,0x00,0x00,0x65,0x00,0x00,0x00,0x6c,0x00,0x00,0x00,0x6c,0x00,0x00,0x00,0x6f,0x00,0x00,0x00]5loadListByteOffMem ([0xff,0xff,0xff] :: [Word8]) ma 1([],Count {unCount = 3}) freezeMem mae[0x48,0xff,0xff,0xff,0x65,0x00,0x00,0x00,0x6c,0x00,0x00,0x00,0x6c,0x00,0x00,0x00,0x6f,0x00,0x00,0x00] primal-memorySame as @, but works with offset in number of elements instead of bytes. Unsafe)When preconditions for either the offset  memTargetOff or the element count memCountd is violated then a call to this function can result in heap corruption or failure with a segfault. primal-memorySame as , but start loading at 0 offset. Unsafe,When any precondition for the element count memCountd is violated then a call to this function can result in heap corruption or failure with a segfault. primal-memorySame as , but ignores the result. Unsafe,When any precondition for the element count memCountd is violated then a call to this function can result in heap corruption or failure with a segfault. primal-memorySame as Z, but infer the count from number of bytes that is available in the target memory region. Unsafe*When a precondition for the element count memCountd is violated then a call to this function can result in heap corruption or failure with a segfault. primal-memorySame as , but tries to fit as many elements as possible into the mutable memory region starting at the beginning. This operation is always safe.Examplesimport Data.Prim.Memory7ma <- allocMem (5 :: Count Char) :: IO (MBytes 'Inc RW)loadListMem "HelloWorld" ma("World",Count {unCount = 5}) freezeMem mae[0x48,0x00,0x00,0x00,0x65,0x00,0x00,0x00,0x6c,0x00,0x00,0x00,0x6c,0x00,0x00,0x00,0x6f,0x00,0x00,0x00],loadListMem (replicate 6 (0xff :: Word8)) ma([],Count {unCount = 6}) freezeMem mae[0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x6c,0x00,0x00,0x00,0x6c,0x00,0x00,0x00,0x6f,0x00,0x00,0x00] primal-memorySame as 2, but ignores the result. Equivalence as property:let c = fromInteger (abs i) :: Count Int in (createZeroMemST_ c (loadListMem_ (xs :: [Int])) :: Bytes 'Inc) == createZeroMemST_ c (void . loadListMem xs) primal-memory:Convert a memory region to a list of bytes. Equivalent to  for Example5toByteListMem (fromByteListMem [0..10] :: Bytes 'Pin)[0,1,2,3,4,5,6,7,8,9,10] primal-memoryIterate over a region of memory primal-memory A list of r which covert bytes to base16 encoded strings. Each element of the list is a function that will convert one byte.Example:set -XDataKindsimport Data.Prim.MemoryNconcatMap ($ " ") $ showsHexMem (fromListMem [1 :: Int16 .. 15] :: Bytes 'Inc)\"01 00 02 00 03 00 04 00 05 00 06 00 07 00 08 00 09 00 0a 00 0b 00 0c 00 0d 00 0e 00 0f 00 " primal-memoryGEnsure that memory is filled with zeros before and after it gets used. Z is not used directly, but istead is used to guarantee that the memory is pinned and its contents do get moved around by the garbage collector.% primal-memorymemCount" - Number of elements to allocate.Preconditions:  0 <= memCountPossibility of overflow: 5unCount memCount <= fromByteCount @e (Count maxBound)OWhen converted to bytes the value should be less then available physical memory primal-memory memSource! - Source memory region to resize primal-memorymemCount7 - Number of elements for the reallocated memory regionPreconditions:  0 <= memCount-Should be less then available physical memory primal-memorymemRead( - Memory region to read an element from primal-memoryoff6 - Offset in number of elements from the beginning of memReadPreconditions: 0 <= offdWith offset applied it should still refer to the same memory region. For types that also implement  this can be described as: \count <- getByteCountMem memRead unOff (toByteOff off) <= unCount (count - byteCountType @e) primal-memorymemRead( - Memory region to read an element from primal-memoryoff6 - Offset in number of elements from the beginning of memReadPreconditions: 0 <= offdWith offset applied it should still refer to the same memory region. For types that also implement  this can be described as: \count <- getByteCountMem memRead unOff (toByteOff off) <= unCount (count - byteCountType @e) primal-memorymemWrite) - Memory region to write an element into primal-memoryoff6 - Offset in number of elements from the beginning of memWritePreconditions: 0 <= offdWith offset applied it should still refer to the same memory region. For types that also implement  this can be described as: ]count <- getByteCountMem memWrite unOff (toByteOff off) <= unCount (count - byteCountType @e) primal-memoryelt - Element to write primal-memorymemWrite) - Memory region to write an element into primal-memoryoff6 - Offset in number of elements from the beginning of memWritePreconditions: 0 <= offdWith offset applied it should still refer to the same memory region. For types that also implement  this can be described as: ]count <- getByteCountMem memWrite unOff (toByteOff off) <= unCount (count - byteCountType @e) primal-memory memSource# - Source memory from where to copy primal-memory memSourceOff/ - Offset in number of bytes into source memoryPreconditions: 0 <= memSourceOffdWith offset applied it should still refer to the same memory region. For types that also implement  this can be described as: {sourceByteCount <- getByteCountMem memSource unOff (toByteOff memSourceOff) <= unCount (sourceByteCount - byteCountType @e) primal-memory memTarget# - Target memory into where to copy primal-memory memTargetOffH - Offset in number of bytes into target memory where writing will startPreconditions: 0 <= memTargetOffdWith offset applied it should still refer to the same memory region. For types that also implement  this can be described as: ttargetByteCount <- getByteCountMem memTarget unOffBytes memTargetOff <= unCount (targetByteCount - byteCountType @e) primal-memorymemCount - Number of elements of type e to copyPreconditions:  0 <= memCountTBoth source and target memory regions must have enough memory to perform a copy of memCountO elements starting at their respective offsets. For types that also implement  this can be described as: sourceByteCount <- getByteCountMem memSource unOff memSourceOff + unCountBytes memCount <= unCount (sourceByteCount - byteCountType @e) targetByteCount <- getByteCountMem memTarget unOff memTargetOff + unCountBytes memCount <= unCount (targetByteCount - byteCountType @e) primal-memory memSource# - Source memory from where to copy primal-memory memSourceOff/ - Offset in number of bytes into source memoryPreconditions: 0 <= memSourceOffdWith offset applied it should still refer to the same memory region. For types that also implement  this can be described as: {sourceByteCount <- getByteCountMem memSource unOff (toByteOff memSourceOff) <= unCount (sourceByteCount - byteCountType @e) primal-memory memTarget# - Target memory into where to copy Precondition: Once the pointer is advanced by  memTargetOff the next unCountBytes memCount7 bytes must still belong to the same region of memory memTargetWrite primal-memory memTargetOffH - Offset in number of bytes into target memory where writing will startPreconditions: 0 <= memTargetOff Once the pointer is advanced by  memTargetOff0 it must still refer to the same memory region  memTarget primal-memorymemCount - Number of elements of type e to copyPreconditions:  0 <= memCountTBoth source and target memory regions must have enough memory to perform a copy of memCount4 elements starting at their respective offsets. For  memSource that also implements  this can be described as: sourceByteCount <- getByteCountMem memSource unOff memSourceOff + unCountBytes memCount <= unCount (sourceByteCount - byteCountType @e) primal-memory memSourceRead4 - Read-only source memory region from where to copy primal-memory memSourceOff/ - Offset into source memory in number of bytesPreconditions: 0 <= memSourceOff MunOff memSourceOff <= unCount (byteCountMem memSourceRead - byteCountType @e) primal-memorymemTargetWrite - Target mutable memory primal-memory memTargetOff0 - Offset into target memory in number of bytesPreconditions: 0 <= memTargetOffdWith offset applied it should still refer to the same memory region. For types that also implement  this can be described as: ytargetByteCount <- getByteCountMem memTargetWrite unOffBytes memTargetOff <= unCount (targetByteCount - byteCountType @e) primal-memorymemCount - Number of elements of type e to copyPreconditions:  0 <= memCountTBoth source and target memory regions must have enough memory to perform a copy of memCount4 elements starting at their respective offsets. For  memSourceRead: eunOff memSourceOff + unCountBytes memCount <= unCount (byteCountMem memSourceRead - byteCountType @e)and for memTargetWrite that also implements  this can be described as: targetByteCount <- getByteCountMem memTargetWrite unOff memTargetOff + unCountBytes memCount <= unCount (targetByteCount - byteCountType @e) primal-memory memSource# - Source memory from where to copy primal-memory memSourceOff/ - Offset in number of bytes into source memoryPreconditions: 0 <= memSourceOffdWith offset applied it should still refer to the same memory region. For types that also implement  this can be described as: tsourceByteCount <- getByteCountMem memSource unOffBytes memSourceOff <= unCount (sourceByteCount - byteCountType @e) primal-memory memTarget# - Target memory into where to copy primal-memory memTargetOff0 - Offset into target memory in number of bytesPreconditions: 0 <= memTargetOffdWith offset applied it should still refer to the same memory region. For types that also implement  this can be described as: targetByteCount <- getByteCountMem memTarget unOffBytes (toByteOff memTargetOff) <= unCount (targetByteCount - byteCountType @e) primal-memorymemCount - Number of elements of type e to copyPreconditions:  0 <= memCountTBoth source and target memory regions must have enough memory to perform a copy of memCountO elements starting at their respective offsets. For types that also implement  this can be described as: sourceByteCount <- getByteCountMem memSource unOff memSourceOff + unCountBytes memCount <= unCount (sourceByteCount - byteCountType @e) targetByteCount <- getByteCountMem memTarget unOff memTargetOff + unCountBytes memCount <= unCount (targetByteCount - byteCountType @e) primal-memory memTarget0 - Target memory into where to write the element primal-memory memTargetOffZ - Offset into target memory in number of elements at which element setting should start.Preconditions: 0 <= memTargetOffdWith offset applied it should still refer to the same memory region. For types that also implement  this can be described as: ttargetByteCount <- getByteCountMem memTarget unOffBytes memTargetOff <= unCount (targetByteCount - byteCountType @e) primal-memorymemCount - Number of times the element elt should be writtenPreconditions:  0 <= memCountcTarget memory region should have enough memory to perform a set operation of the supplied element memCountQ number of times starting at the supplied offset. For types that also implement  this can be described as: targetByteCount <- getByteCountMem memTarget unCountBytes memCount + unOff memTargetOff <= unCount (targetByteCount - byteCountType @e) primal-memoryelts - Element to write into memory cells. This function is strict with respect to element, which means that the even  memCount = 0$ it might be still fully evaluated. primal-memorymemRead! - Memory to read an element from primal-memoryoff6 - Offset in number of elements from the beginning of memReadPreconditions: 0 <= off CunOffBytes off <= unCount (byteCountMem memRead - byteCountType @e) primal-memorymemRead! - Memory to read an element from primal-memoryoff6 - Offset in number of elements from the beginning of memReadPreconditions: 0 <= unOff off >unOff off <= unCount (byteCountMem memRead - byteCountType @e) primal-memory memSourceRead - Source from where to copy primal-memory memSourceOff/ - Offset into source memory in number of bytesPreconditions: 0 <= memSourceOff MunOff memSourceOff <= unCount (byteCountMem memSourceRead - byteCountType @e) primal-memorymemTargetWrite - Target mutable memory primal-memory memTargetOff0 - Offset into target memory in number of bytesPreconditions: 0 <= memTargetOff NunOff memTargetOff <= unCount (byteCountMem memTargetWrite - byteCountType @e) primal-memorymemCount - Number of elements of type e to copyPreconditions:  0 <= memCount eunCountBytes memCount + unOff memSourceOff <= unCount (byteCountMem memSourceRead - byteCountType @e) eunCountBytes memCount + unOff memTargetOff <= unCount (byteCountMem memTargetRead - byteCountType @e) primal-memory memSourceRead - Source from where to copy primal-memory memSourceOff/ - Offset into source memory in number of bytesPreconditions: 0 <= memSourceOff MunOff memSourceOff <= unCount (byteCountMem memSourceRead - byteCountType @e) primal-memorymemTargetWrite' - Pointer to the target mutable memoryPreconditions: Once the pointer is advanced by  memTargetOff the next unCountBytes memCount7 bytes must still belong to the same region of memory memTargetWrite primal-memory memTargetOff* - Number of bytes to advance the pointer memTargetWrite forward Precondition: Once the pointer is advanced by  memTargetOff0 it must still refer to the same memory region memTargetWrite primal-memorymemCount - Number of elements of type e to copyPreconditions:  0 <= memCount eunCountBytes memCount + unOff memSourceOff <= unCount (byteCountMem memSourceRead - byteCountType @e) primal-memorymemRead1 - First memory region primal-memorymemOff1 - Offset for memRead1 in number of bytesPreconditions:  0 <= memOff1 CunOff memOff1 <= unCount (byteCountMem memRead1 - byteCountType @e) primal-memorymemRead28- Second memory region that can be accessed by a pointer Preconditions Once the pointer is advanced by memOff2 the next unCountBytes memCount7 bytes must still belong to the same region of memory memRead2 primal-memorymemOff2* - Number of bytes to advance the pointer memRead2 forward Precondition: Once the pointer is advanced by memOff20 it must still refer to the same memory region memRead2 primal-memorymemCount - Number of elements of type e to compare as binary ^ memCount - Number of elements of type e to compare as binaryPreconditions:  0 <= memCount [unCountBytes memCount + unOff memOff1 <= unCount (byteCountMem memRead1 - byteCountType @e) primal-memorymemRead1 - First memory region primal-memorymemOff1 - Offset for memRead1 in number of bytesPreconditions:  0 <= memOff1 CunOff memOff1 <= unCount (byteCountMem memRead1 - byteCountType @e) primal-memorymemRead2)- Second memory region that is backed by  primal-memorymemOff2 - Offset for memRead2 in number of bytesPreconditions:  0 <= memOff2 CunOff memOff2 <= unCount (byteCountMem memRead2 - byteCountType @e) primal-memorymemCount - Number of elements of type e to compare as binaryPreconditions:  0 <= memCount [unCountBytes memCount + unOff memOff1 <= unCount (byteCountMem memRead1 - byteCountType @e) [unCountBytes memCount + unOff memOff2 <= unCount (byteCountMem memRead2 - byteCountType @e) primal-memorymemRead1 - First memory region primal-memorymemOff1 - Offset for memRead1 in number of bytesPreconditions:  0 <= memOff1 CunOff memOff1 <= unCount (byteCountMem memRead1 - byteCountType @e) primal-memorymemRead2 - Second memory region primal-memorymemOff2 - Offset for memRead2 in number of bytesPreconditions:  0 <= memOff2 CunOff memOff2 <= unCount (byteCountMem memRead2 - byteCountType @e) primal-memorymemCount - Number of elements of type e to compare as binaryPreconditions:  0 <= memCount [unCountBytes memCount + unOff memOff1 <= unCount (byteCountMem memRead1 - byteCountType @e) [unCountBytes memCount + unOff memOff2 <= unCount (byteCountMem memRead2 - byteCountType @e) primal-memoryNThe single element that will be stored in the newly allocated region of memory primal-memorymemCount" - Number of elements to allocate.Preconditions:  0 <= memCount@Converted to bytes should be less then available physical memory primal-memory fillActionK -- Action that will be used to modify contents of newly allocated memory.Required invariant:JIt is important that this action overwrites all of newly allocated memory. primal-memorymemCountL - Size of the newly allocated memory region in number of elements of type e Precoditions:Size should be non-negative, but smaller than amount of available memory. Note that the second condition simply describes overflow.  0 <= memCountPossibility of overflow: 5unCount memCount <= fromByteCount @e (Count maxBound) primal-memory fillAction -- Action that will be used to modify contents of newly allocated memory. It is not required to overwrite the full region, since it was reset to zeros right after allocation. primal-memory memSource - immutable source memory. primal-memory memSourceRead4 - Read-only source memory region from where to copy primal-memory memSourceOff; - Offset into source memory in number of elements of type ePreconditions: 0 <= memSourceOff 5unOff memSourceOff < unCount (countMem memSourceRead) primal-memorymemTargetWrite - Target mutable memory primal-memory memTargetOff3 - Offset into target memory in number of elementsPreconditions: 0 <= memTargetOffdWith offset applied it should still refer to the same memory region. For types that also implement  this can be described as: RtargetCount <- getCountMem memTargetWrite unOff memTargetOff < unCount targetCount primal-memorymemCount - Number of elements of type e to copyPreconditions:  0 <= memCountTBoth source and target memory regions must have enough memory to perform a copy of memCount4 elements starting at their respective offsets. For  memSourceRead: HunOff memSourceOff + unCount memCount < unCount (countMem memSourceRead)and for memTargetWrite that also implements  this can be described as: etargetCount <- getCountMem memTargetWrite unOff memTargetOff + unCount memCount < unCount targetCount primal-memorySource memory region primal-memory,Offset into the source in number of elements primal-memoryDestination memory region primal-memory-Offset into destination in number of elements primal-memoryNumber of elements to copy over primal-memoryFirst region of memory primal-memory2Offset in number of elements into the first region primal-memorySecond region of memory primal-memory3Offset in number of elements into the second region primal-memoryNumber of elements to compare primal-memorymemCount] - Expected number of elements in the list, which exactly how much memory will be allocated.Preconditions: -0 <= memCount unCount memCount <= length list primal-memorylistE - A list of elements to load into the newly allocated memory region. primal-memorymemCount, - Number of elements to load from the list. primal-memoryOffset primal-memory Upper bound primal-memory Element size primal-memory elemCountF - Maximum number of elements to load from list into the memory regionPreconditions:  0 <= memCountCTarget memory region must have enough memory to perform loading of  elemCount elements starting at the  memTargetOff( offset. For types that also implement  this can be described as: targetByteCount <- getByteCountMem memTarget unOff memTargetOff + unCountBytes elemCount <= unCount (targetByteCount - byteCountType @e) primal-memory listSource+ - List with elements that should be loaded primal-memory memTarget0 - Memory region where to load the elements into primal-memory memTargetOffH - Offset in number of bytes into target memory where writing will startPreconditions: 0 <= memTargetOff Once the pointer is advanced by  memTargetOff0 it must still refer to the same memory region  memTarget . For types that also implement  this can be described as: otargetByteCount <- getByteCountMem memTarget unOff memTargetOff <= unCount (targetByteCount - byteCountType @e) primal-memoryLeftover part of the  listSource> if any and the exact count of elements that have been loaded. primal-memory listSource+ - List with elements that should be loaded primal-memory memTarget0 - Memory region where to load the elements into primal-memory memTargetOffH - Offset in number of bytes into target memory where writing will startPreconditions: 0 <= memTargetOff Once the pointer is advanced by  memTargetOff0 it must still refer to the same memory region  memTarget . For types that also implement  this can be described as: otargetByteCount <- getByteCountMem memTarget unOff memTargetOff <= unCount (targetByteCount - byteCountType @e) primal-memoryLeftover part of the  listSource> if any and the exact count of elements that have been loaded. primal-memory elemCountF - Maximum number of elements to load from list into the memory regionPreconditions:  0 <= memCountCTarget memory region must have enough memory to perform loading of  elemCount elements starting at the  memTargetOff( offset. For types that also implement  this can be described as: atargetCount <- getCountMem memTarget unOff memTargetOff + unCount elemCount < unCount targetCount primal-memory listSource+ - List with elements that should be loaded primal-memory memTarget0 - Memory region where to load the elements into primal-memory memTargetOffK - Offset in number of elements into target memory where writing will startPreconditions: 0 <= memTargetOff Once the pointer is advanced by  memTargetOff0 it must still refer to the same memory region  memTarget . For types that also implement  this can be described as: QtargetCount <- getByteCountMem memTarget unOff memTargetOff < unCount targetCount primal-memoryLeftover part of the  listSource> if any and the exact count of elements that have been loaded. primal-memory elemCountF - Maximum number of elements to load from list into the memory regionPreconditions:  0 <= memCountCTarget memory region must have enough memory to perform loading of  elemCount* elements. For types that also implement  this can be described as: =targetCount <- getCountMem memTarget elemCount <= targetCount primal-memory listSource+ - List with elements that should be loaded primal-memory memTarget0 - Memory region where to load the elements into primal-memoryLeftover part of the  listSource> if any and the exact count of elements that have been loaded. primal-memory elemCountF - Maximum number of elements to load from list into the memory regionPreconditions:  0 <= memCountCTarget memory region must have enough memory to perform loading of  elemCount* elements. For types that also implement  this can be described as: =targetCount <- getCountMem memTarget elemCount <= targetCount primal-memory listSource+ - List with elements that should be loaded primal-memory memTarget0 - Memory region where to load the elements into primal-memory listSource+ - List with elements that should be loaded primal-memory memTarget0 - Memory region where to load the elements into primal-memory memTargetOffL - Offset in number of elements into target memory where writing will startPreconditions: 0 <= memTargetOff Once the pointer is advanced by  memTargetOff0 it must still refer to the same memory region  memTarget . For types that also implement  this can be described as: MtargetCount <- getCountMem memTarget unOff memTargetOff < unCount targetCount primal-memoryLeftover part of the  listSource> if any and the exact count of elements that have been loaded. primal-memory listSource - List with elements to load primal-memory memTarget6 - Mutable region where to load elements from the list primal-memoryLeftover part of the  listSource> if any and the exact count of elements that have been loaded. primal-memory listSource - List with elements to load primal-memory memTarget6 - Mutable region where to load elements from the list !"#$%&'()*+,-./0123456789:;<=>?@AB(c) Alexey Kuleshevich 2020BSD3(Alexey Kuleshevich <alexey@kuleshevi.ch> experimental non-portableNone.=>?FHSVX( primal-memoryWrap  into  primal-memoryUnwrap  to get the underlying . primal-memoryWrap  into  primal-memoryUnwrap  to get the underlying . primal-memory<Check if two mutable bytes pointers refer to the same memory primal-memorylThis function allows the change of state token. Use with care, because it can allow mutation to escape the  monad. primal-memorysAllocated memory is not cleared, so make sure to fill it in properly, otherwise you might find some garbage there. primal-memory.Fill the mutable array with zeros efficiently. primal-memory"Get the count of elements of type a that can fit into bytes as well as the slack number of bytes that would be leftover in case when total number of bytes available is not exactly divisable by the size of the element that will be stored in the memory chunk. primal-memory#Get the number of elements of type a that can fit into bytes as well as the slack number of bytes that would be leftover in case when total number of bytes available is not exactly divisable by the size of the element that will be stored in the memory chunk. primal-memoryIt is only guaranteed to convert the whole memory to a list whenever the size of allocated memory is exactly divisible by the size of the element, otherwise there will be some slack left unaccounted for. primal-memorySame as  primal-memorySame as  primal-memorySame as  primal-memory Exactly like , but restricted to . primal-memoryMAllocate new memory region and append second bytes region after the first one primal-memory1Perform atomic modification of an element in the  at the supplied index. Returns the actual value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory1Perform atomic modification of an element in the ! at the supplied index. Returns  if swap was successfull and false otherwise. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory Just like k, but also returns the actual value, which will match the supplied expected value if the returned flag is Note= - Bounds are not checked, therefore this function is unsafe. primal-memoryPerform atomic read of k at the supplied index. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memoryPerform a write into v at the supplied index atomically. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory1Perform atomic modification of an element in the = at the supplied index. Returns the artifact of computation bV. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory1Perform atomic modification of an element in the m at the supplied index. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory1Perform atomic modification of an element in the  at the supplied index. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory1Perform atomic modification of an element in the  at the supplied index. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory1Perform atomic modification of an element in the m at the supplied index. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory'Add a numeric value to an element of a , corresponds to () done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory'Add a numeric value to an element of a , corresponds to ()~ done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory.Subtract a numeric value from an element of a , corresponds to () done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory.Subtract a numeric value from an element of a , corresponds to ()| done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory,Binary conjunction (AND) of an element of a * with the supplied value, corresponds to () done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory,Binary conjunction (AND) of an element of a * with the supplied value, corresponds to ()| done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory9Negation of binary conjunction (NAND) of an element of a * with the supplied value, corresponds to \x y ->  (x  y) done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory:Negation of binary conjunction (NAND) of an element of a * with the supplied value, corresponds to \x y ->  (x  y)} done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory+Binary disjunction (OR) of an element of a * with the supplied value, corresponds to () done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe.  primal-memory+Binary disjunction (OR) of an element of a * with the supplied value, corresponds to ()| done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe.  primal-memory6Binary exclusive disjunction (XOR) of an element of a * with the supplied value, corresponds to  done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe.  primal-memory6Binary exclusive disjunction (XOR) of an element of a * with the supplied value, corresponds to | done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe.  primal-memory)Binary negation (NOT) of an element of a , corresponds to () done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe.  primal-memory)Binary negation (NOT) of an element of a , corresponds to ()| done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe.  primal-memoryFirst memory region primal-memorySecond memory region primal-memoryArray to be mutated primal-memoryIndex is in elements of a, rather than bytes. primal-memoryExpected old value primal-memory New value primal-memoryArray to be mutated primal-memoryIndex is in elements of a, rather than bytes. primal-memoryExpected old value primal-memory New value primal-memoryArray to be mutated primal-memoryIndex is in elements of a, rather than bytes. primal-memoryExpected old value primal-memory New value primal-memoryArray to be mutated primal-memoryIndex is in elements of a, rather than bytes. primal-memoryArray to be mutated primal-memoryIndex is in elements of a, rather than bytes. primal-memoryArray to be mutated primal-memoryIndex is in elements of a, rather than bytes. primal-memorybFunction that is applied to the old value and returns new value and some artifact of computation b primal-memoryArray to be mutated primal-memoryIndex is in elements of a, rather than bytes. primal-memory@Function that is applied to the old value and returns new value. primal-memoryArray to be mutated primal-memoryIndex is in elements of a, rather than bytes. primal-memoryCFunction that is applied to the old value and returns the new value primal-memoryArray to be mutated primal-memoryIndex is in elements of a, rather than bytes. primal-memoryCFunction that is applied to the old value and returns the new value primal-memoryArray to be mutated primal-memoryIndex is in elements of a, rather than bytes. primal-memoryCFunction that is applied to the old value and returns the new valueHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu !"#$%&'()*+,-./0123456789:;<=>?@A     t56-.+,@A'/&%!" #()*$012347:;<=89>?     (c) Alexey Kuleshevich 2020BSD3(Alexey Kuleshevich <alexey@kuleshevi.ch> experimental non-portableNone.=>?@AHIMSVX  primal-memory!A mutable array of bytes of type e primal-memory$An immutable array of bytes of type e( primal-memoryShrink mutable bytes to new specified count of elements. The new count must be less than or equal to the current count as reported by getCountMPrimArray.) primal-memory)Attempt to resize mutable bytes in place.:New bytes might be allocated, with the copy of an old one.@Old references should not be kept around to allow GC to claim it=Old references should not be used to avoid undefined behavior5 primal-memory)Read-only access, but it is not enforced.% primal-memorySize in number of bytes/ primal-memoryChunk of memory to fill primal-memoryOffset in number of elements primal-memoryNumber of cells to fill primal-memoryA value to fill the cells with !"#$%&'()*+,-./01"$%#()*+,'& !-./01(c) Alexey Kuleshevich 2020BSD3(Alexey Kuleshevich <alexey@kuleshevi.ch> experimental non-portableNone.=>?@AFHIVX#> primal-memoryMutable addressB primal-memoryImmutable read-only addressK primal-memoryShrink mutable address to new specified size in number of elements. The new count must be less than or equal to the current as reported by S.L primal-memoryShrink mutable address to new specified size in bytes. The new count must be less than or equal to the current as reported by T._ primal-memory0This is a unsafe cast therefore modification of + will be reflected in resulting immutable B. Pointer created with malloc cannot be converted to B and will result in ` primal-memory^Discarding the original ForeignPtr will trigger finalizers that were attached to it, because >6 does not retain any finalizers. Pointer created with malloc cannot be converted to > and will result in q primal-memoryO(1) - Cast an immutable B to an immutable  r primal-memoryO(1) - Cast an immutable B to an immutable  s primal-memoryO(n) - Convert an immutable   to an immutable B. In a most common case when  < is not backed by pinned memory, this function will return .t primal-memoryO(1) - Cast an immutable   to BR. Also returns the original length of ByteString, which will be less or equal to  countOfAddr in the produced B.u primal-memoryO(1) - Cast an immutable   to a mutable >R. Also returns the original length of ByteString, which will be less or equal to getCountOfMAddr in the produced >.Unsafe - Further modification of > will affect the source  v primal-memory1Perform atomic modification of an element in the >= at the supplied index. Returns the artifact of computation bV. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe.w primal-memory1Perform atomic modification of an element in the >! at the supplied index. Returns  if swap was successfull and false otherwise. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe.x primal-memory Just like wk, but also returns the actual value, which will match the supplied expected value if the returned flag is Note= - Bounds are not checked, therefore this function is unsafe.y primal-memory)Perform atomic read of an element in the >l at the supplied offset. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe.z primal-memory*Perform atomic write of an element in the >l at the supplied offset. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe.{ primal-memory1Perform atomic modification of an element in the >= at the supplied index. Returns the artifact of computation bV. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe.| primal-memory1Perform atomic modification of an element in the >m at the supplied index. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe.} primal-memory1Perform atomic modification of an element in the > at the supplied index. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe.~ primal-memory1Perform atomic modification of an element in the >m at the supplied index. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory'Add a numeric value to an element of a >, corresponds to () done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory'Add a numeric value to an element of a >, corresponds to ()~ done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory.Subtract a numeric value from an element of a >, corresponds to () done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory.Subtract a numeric value from an element of a >, corresponds to ()| done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory,Binary conjunction (AND) of an element of a >* with the supplied value, corresponds to () done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory,Binary conjunction (AND) of an element of a >* with the supplied value, corresponds to ()| done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory9Negation of binary conjunction (NAND) of an element of a >* with the supplied value, corresponds to \x y ->  (x  y) done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory:Negation of binary conjunction (NAND) of an element of a >* with the supplied value, corresponds to \x y ->  (x  y)} done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory+Binary disjunction (OR) of an element of a >* with the supplied value, corresponds to () done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory+Binary disjunction (OR) of an element of a >* with the supplied value, corresponds to ()| done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory6Binary exclusive disjunction (XOR) of an element of a >* with the supplied value, corresponds to  done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory6Binary exclusive disjunction (XOR) of an element of a >* with the supplied value, corresponds to | done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory)Binary negation (NOT) of an element of a >, corresponds to () done atomically. Returns the previous value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory)Binary negation (NOT) of an element of a >, corresponds to ()| done atomically. Returns the new value. Offset is in number of elements, rather than bytes. Implies a full memory barrier.Note= - Bounds are not checked, therefore this function is unsafe. primal-memory)Read-only access, but it is not enforced. v primal-memoryArray to be mutated primal-memoryIndex is in elements of e, rather than bytes. primal-memoryExpected old value primal-memory New valuew primal-memoryArray to be mutated primal-memoryIndex is in elements of e, rather than bytes. primal-memoryExpected old value primal-memory New valuex primal-memoryArray to be mutated primal-memoryIndex is in elements of e, rather than bytes. primal-memoryExpected old value primal-memory New valuey primal-memoryArray to be mutated primal-memoryIndex is in elements of e, rather than bytes.z primal-memoryArray to be mutated primal-memoryIndex is in elements of e, rather than bytes.{ primal-memoryArray to be mutated primal-memoryIndex is in elements of e, rather than bytes. primal-memorybFunction that is applied to the old value and returns new value and some artifact of computation b| primal-memoryArray to be mutated primal-memoryIndex is in elements of e, rather than bytes. primal-memory-Function that is applied to the current value} primal-memoryArray to be mutated primal-memoryIndex is in elements of e, rather than bytes. primal-memory)Function that is applied to the old value primal-memoryReturns the old value~ primal-memoryArray to be mutated primal-memoryIndex is in elements of e, rather than bytes primal-memory)Function that is applied to the old value primal-memoryReturns the new valueHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~_BCDEFHPRQNUVWefgcdXYZ>?@AGIJMKLp[TSOhijklmno\ab]^_`qrstuvwxyz{|}~(c) Alexey Kuleshevich 2020BSD3(Alexey Kuleshevich <alexey@kuleshevi.ch> experimental non-portableNoneHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuO !"#$%&'()*(+(,-().(+/012012034035035036037037 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b cdefghijklmnoppqrstuvwxyz{|}~          !"#$%&'()*+,-..//0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTTUVWWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~   8 9             !"#$%&'(&')&'*&'+&',&'-&'.&'/&'0&'1&'2&'3&'4&'5&'6&'7&'8&'9&':&';&'<&'=&'>&'?&'@&'A&'B&'C&'D&'E&'F&'G&'H&'I&'J&'K&'L&'M&'N&'O&'P&'Q&'R&'S&'T&'U&VW&VX&VY&VZ&V[&V\&V]&V^&V_&V`&Va&Vb&Vc&Vd&Ve&Vf&Vg&Vh&Vi&Vj&Vk&Vl&Vm&Vn&Vo&Vp&Vq&Vr&Vs&Vs&Vt&Vu&Vu&Vv&Vw&Vw&Vx&yz&yz&y{&|}&|~&|&&&(,primal-memory-0.2.0.0-Do3UKIB7Az1K5Sa9SkYoIdData.Prim.Memory.ForeignPtrData.Prim.Memory.ByteStringData.Prim.Memory.TextData.Prim.Memory.BytesData.Prim.Memory.PtrData.Prim.MemoryData.Prim.Memory.PrimArrayData.Prim.Memory.AddrData.Prim.Memory.Bytes.InternalfromMutableByteArray#toMutableByteArray#fromByteArray# toByteArray# toPinnedBytestoPinnedMBytesForeign.ForeignPtrmallocForeignPtrArraymallocPlainForeignPtrArrayData.Prim.Memory.InternalData.ByteStringpack ByteStringunpack Data.Bits.&. complement.|.xorbaseGHC.ForeignPtr ForeignPtrPlainPtr MallocPtrPlainForeignPtrForeignPtrContentscastForeignPtrunsafeForeignPtrToPtr FinalizerPtrFinalizerEnvPtrbytestring-0.10.8.2Data.ByteString.Short.InternalShortByteStringData.ByteString.Internal Data.ByteString.Builder.InternalBuilderSBSPS text-1.2.3.1Data.Text.InternalTextData.Text.ArrayaBAArraymaBAMArrayMBytesBytesPinnedPinInccompareByteOffBytes indexOffBytesindexByteOffBytes allocMBytesallocUnpinnedMBytesallocPinnedMBytesallocAlignedMBytescallocAlignedMBytesgetByteCountMBytes freezeMBytes thawBytesbyteCountBytes shrinkMBytes resizeMBytes reallocMBytesrelaxPinnedBytesrelaxPinnedMBytestoInconclusiveBytestoInconclusiveMBytes countBytesgetCountMBytes readOffMBytesreadByteOffMByteswriteOffMByteswriteByteOffMBytes isPinnedBytesisPinnedMBytes setMBytes toPtrBytes toPtrMBytes withPtrByteswithNoHaltPtrBytes withPtrMByteswithNoHaltPtrMBytestoForeignPtrBytestoForeignPtrMBytes isSameBytesisSamePinnedBytesbyteStringConvertErrorcopyPtrToMBytescopyByteOffPtrToMBytescopyBytesToPtrcopyByteOffBytesToPtrcopyMBytesToPtrcopyByteOffMBytesToPtrmovePtrToMBytesmoveByteOffPtrToMBytesmoveMBytesToPtrmoveByteOffMBytesToPtrcompareByteOffBytesToPtrcompareByteOffPtrToBytes MByteStringtoByteStringBytestoShortByteStringBytesfromShortByteStringBytestoBuilderBytesfromBuilderBytesfromLazyByteStringBytesfromByteStringByteswithPtrByteStringwithNoHaltPtrByteString PtrAccess toForeignPtr withPtrAccesswithNoHaltPtrAccesswithForeignPtrwithNoHaltForeignPtrtouchForeignPtr newForeignPtrnewForeignPtrEnvnewForeignPtr_mallocForeignPtrmallocCountForeignPtrmallocCountForeignPtrAlignedmallocByteCountForeignPtr mallocByteCountForeignPtrAlignedaddForeignPtrFinalizeraddForeignPtrFinalizerEnvmallocPlainForeignPtrmallocCountPlainForeignPtr!mallocCountPlainForeignPtrAlignedmallocByteCountPlainForeignPtr%mallocByteCountPlainForeignPtrAlignednewConcForeignPtraddForeignPtrConcFinalizerfinalizeForeignPtrplusOffForeignPtrplusByteOffForeignPtrminusByteOffForeignPtrminusOffForeignPtrminusOffRemForeignPtr$fPtrAccesssMBytes$fPtrAccesssBytes$fPtrAccesssMByteString$fPtrAccesssByteString$fPtrAccesssForeignPtrMText toBytesArrayfromBytesArraytoMBytesMArrayfromMBytesMArrayMemState unMemStateMemAlloc FrozenMemgetByteCountMemallocMemthawMem freezeMem resizeMemMemWrite readOffMemreadByteOffMem writeOffMemwriteByteOffMemmoveByteOffToMBytesMemmoveByteOffToPtrMemcopyByteOffMemmoveByteOffMemsetMemMemRead byteCountMem indexOffMemindexByteOffMemcopyByteOffToMBytesMemcopyByteOffToPtrMemcompareByteOffToPtrMemcompareByteOffToBytesMemcompareByteOffMemmodifyFetchOldMemmodifyFetchNewMemmodifyFetchOldMemMmodifyFetchNewMemM cycleMemNemptyMem singletonMem allocZeroMem createMemST createMemST_createZeroMemSTcreateZeroMemST_cloneMemcopyMemmoveMem thawCopyMem freezeCopyMem thawCloneMemfreezeCloneMem convertMemcountMem countRemMem getCountMemgetCountRemMemeqMem compareMem toListMemtoListSlackMem foldrCountMem fromListMemfromByteListMem fromListMemNfromListZeroMemNfromListZeroMemN_loadListByteOffMemNloadListByteOffMemloadListOffMemN loadListMemN loadListMemN_loadListOffMem loadListMem loadListMem_ toByteListMem showsHexMemwithScrubbedMem isSameMByteseqBytes compareBytescoerceStateMBytes emptyBytes isEmptyBytessingletonBytessingletonMBytes cloneBytes cloneMBytescopyBytesToMBytesmoveMBytesToMBytes createBytes createBytes_ createBytesSTcreateBytesST_ callocMBytes zeroMByteswithCloneMByteswithCloneMBytes_withCloneMBytesSTwithCloneMBytesST_ countRemBytesgetCountRemOfMBytes toListBytestoListSlackBytesloadListMBytesloadListMBytes_fromListBytesN_fromListBytesN fromListBytes appendBytes concatBytesensurePinnedBytesensurePinnedMBytes casMBytes casBoolMBytescasBoolFetchMBytesatomicReadMBytesatomicWriteMBytesatomicModifyMBytesatomicModifyMBytes_atomicModifyFetchOldMBytesatomicBoolModifyFetchOldMBytesatomicModifyFetchNewMBytesatomicAddFetchOldMBytesatomicAddFetchNewMBytesatomicSubFetchOldMBytesatomicSubFetchNewMBytesatomicAndFetchOldMBytesatomicAndFetchNewMBytesatomicNandFetchOldMBytesatomicNandFetchNewMBytesatomicOrFetchOldMBytesatomicOrFetchNewMBytesatomicXorFetchOldMBytesatomicXorFetchNewMBytesatomicNotFetchOldMBytesatomicNotFetchNewMBytesprefetchBytes0prefetchMBytes0prefetchBytes1prefetchMBytes1prefetchBytes2prefetchMBytes2prefetchBytes3prefetchMBytes3 MPrimArray PrimArray castPrimArrayfromBytesPrimArraytoBytesPrimArraycastMPrimArrayfromMBytesMPrimArraytoMBytesMPrimArray sizePrimArraygetSizeMPrimArrayallocMPrimArrayallocUnpinnedMPrimArrayallocPinnedMPrimArrayallocAlignedMPrimArrayfreezeMPrimArray thawPrimArrayshrinkMPrimArrayresizeMPrimArrayreallocMPrimArrayisPinnedPrimArrayisPinnedMPrimArrayreadMPrimArraywriteMPrimArray setMPrimArraycopyPrimArrayToMPrimArraymoveMPrimArrayToMPrimArray$fShowPrimArray$fIsStringPrimArray$fIsListPrimArray$fPtrAccesssPrimArray$fMemAllocMPrimArray$fPtrAccesssMPrimArray$fNFDataPrimArray$fSemigroupPrimArray$fMonoidPrimArray$fMemReadPrimArray$fNFDataMPrimArray$fMemWriteMPrimArrayMAddr mAddrAddr# mAddrMBytesAddr addrAddr# addrBytescastAddr castMAddr fromBytesAddr allocMAddr callocMAddr shrinkMAddrshrinkByteCountMAddr reallocMAddr plusOffAddr plusOffMAddr curOffAddr countAddr byteCountAddr getCountMAddrgetByteCountMAddr indexAddr indexOffAddrindexByteOffAddr withPtrAddr withAddrAddr#withNoHaltPtrAddr curOffMAddr withPtrMAddrtoForeignPtrAddrtoForeignPtrMAddrfromForeignPtrAddrfromForeignPtrMAddrwithAddrMAddr#withNoHaltPtrMAddrthawAddr freezeMAddrreadAddr readOffAddrreadByteOffAddr readMAddr readOffMAddrreadByteOffMAddr writeMAddr writeOffMAddrwriteByteOffMAddrcopyAddrToMAddrmoveMAddrToMAddrsetMAddrtoByteStringAddrtoShortByteStringAddrfromShortByteStringAddrfromByteStringAddrfromByteStringMAddr casOffMAddrcasBoolOffMAddrcasBoolFetchOffMAddratomicReadOffMAddratomicWriteOffMAddratomicModifyOffMAddratomicModifyOffMAddr_atomicModifyFetchOldOffMAddratomicModifyFetchNewOffMAddratomicAddFetchOldOffMAddratomicAddFetchNewOffMAddratomicSubFetchOldOffMAddratomicSubFetchNewOffMAddratomicAndFetchOldOffMAddratomicAndFetchNewOffMAddratomicNandFetchOldOffMAddratomicNandFetchNewOffMAddratomicOrFetchOldOffMAddratomicOrFetchNewOffMAddratomicXorFetchOldOffMAddratomicXorFetchNewOffMAddratomicNotFetchOldOffMAddratomicNotFetchNewOffMAddr prefetchAddr0prefetchMAddr0 prefetchAddr1prefetchMAddr1 prefetchAddr2prefetchMAddr2 prefetchAddr3prefetchMAddr3prefetchOffAddr0prefetchOffMAddr0prefetchOffAddr1prefetchOffMAddr1prefetchOffAddr2prefetchOffMAddr2prefetchOffAddr3prefetchOffMAddr3 $fMemReadAddr$fPtrAccesssAddr $fNFDataAddr $fMonoidAddr$fSemigroupAddr $fIsListAddr$fIsStringAddr $fShowAddr$fEqAddr$fMemWriteMAddr$fMemAllocMAddr$fPtrAccesssMAddr $fNFDataMAddrcastPinnedMBytesghc-primGHC.Prim ByteArray#MutableByteArray#castForeignPtrToBytescopyByteOffBytesToMBytesmoveByteOffMBytesToMBytescastStateMBytescastPinnedBytesonForeignPtrContentscoerceData.Typeable.InternalTypeableGHC.Base Semigroup<>sconcatstimesMonoidmemptymappendmconcat GHC.TypesIntGHC.IntInt8Int16Int32Int64 RealWorldWordGHC.WordWord8Word16Word32Word64GHC.PtrPtrFunPtr CoercibleData.Semigroupoption mtimesDefaultdiffcycle1MingetMinMaxgetMaxArgArgMinArgMaxFirstgetFirstLastgetLast WrappedMonoid WrapMonoid unwrapMonoidOption getOption Data.MonoidApgetApData.Semigroup.Internal stimesMonoidstimesIdempotentDualgetDualEndoappEndoAllgetAllAnygetAnySumgetSumProduct getProductAltgetAlt Data.ProxyProxy Foreign.Ptr intPtrToPtr ptrToIntPtr wordPtrToPtr ptrToWordPtrWordPtrIntPtrcastPtrToFunPtrcastFunPtrToPtr castFunPtr nullFunPtrminusPtralignPtrplusPtrcastPtrnullPtr byteSwap64 byteSwap32 byteSwap16stimesIdempotentMonoid%primal-0.2.0.0-9Z2xO2cZcdkIq350JNtMUjForeign.Prim.PtrfreeHaskellFunPtrprefetchOffPtr3prefetchOffPtr2prefetchOffPtr1prefetchOffPtr0 prefetchPtr3 prefetchPtr2 prefetchPtr1 prefetchPtr0atomicNotFetchNewOffPtratomicNotFetchOldOffPtratomicXorFetchNewOffPtratomicXorFetchOldOffPtratomicOrFetchNewOffPtratomicOrFetchOldOffPtratomicNandFetchNewOffPtratomicNandFetchOldOffPtratomicAndFetchNewOffPtratomicAndFetchOldOffPtratomicSubFetchNewOffPtratomicSubFetchOldOffPtratomicAddFetchNewOffPtratomicAddFetchOldOffPtratomicModifyFetchNewOffPtratomicModifyFetchOldOffPtratomicModifyOffPtr_atomicModifyOffPtr casOffPtrcompareByteOffPtrToPtrcomparePtrToPtrmoveByteOffPtrToPtr movePtrToPtrcopyByteOffPtrToPtr copyPtrToPtrminusOffRemPtr minusOffPtrminusByteOffPtr plusOffPtrplusByteOffPtrwritePtrreadPtrwriteByteOffPtr writeOffPtrreadByteOffPtr readOffPtr setOffPtr Data.PrimprefetchValue3prefetchValue2prefetchValue1prefetchValue0fromByteOffRem fromByteOff unOffBytes# unOffBytes toByteOffoffToByteCount offToCount offForTypeoffForProxyTypeOffromByteCountRem fromByteCount countForTypecountForProxyTypeOfcountToByteOff countToOff toByteCount unCountBytes unCountBytes#alignmentProxy alignmentType alignmentbyteCountProxy byteCountType byteCountSizeunSizeCountunCountOffunOffData.Prim.AtomAtomunAtomData.Prim.AtomicAtomic AtomicCount AtomicBitsData.Prim.ClassPrimControl.Prim.Monad.InternalRW MonadPrimcastByteStringBytesData.ByteString.Lazy.InternalForeign.ForeignPtr.ImpmallocForeignPtrBytesmallocForeignPtrAlignedBytesIOGHC.IO.Exception HeapOverflowGHC.STrunSTLTGTFalseEQforByteOffMemM_GHC.ShowShowSloadListByteOffHelperMMemView mmvOffsetmmvCountmmvMemMemViewmvOffsetmvCountmvMemdefaultResizeMem appendMem concatMemclone mapByteMemimapByteOffMem mapByteMemMmapByteOffMemM loopShortM loopShortM'izipWithByteOffMemM_izipWithOffMemM_STTrueGHC.Num+- GHC.MaybeNothing