,$      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_` a b c d e f g h i j k l m n o p q r s t u v w xyz{|}~    (c) Vincent Hanquez 2014 BSD-styleVincent Hanquez provisionalnon-portable (requires POSIX)NoneMemory synchronization flagsperform asynchronous write.perform synchronous write.invalidate cache data.Advice to put on memory.only define the posix one. no specific advice, the default.BExpect page references in random order. No readahead should occur.RExpect page references in sequential order. Page should be readahead aggressively.IExpect access in the near future. Probably a good idea to readahead early(Do not expect access in the near future.Memory protection Mapping flag)memory changes are shared between process%memory changes are private to processMap pages of memory.vIf fd is present, this memory will represent the file associated. Otherwise, the memory will be an anonymous mapping.use mmapUnmap pages of memoryuse munmap7give advice to the operating system about use of memorycall madvise%lock a range of process address spacecall mlock'unlock a range of process address spacecall munlock set protection of memory mappingcall mprotect4memorySync synchronize memory with physical storage.EOn an anonymous mapping this function doesn't have any effect. call msync&Return the operating system page size.call sysconf$*The address to map to if MapFixed is used.The length of the mapping1the memory protection associated with the mapping BSD-style#Vincent Hanquez <vincent@snarc.org> experimentalunknownSafe BSD-style#Vincent Hanquez <vincent@snarc.org> experimentalunknownSafe, BSD-style#Vincent Hanquez <vincent@snarc.org> experimentalunknownSafeBCreate a new temporary buffer1xor bytes from source1 and source2 to destination d = s1 xor s22s1, nor s2 are modified unless d point to s1 or s2:xor bytes from source with a specific value to destinationd = replicate (sizeof s) v  s Copy a set number of bytes from src to dstSet $n number of bytes to the same value v'Check if two piece of memory are equals8Compare two piece of memory and returns how they compare2A constant time equality test for 2 Memory bufferscompared to normal equality function, this function will go over all the bytes present before yielding a result even when knowing the overall result early in the processing.   BSD-style#Vincent Hanquez <vincent@snarc.org>stableCompatNoneB                BSD-style#Vincent Hanquez <vincent@snarc.org>stableCompatNoneB$byteswap Word# to or from Big Endian0on a big endian machine, this function is a nop.'byteswap Word# to or from Little Endian3on a little endian machine, this function is a nop.VSimple compatibility for byteswap the lower 32 bits of a Word# at the primitive levelpSimple wrapper to handle pre 7.8 and future, where most comparaison functions don't returns a boolean anymore.=Apply or or another function if 8 divides the number of bytesnumber of bytes?if it divided by 8, the argument is the number of 8 bytes words'if it doesn't, just the number of bytes BSD-style#Vincent Hanquez <vincent@snarc.org>stableCompatNoneB BSD-style#Vincent Hanquez <vincent@snarc.org>stableGoodNoneperform io for hashes that do allocation and ffi. unsafeDupablePerformIO is used when possible as the computation is pure and the output is directly linked to the input. we also do not modify anything after it has been returned to the user.  BSD-style#Vincent Hanquez <vincent@snarc.org> experimentalgoodNoneBIFNV1(a) hash (64 bit variants) FNV1(a) hash (32 bit variants)!6compute FNV1 (32 bit variant) of a raw piece of memory"7compute FNV1a (32 bit variant) of a raw piece of memory#6compute FNV1 (64 bit variant) of a raw piece of memory$7compute FNV1a (64 bit variant) of a raw piece of memory !"#$ !"#$  !"#$ BSD-style#Vincent Hanquez <vincent@snarc.org> experimentalunknownSafe .A simple Extended Word128 composed of 2 Word64      BSD-style#Vincent Hanquez <vincent@snarc.org>stablegoodNoneI (Class of types that can be byte-swapped.e.g. Word16, Word32, Word64Big Endian valueLittle Endian valuerepresent the CPU endiannessBig endian system stores bytes with the MSB as the first byte. Little endian system stores bytes with the LSB as the first byte.#middle endian is purposely avoided.Return the system endianness.Convert a value in cpu endianess to big endian5Convert from a big endian value to the cpu endianness1Convert a value in cpu endianess to little endian8Convert from a little endian value to the cpu endianness% ! % ! BSD-style#Vincent Hanquez <vincent@snarc.org> experimentalgoodNone*Siphash tag value, SigHash Key&;produce a siphash with a key and a memory pointer + length.'same as &U, except also specifies the number of sipround iterations for compression and digest.()*+,-&' siphash C siphash Dkey for the hashmemory pointerlength of the data*+,-&'()*+,-&' BSD-style#Vincent Hanquez <vincent@snarc.org> experimentalunknownNoneBOT.'Transform a number of bytes pointed by src$ to base64 binary representation in dst`The destination memory need to be of correct size, otherwise it will lead to really bad things./'Transform a number of bytes pointed by src/ to, URL-safe base64 binary representation in dstJ. The result will be either padded or unpadded, depending on the boolean padded argument.`The destination memory need to be of correct size, otherwise it will lead to really bad things.1GGet the length needed for the destination buffer for a base64 decoding.9if the length is not a multiple of 4, Nothing is returned29Get the length needed for the destination buffer for an  .http://tools.ietf.org/html/rfc4648#section-3.2unpadded base64 decoding.If the length of the encoded string is a multiple of 4, plus one, Nothing is returned. Any other value can be valid without padding.5convert from base64 in src to binary in dst%, using the number of bytes specifiedthe user should use unBase64Length to compute the correct length, or check that the length specification is proper. no check is done here. ./0*+1234,-.5./012345./012543 ./0*+1234,-.5 BSD-style&Nicolas DI PRIMA <nicolas@di-prima.fr> experimentalunknownNoneBOT6'Transform a number of bytes pointed by.+src in the base32 binary representation in dst\destination memory need to be of correct size, otherwise it will lead to really bad things.7GGet the length needed for the destination buffer for a base32 decoding.9if the length is not a multiple of 8, Nothing is returned8convert from base32 in src to binary in (dst, using the number of bytes specifiedthe user should use unBase32Length to compute the correct length, or check that the length specification is proper. no check is done here.6inputoutput input len/7806786786/780 BSD-style#Vincent Hanquez <vincent@snarc.org> experimentalunknownNoneBOT9)Transform a raw memory to an hexadecimal 1user beware, no checks are made:'Transform a number of bytes pointed by.0src in the hexadecimal binary representation in dst\destination memory need to be of correct size, otherwise it will lead to really bad things.2Convert a value Word to two Word9s containing the hexadecimal representation of the Word#;convert a base16 src in dst.n need to even9a with1 type of function to hold reference to the objectlength in bytes:destination memory source memorynumber of bytes2;9:;9:;9:2; BSD-style#Vincent Hanquez <vincent@snarc.org>stableGoodNone<0Class to allocate new ByteArray of specific size= allocate n& bytes and perform the given operation>7Class to Access size properties and data of a ByteArray?)Return the length in bytes of a bytearray@Allow to use using a pointer <=>?@345678<=>?@<=>?@345678 BSD-style#Vincent Hanquez <vincent@snarc.org>StableGHCNoneBA=ScrubbedBytes is a memory chunk which have the properties of:+Being scrubbed after its goes out of scope.6A Show instance that doesn't actually show any content#A Eq instance that is constant timeA9:;<=>?@ABCDEFGHIJKLAA9:;<=>?@ABCDEFGHIJKL BSD-style#Vincent Hanquez <vincent@snarc.org>stableGoodNoneBQAllocate a new bytearray of specific size, and run the initializer on this memoryCQAllocate a new bytearray of specific size, and run the initializer on this memoryD similar to B: but hide the allocation and initializer in a pure contextE similar to C: but hide the allocation and initializer in a pure contextFCreate an empty byte arrayGCheck if a byte array is emptyH%Pack a list of bytes into a bytearrayI(Un-pack a bytearray into a list of bytesJPreturns the first byte, and the remaining bytearray if the bytearray is not nullK&Create a byte array from a single byteL%prepend a single byte to a byte arrayM$append a single byte to a byte arrayN&Create a xor of bytes between a and b.9the returns byte array is the size of the smallest input.O@return a specific byte indexed by a number from 0 in a bytearray"unsafe, no bound checking are doneP7Split a bytearray at a specific length in two bytearrayQTake the first n byte of a bytearrayRdrop the first n byte of a bytearrayS%Split a bytearray at the point where pred becomes invalidT-Concatenate bytearray into a larger bytearrayU!append one bytearray to the otherVJDuplicate a bytearray into another bytearray, and run an initializer on itW Similar to V> but also provide a way to return a value from the initializerX Similiar to V5 but expect the resulting bytearray in a pure contextYFCreate a bytearray of a specific size containing a repeated byte valueZ6Create a bytearray of a specific size initialized to 0[!Check if two bytearray are equalsUThis is not constant time, as soon some byte differs the function will returns. use \+ in sensitive context where timing matters.\;A constant time equality test for 2 ByteArrayAccess values._If values are of 2 different sizes, the function will abort early without comparing any bytes.compared to == , this function will go over all the bytes present before yielding a result even when knowing the overall result early in the processing.]:Check if any element of a byte array satisfies a predicate^9Check if all elements of a byte array satisfy a predicate_0Convert a bytearray to another type of bytearrayBCDEMFGHIJKLMNOPQRSTUVWXYZ[\]^_BCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_BCDEMFGHIJKLMNOPQRSTUVWXYZ[\]^_  BSD-style#Vincent Hanquez <vincent@snarc.org> experimentalportableNoneOT`"Simple ByteString parser structureN?The continuation of the next buffer value, and the parsed valueO<The continuation of the current buffer, and the error stringa3Simple parsing result, that represent respectively:failure: with the error message+continuation: that need for more input data9success: the remaining unparsed data and the parser valuee&Run a parser on an @initial byteArray.|If the Parser need more data than available, the @feeder function is automatically called and fed to the More continuation.f*Run a Parser on a ByteString and return a ah!Get the next byte from the parseri)Parse a specific byte at current positionQif the byte is different than the expected on, this parser will raise a failure.j/Parse a sequence of bytes from current positiongif the following bytes don't match the expected bytestring completely, the parser will raise a failurek7Take a storable from the current position in the streaml5Take @n bytes from the current position in the streammLTake bytes while the @predicate hold from the current position in the streamn@Take the remaining bytes from the current position in the streamo5Skip @n bytes from the current position in the streampLSkip bytes while the @predicate hold from the current position in the streamqDSkip all the remaining bytes from the current position in the stream`PQNOabcdefRSTghijklmnopqrstuvw`acbdefghijklmnopq`abcdfegihjlmnopqk`PQNOabcdefRSTghijklmnopqrstuvw BSD-style&Nicolas DI PRIMA <nicolas@di-prima.fr>stableGoodNonexa view on a given bytesEquality test in constant timey"create a view on a given bytearrayCThis function update the offset and the size in order to guarantee: offset >= 0 size >= 0offset < lengthsize =< length - offsetz&create a view from the given bytearray{Wcreate a view from the given byte array starting after having dropped the fist n bytes xUVWXYythe byte array we put a view on%the offset to start the byte array onthe size of the viewz byte araysize of the view{ byte array7the number of bytes do dropped before creating the viewZ[\]xyz{ xUVWXYyz{Z[\] BSD-style#Vincent Hanquez <vincent@snarc.org>stableGoodNone|*A simple abstraction to a piece of memory.fDo beware that garbage collection related to piece of memory could be triggered before this is used.XOnly use with the appropriate handler has been used (e.g. withForeignPtr on ForeignPtr)~>Increase the memory view while reducing the size of the windowkthis is useful as an abtraction to represent the current offset in a buffer, and the remaining bytes left.|}~^|}~|}~^ BSD-StyleNoneSimple ByteArray PackerPacking result:=PackerMore: the next state of Packing with an arbitrary valuePackerFail: an error happened_run a sized action`run a sized actionabcdef_`ghiab_` abcdef_`ghi  BSD-style#Vincent Hanquez <vincent@snarc.org>stableGoodNoneSTransform a bytearray at a specific offset into a Word64 tagged as BE (Big Endian)no bounds checking. unsafeVTransform a bytearray at a specific offset into a Word64 tagged as LE (Little Endian)no bounds checking. unsafe Serialize a Word64 to a  ByteArray in big endian formatmap blocks of 128 bits of a bytearray, creating a new bytestring of equivalent size where each blocks has been mapped through f"no length checking is done. unsafe~map blocks of 64 bits of a bytearray, creating a new bytestring of equivalent size where each blocks has been mapped through f"no length checking is done. unsafe BSD-style#Vincent Hanquez <vincent@snarc.org> experimentalgoodNone8Compute the SipHash tag of a byte array for a given key.# is equivalent to 'sipHashWith 2 4'8Compute the SipHash tag of a byte array for a given key.2The user can choose the C and D numbers of rounds.calling # is equivalent to 'sipHashWith 2 4'2Compute the FNV1 32 bit hash value of a byte array3Compute the FNV1a 32 bit hash value of a byte array2Compute the FNV1 64 bit hash value of a byte array3Compute the FNV1a 64 bit hash value of a byte arrayc roundsd roundskey data to hash *+,-,-*+    BSD-style#Vincent Hanquez <vincent@snarc.org> experimentalunknownNone Different bases that can be usedSee  "http://tools.ietf.org/html/rfc4648RFC46489 for details. In particular, Base64 can be standard or  ,http://tools.ietf.org/html/rfc4648#section-5URL-safeD. URL-safe encoding is often used in other specifications without  .http://tools.ietf.org/html/rfc4648#section-3.2padding characters.similar to hexadecimalstandard Base64unpadded URL-safe Base64<Base64 as used in OpenBSD password encoding (such as bcrypt)GConvert a bytearray to the equivalent representation in a specific BasePTry to Convert a bytearray from the equivalent representation in a specific Base BSD-style#Vincent Hanquez <vincent@snarc.org>stableGoodNoneBSimplest Byte Arrayjklmnopqrstuvwxyz{|}~jklmnopqrstuvwxyz{|}~ BSD-style#Vincent Hanquez <vincent@snarc.org>stableGoodNoneB+<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_xyz{|},>?@<=A|}~xyz{BDCEHIJFKLMGYZVQRS_WXPNO[\]^UT  BSD-Style#Vincent Hanquez <vincent@snarc.org> experimentalunknownNone >Fill a given sized buffer with the result of the Packer action/Pack the given packer into the given bytestring6Put a storable from the current position in the stream8Put a Byte Array from the current position in the stream)If the ByteArray is null, then do nothing7Skip some bytes from the current position in the streamCSkip the size of a storable from the current position in the stream:Fill up from the current position in the stream to the endIt is equivalent to: #fillUpWith s == fillList (repeat s)UWill put the given storable list from the current position in the stream to the end.jThis function will fail with not enough storage if the given storable can't be written (not enough space)Example: *> pack (fillList $ [1..] :: Word8) 9 "\1\2\3\4\5\6\7\8\9" > pack (fillList $ [1..] :: Word32) 4 "\1\0\0\0" > pack (fillList $ [1..] :: Word32) 64 .. <..succesful..> > pack (fillList $ [1..] :: Word32) 1 .. <.. not enough space ..> > pack (fillList $ [1..] :: Word32) 131 .. <.. not enough space ..>/put Word8 in the current position in the streamHput Word16 in the current position in the stream /! use Host EndiannessHput Word32 in the current position in the stream /! use Host Endianness   !"#$%%&&''()*++,--./0123456789:;<=>?@ABBCCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu v w x y z { | } ~  g w         ^                      \  d !"#$%&'()*+,-./0123456789:;<=>?@ABCCDEFGHIJKLMNOPQRWSTUVWXYZ[\]^_`abcdef g h v i j k lmnopqrstuvwxyz{|}~Y $memory-0.14.8-ELWbq9jC1C9440YaMPtYZrData.Memory.PtrMethodsData.ByteArray.HashData.Memory.ExtendedWordsData.Memory.EndianData.Memory.Encoding.Base64Data.Memory.Encoding.Base32Data.Memory.Encoding.Base16Data.ByteArrayData.ByteArray.ParseData.ByteArray.PackData.ByteArray.MappingData.ByteArray.EncodingData.Memory.MemMap.PosixData.Memory.Internal.DeepSeqData.Memory.Internal.Imports!Data.Memory.Internal.CompatPrim64Data.Memory.Internal.CompatPrimData.Memory.Internal.ScrubberData.Memory.Internal.CompatData.Memory.Hash.FNVData.Memory.Hash.SipHashData.ByteArray.TypesData.ByteArray.ScrubbedBytesData.ByteArray.MethodsData.ByteArray.ViewData.ByteArray.MemViewData.ByteArray.Pack.InternalData.ByteArray.BytesmemCreateTemporarymemXor memXorWithmemCopymemSetmemEqual memCompare memConstEqual FnvHash64 FnvHash32Word128 $fShowWord128 $fEqWord128ByteSwapBEunBELEunLE Endianness LittleEndian BigEndiangetSystemEndiannesstoBEfromBEtoLEfromLE$fByteSwapWord64$fByteSwapWord32$fByteSwapWord16$fShowEndianness$fEqEndianness$fShowLE$fEqLE $fStorableLE$fShowBE$fEqBE $fStorableBESipHashSipKeytoBase64 toBase64URLtoBase64OpenBSDunBase64LengthunBase64LengthUnpaddedfromBase64OpenBSDfromBase64URLUnpadded fromBase64toBase32unBase32Length fromBase32showHexadecimal toHexadecimalfromHexadecimal ByteArrayallocRetByteArrayAccesslength withByteArray ScrubbedBytesalloccreateallocAndFreeze unsafeCreateemptynullpackunpackuncons singletonconssnocxorindexsplitAttakedropspanconcatappendcopycopyRet copyAndFreeze replicatezeroeqconstEqanyallconvertParserResult ParseFail ParseMoreParseOK parseFeedparsehasMoreanyBytebytebytes takeStorable takeWhiletakeAllskip skipWhileskipAll$fAlternativeParser$fMonadPlusParser $fMonadParser$fApplicativeParser$fFunctorParser $fShowResultViewviewtakeViewdropViewMemView memViewPlusPacker PackerMore PackerFailtoW64BEtoW64LE fromW64BE mapAsWord128 mapAsWord64sipHash sipHashWithfnv1Hash fnv1aHash fnv1_64Hash fnv1a_64HashBaseBase16Base32Base64Base64URLUnpadded Base64OpenBSD convertToBaseconvertFromBase $fShowBase$fEqBaseBytesfill putStorableputBytes skipStorable fillUpWithfillListputWord8 putWord16 putWord32MemorySyncFlagMemorySyncAsyncMemorySyncSyncMemorySyncInvalidate MemoryAdviceMemoryAdviceNormalMemoryAdviceRandomMemoryAdviceSequentialMemoryAdviceWillNeedMemoryAdviceDontNeedMemoryProtection MemoryMapFlagMemoryMapSharedMemoryMapPrivate memoryMap memoryUnmap memoryAdvise memoryLock memoryUnlock memoryProtect memorySyncsysconfPageSizeMemoryProtectionNoneMemoryProtectionReadMemoryProtectionWriteMemoryProtectionExecute c_sysconf c_munlockc_mlock c_mprotectc_msync c_madvisec_munmapc_mmapcvalueOfMemoryProtscvalueOfMemorySyncdeepseq-1.4.2.0Control.DeepSeqNFDatarnfbaseGHC.Base<$ Applicativepure<*>*><*ghc-prim GHC.TypesWordGHC.WordWord8Word16Word32Word64Data.TraversableforMControl.Applicativeoptional WrappedMonad WrapMonad unwrapMonad WrappedArrow WrapArrow unwrapArrowZipList getZipList Control.ArrowfirstsecondData.Functor.ConstConstgetConst Data.FoldableforM_ byteSwap64 byteSwap32 byteSwap16 Data.Functorvoid<$>liftA3liftA2liftA<**> Alternative<|>somemany Data.Bitsc_memcpyc_memsetInt64#Word64#OutBool eqWord64# neWord64# ltWord64# leWord64# gtWord64# geWord64#eqInt64#neInt64#ltInt64#leInt64#gtInt64#geInt64# quotInt64# remInt64#and64#or64#xor64#not64#uncheckedShiftL64#uncheckedShiftRL64#int64ToWord64#word64ToInt64# intToInt64# int64ToInt# wordToWord64# word64ToWord# timesWord64#w64#be32Primle32Primbyteswap32Prim booleanPrimeitherDivideBy8# getScrubber scrubBytes unsafeDoIO unsafeShiftR unsafeShiftLpopCountfnv1fnv1afnv1_64fnv1a_64byteSwaphashhashWith InternalStatetoBase64Internalconvert3fromBase64UnpaddedrsetURL rsetOpenBSDtoBase32Per5BytesfromBase32Per8BytesString convertByteuarrayRecastW8$fByteArrayUArray$fByteArrayAccessString$fByteArrayAccessUArray$fByteArrayByteString$fByteArrayAccessByteStringnewScrubbedBytesscrubbedBytesAllocRetscrubbedBytesAllocscrubbedBytesConcatscrubbedBytesAppendsizeofScrubbedByteswithPtrtouchScrubbedBytesscrubbedBytesEqscrubbedBytesComparescrubbedFromChar8$fByteArrayScrubbedBytes$fByteArrayAccessScrubbedBytes$fIsStringScrubbedBytes$fNFDataScrubbedBytes$fMonoidScrubbedBytes$fOrdScrubbedBytes$fEqScrubbedBytes$fShowScrubbedBytesinlineUnsafeCreateSuccessFailure runParsergetMoregetAllflushAll viewOffsetviewSizeunViewviewUnpackChars$fByteArrayAccessView $fShowView $fOrdView$fEqView$fByteArrayAccessMemView actionPackeractionPackerWithRemain runPacker_ fmapPacker returnPacker bindPacker appendPacker $fMonadPacker$fApplicativePacker$fFunctorPackernewBytes touchBytes sizeofBytes bytesAlloc bytesConcat bytesAppend bytesAllocRet bytesLength withBytesbytesEq bytesComparebytesUnpackChars$fByteArrayBytes$fByteArrayAccessBytes $fNFDataBytes $fMonoidBytes $fOrdBytes $fEqBytes $fShowBytesfillUpWithWord8'