úÎbÏXx¦      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|} ~  € ‚ ƒ „ … † ‡ ˆ ‰ Š ‹ Œ Ž ‘ ’ “ ” • – — ˜ ™ š › œ ž Ÿ   ¡ ¢ £ ¤ ¥ tested on GHC only experimental Simon Meier <iridcode@gmail.com>NonePut the given builder. CIgnore the value of a put and only exploit its output side effect. Lift the given IO action.  ¦§¨     ¦§¨tested on GHC only experimental Simon Meier <iridcode@gmail.com>None&A write of a bounded number of bytes. When defining a function write :: a -> Write for some a , then it is F important to ensure that the bound on the number of bytes written is  data-independent. Formally,  4 forall x y. getBound (write x) = getBound (write y)HThe idea is that this data-independent bound is specified such that the P compiler can optimize the check, if there are enough free bytes in the buffer, K to a single subtraction between the pointer to the next free byte and the J pointer to the end of the buffer with this constant bound of the maximal  number of bytes to be written. >Changing a sequence of bytes starting from the given pointer. s are ? the most primitive buffer manipulation. In most cases, you don' t use the  explicitely but as part of a ', which also tells how many bytes will  be changed at most.  Extract the  action of a write. Run the  action of a write. AExtract the maximal number of bytes that this write could write. GExtract the maximal number of bytes that this write could write in any @ case. Assumes that the bound of the write is data-independent.  pokeN size io- creates a write that denotes the writing of size bytes ! to a buffer using the IO action io . Note that io MUST write EXACTLY size  bytes to the buffer! exactWrite size io8 creates a bounded write that can later be converted to  a builder that writes exactly size bytes. Note that io MUST write  EXACTLY size bytes to the buffer! !boundedWrite size write creates a bounded write from a write that does  not write more than size bytes. "writeLiftIO io write creates a write executes the io action to compute ! the value that is then written. #writeIf p wTrue wFalse x creates a  with a  equal to wTrue  x, if p x and equal to wFalse x" otherwise. The bound of this new  ) is the maximum of the bounds for either . This yields a data % independent bound, if the bound for wTrue and wFalse is already data  independent. $ICompare the value to a test value and use the first write action for the @ equal case and the second write action for the non-equal case. %8TODO: Test this. It might well be too difficult to use.  FIXME: Better name required! &JA write combinator useful to build decision trees for deciding what value H to write with a constant bound on the maximal number of bytes written. ''Create a builder that execute a single . ) Construct a / writing a list of data one element at a time. *Write a storable value. +BA builder that serializes a storable value. No alignment is done. ,DA builder that serializes a list of storable values by writing them F consecutively. No alignment is done. Parsing information needs to be  provided externally. ©ª(Name of caller: for debugging purposes.  !"#$%&'()*+,«¬ !"#$%&'()*+, !"#$%&'()*+,©ª !"#$%&'()*+,«¬tested on GHC only experimental Simon Meier <iridcode@gmail.com>None-A buffer allocation strategy (buf0, nextBuf) specifies the initial / buffer to use and how to compute a new buffer nextBuf minSize buf with at  least size minSize from a filled buffer buf. The double nesting of the  IO? monad helps to ensure that the reference to the filled buffer buf is 3 lost as soon as possible, but the new buffer doesn't have to be allocated  too early. . A buffer Buffer fpbuf p0 op ope( describes a buffer with the underlying  byte array  fpbuf..ope, the currently written slice p0..op and the free  space op..ope. /*The size of the free space of the buffer. 0-The size of the written slice in the buffer. 18The size of the whole byte array underlying the buffer. 2allocBuffer size allocates a new buffer of size size. 3HResets the beginning of the next slice and the next free byte such that ' the whole buffer can be filled again. 4JConvert the buffer to a bytestring. This operation is unsafe in the sense K that created bytestring shares the underlying byte array with the buffer. N Hence, depending on the later use of this buffer (e.g., if it gets reset and 5 filled again) referential transparency may be lost. 50Convert a buffer to a non-empty bytestring. See 4 for 6 the explanation of why this operation may be unsafe. 6!Update the end of slice pointer. 7*Execute a build step on the given buffer. 8DMove the beginning of the slice to the next free byte such that the J remaining free space of the buffer can be filled further. This operation J is safe and can be used to fill the remaining part of the buffer after a . direct insertion of a bytestring or a flush. 9IThe simplest buffer allocation strategy: whenever a buffer is requested, K allocate a new one that is big enough for the next build step to execute. KNOTE that this allocation strategy may spill quite some memory upon direct H insertion of a bytestring by the builder. Thats no problem for garbage H collection, but it may lead to unreasonably high memory consumption in  special circumstances. :CAn unsafe, but possibly more efficient buffer allocation strategy: K reuse the buffer, if it is big enough for the next build step to execute. ;Execute a put on a buffer. 2TODO: Generalize over buffer allocation strategy. -.­/0123456789:;-./0123456789:;./012386745-9:;-.­/0123456789:; tested on GHC only experimental Simon Meier <iridcode@gmail.com>None®¯°®¯°®¯°tested on GHC only experimental Simon Meier <iridcode@gmail.com>None <GDefault size (~32kb) for the buffer that becomes a chunk of the output  stream once it is filled. =CThe minimal length (~4kb) a buffer must have before filling it and 0 outputting it as a chunk of the output stream. 6This size determines when a buffer is spilled after a @ or a direct K bytestring insertion. It is also the size of the first chunk generated by  B. >BThe default length (64) for the first buffer to be allocated when  converting a  to a lazy bytestring. See A for further explanation. ?DThe maximal number of bytes for that copying is cheaper than direct M insertion into the output stream. This takes into account the fragmentation 6 that may occur in the output buffer due to the early @ implied by the  direct bytestring insertion. ? = 2 * =±&Prepend the chunk if it is non-empty. @EOutput all data written in the current buffer and start a new chunk. FThe use of this function depends on how the resulting bytestrings are  consumed. @; is possibly not very useful in non-interactive scenarios. D However, it is kept for compatibility with the builder provided by  Data.Binary.Builder.  When using B to extract a lazy ² from a  D, this means that a new chunk will be started in the resulting lazy  ²6. The remaining part of the buffer is spilled, if the G reamining free space is smaller than the minimal desired buffer size. ARun a  with the given buffer sizes. &Use this function for integrating the  type with other libraries ! that generate lazy bytestrings. JNote that the builders should guarantee that on average the desired chunk E size is attained. Builders may decide to start a new buffer and not N completely fill the existing buffer, if this is faster. However, they should E not spill too much of the buffer, if they cannot compensate for it. A call 4toLazyByteStringWith bufSize minBufSize firstBufSize will generate K a lazy bytestring according to the following strategy. First, we allocate  a buffer of size  firstBufSize+ and start filling it. If it overflows, we  allocate a buffer of size  minBufSize$ and copy the first buffer to it in N order to avoid generating a too small chunk. Finally, every next buffer will  be of size bufSize5. This, slow startup strategy is required to achieve  good speed for short (<2200 bytes) resulting bytestrings, as for them the L allocation cost is of a large buffer cannot be compensated. Moreover, this E strategy also allows us to avoid spilling too much memory for short  resulting bytestrings. Note that setting firstBufSize >= minBufSize implies that the first buffer G is no longer copied but allocated and filled directly. Hence, setting  firstBufSize = bufSize5 means that all chunks will use an underlying buffer  of size bufSize:. This is recommended, if you know that you always output  more than  minBufSize bytes. BExtract the lazy ²- from the builder by running it with default A buffer sizes. Use this function, if you do not have any special . considerations with respect to buffer sizes.   B b = A < = > b L.empty Note that B is a Monoid homomorphism.  , toLazyByteString mempty == mempty U toLazyByteString (x `mappend` y) == toLazyByteString x `mappend` toLazyByteString y KHowever, in the second equation, the left-hand-side is generally faster to  execute. ³FPack the chunks of a lazy bytestring into a single strict bytestring. CIRun the builder to construct a strict bytestring containing the sequence n of bytes denoted by the builder. This is done by first serializing to a lazy bytestring and then packing its 4 chunks to a appropriately sized strict bytestring.  . toByteString = packChunks . toLazyByteString  Note that C is a Monoid homomorphism.  ( toByteString mempty == mempty I toByteString (x `mappend` y) == toByteString x `mappend` toByteString y KHowever, in the second equation, the left-hand-side is generally faster to  execute. DtoByteStringIOWith bufSize io b runs the builder b with a buffer of  at least the size bufSize and executes the ´ action io whenever the  buffer is full.  Compared to A) this function requires less allocation, A as the output buffer is only allocated once at the start of the N serialization and whenever something bigger than the current buffer size has I to be copied into the buffer, which should happen very seldomly for the N default buffer size of 32kb. Hence, the pressure on the garbage collector is K reduced, which can be an advantage when building long sequences of bytes. ERun the builder with a <d buffer and execute the given  ´5 action whenever the buffer is full or gets flushed.   E = D < This is a Monoid& homomorphism in the following sense. 0 toByteStringIO io mempty == return () Q toByteStringIO io (x `mappend` y) == toByteStringIO io x >> toByteStringIO io y FRun a  to produce a strict µ.  This is equivalent to (C . '), but is more @ efficient because it uses just one appropriately-sized buffer. <=>?±@A5Buffer size (upper-bounds the resulting chunk size). 1Minimal free buffer space for continuing filling  the same buffer after a @ or a direct bytestring 4 insertion. This corresponds to the minimal desired  chunk size. 3Size of the first buffer to be used and copied for  larger resulting sequences Builder to run. /Lazy bytestring to output after the builder is  finished. Resulting lazy bytestring B³CDBuffer size (upper bounds  the number of bytes forced  per call to the ´ action). ´ action to execute per  full buffer, which is  referenced by a strict  µ.  to run.  Resulting ´ action. EF.  !"#$%&'()*+,<=>?@ABCDEF  @FBACED>=<? <=>?±@AB³CDEFtested on GHC only experimental Simon Meier <iridcode@gmail.com>NoneG5Write a UTF-8 encoded Unicode character to a buffer. ¶KEncode a Unicode character to another datatype, using UTF-8. This function J acts as an abstract way of encoding characters, as it is unaware of what L needs to happen with the resulting bytes: you have to specify functions to  deal with those. HO(1):. Serialize a Unicode character using the UTF-8 encoding. IO(n). Serialize a Unicode · using the UTF-8 encoding. JO(n). Serialize a value by ¸(ing it and UTF-8 encoding the resulting  ·. KO(n). Serialize a strict Unicode ¹! value using the UTF-8 encoding. LO(n). Serialize a lazy Unicode º! value using the UTF-8 encoding. G¶ 1-byte UTF-8  2-byte UTF-8  3-byte UTF-8  4-byte UTF-8 Input » Result HIJKLGHIJKLGHIJKLG¶HIJKLtested on GHC only experimental Simon Meier <iridcode@gmail.com>None MWrite a strict µ to a buffer. N,Smart serialization of a strict bytestring.  N = O ?DUse this function to serialize strict bytestrings. It guarantees an L average chunk size of 4kb, which has been shown to be a reasonable size in J benchmarks. Note that the check whether to copy or to insert is (almost) 9 free as the builder performance is mostly memory-bound. JIf you statically know that copying or inserting the strict bytestring is . always the best choice, then you can use the P or  Q functions. O%fromByteStringWith maximalCopySize bs" serializes the strict bytestring  bs# according to the following rules.   S.length bs <= maximalCopySize: bs! is copied to the output buffer. S.length bs > maximalCopySize: bs" the output buffer is flushed and  bs> is inserted directly as separate chunk in the output stream. IThese rules guarantee that average chunk size in the output stream is at  least half the maximalCopySize. PcopyByteString bs! serialize the strict bytestring bs by copying it to  the output buffer. LUse this function to serialize strict bytestrings that are statically known  to be smallish (<= 4kb). QinsertByteString bs" serializes the strict bytestring bs by inserting . it directly as a chunk of the output stream. LNote that this implies flushing the output buffer; even if it contains just E a single byte. Hence, you should use this operation only for large (> 8kb) M bytestrings, as otherwise the resulting output stream may be too fragmented  to be processed efficiently. RO(n),. Smart serialization of a lazy bytestring.  R = S ?JUse this function to serialize lazy bytestrings. It guarantees an average D chunk size of 4kb, which has been shown to be a reasonable size in J benchmarks. Note that the check whether to copy or to insert is (almost) 9 free as the builder performance is mostly memory-bound. 1If you statically know that copying or inserting all chunks of the lazy < bytestring is always the best choice, then you can use the  T or U functions. SO(n)E. Serialize a lazy bytestring chunk-wise according to the same rules  as in O. Semantically, it holds that  & fromLazyByteStringWith maxCopySize ? = mconcat . map (fromByteStringWith maxCopySize) . L.toChunks DHowever, the left-hand-side is much more efficient, as it moves the L end-of-buffer pointer out of the inner loop and provides the compiler with  more strictness information. TO(n)). Serialize a lazy bytestring by copying all chunks sequentially  to the output buffer. See P for usage considerations. UO(n)+. Serialize a lazy bytestring by inserting all its chunks directly  into the output stream. See Q for usage considerations.  For library developers, see the  ModifyChunks build signal, if you  need an O(1)3 lazy bytestring insert based on difference lists. MNO!Maximal number of bytes to copy. Strict µ to serialize.  Resulting . P¼QRS!Maximal number of bytes to copy. Lazy ² to serialize.  Resulting . TU MNOPQRSTU MNOPQRSTU MNOP¼QRSTUtested on GHC only experimental Simon Meier <iridcode@gmail.com>None!VWrite a single byte. WWrite a ½ in big endian format. XWrite a ½ in little endian format. YWrite a ¾ in big endian format. ZWrite a ¾ in little endian format. [Write a ¿ in big endian format. \Write a ¿ in little endian format. ]Write a single native machine À. The À is written in host order, & host endian form, for the machine you're on. On a 64 bit machine the À K is an 8 byte value, on a 32 bit machine, 4 bytes. Values written this way F are not portable to different endian or word sized machines, without  conversion. ^Write a ½+ in native host order and host endianness. _Write a ¾+ in native host order and host endianness. `Write a ¿+ in native host order and host endianness. aSerialize a single byte. bSerialize a list of bytes. c Serialize a ½ in big endian format. dSerialize a list of ½s in big endian format. e Serialize a ½ in little endian format. fSerialize a list of ½s in little endian format. g Serialize a ¾ in big endian format. hSerialize a list of ¾s in big endian format. i Serialize a ¾ in little endian format. jSerialize a list of ¾s in little endian format. k Serialize a ¿ in big endian format. lSerialize a list of ¿s in big endian format. m Serialize a ¿ in little endian format. nSerialize a list of ¿s in little endian format. o"Serialize a single native machine À. The À is serialized in host - order, host endian form, for the machine you're on. On a 64 bit machine the  ÀG is an 8 byte value, on a 32 bit machine, 4 bytes. Values written this J way are not portable to different endian or word sized machines, without  conversion. pSerialize a list of Às.  See o for usage considerations. qWrite a ½+ in native host order and host endianness. rWrite a list of ½,s in native host order and host endianness. sWrite a ¾+ in native host order and host endianness. tWrite a list of ¾,s in native host order and host endianness. uWrite a ¿+ in native host order and host endianness. vWrite a list of ¿,s in native host order and host endianness. !VWXYZ[\]^_`abcdefghijklmnopqrstuv!VWXYZ[\]^_`abcdefghijklmnopqrstuv!VWY[XZ\]^_`abcgkhdleimfjnoqsuprtv!VWXYZ[\]^_`abcdefghijklmnopqrstuvtested on GHC only experimental Simon Meier <iridcode@gmail.com>Nonew3Write the lower 8-bits of a character to a buffer. xO(1)-. Serialize the lower 8-bits of a character. yO(n);. Serialize the lower 8-bits of all characters of a string zO(n). Serialize a value by ¸(ing it and serializing the lower 8-bits  of the resulting string. {O(n)C. Serialize the lower 8-bits of all characters in the strict text. |O(n)A. Serialize the lower 8-bits of all characters in the lazy text. wxyz{|wxyz{|wxyz{|wxyz{| NoneÁWrite a CRLF sequence. ÂExecute a write Ã6Length of the hex-string required to encode the given ¾. }FTransform a builder such that it uses chunked HTTP transfer encoding. ~The zero-length chunk  '0\r\n\r\n'1 signaling the termination of the data transfer. ÁÂÄÅÃÆ}~}~}~ÁÂÄÅÃÆ}~ tested on GHC only experimental Simon Meier <iridcode@gmail.com>None!Write a single signed byte. € Write an Ç in big endian format.  Write an Ç in little endian format. ‚ Write an È in big endian format. ƒ Write an È in little endian format. „ Write an É in big endian format. … Write an É in little endian format. †Write a single native machine Ê. The Ê is written in host order, & host endian form, for the machine you're on. On a 64 bit machine the Ê K is an 8 byte value, on a 32 bit machine, 4 bytes. Values written this way I are not portable to different endian or integer sized machines, without  conversion. ‡ Write an Ç+ in native host order and host endianness. ˆ Write an È+ in native host order and host endianness. ‰ Write an É+ in native host order and host endianness. ŠSerialize a single byte. ‹Serialize a list of bytes. Œ Serialize an Ç in big endian format. Serialize a list of Çs in big endian format. Ž Serialize an Ç in little endian format. Serialize a list of Çs in little endian format.  Serialize an È in big endian format. ‘Serialize a list of Ès in big endian format. ’ Serialize an È in little endian format. “Serialize a list of Ès in little endian format. ” Serialize an É in big endian format. •Serialize a list of És in big endian format. – Serialize an É in little endian format. —Serialize a list of És in little endian format. ˜"Serialize a single native machine Ê. The Ê is serialized in host - order, host endian form, for the machine you're on. On a 64 bit machine the  ÊG is an 8 byte value, on a 32 bit machine, 4 bytes. Values written this M way are not portable to different endian or integer sized machines, without  conversion. ™Serialize a list of Ês.  See ˜ for usage considerations. š Write an Ç+ in native host order and host endianness. ›Write a list of Ç,s in native host order and host endianness. œ Write an È+ in native host order and host endianness. Write a list of È,s in native host order and host endianness. ž Write an É+ in native host order and host endianness. ŸWrite a list of É,s in native host order and host endianness. !€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ!€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ!€‚„ƒ…†‡ˆ‰Š‹Œ”‘•Ž’–“—˜šœž™›Ÿ!€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ tested on GHC only experimental Simon Meier <iridcode@gmail.com>NoneZ'()*+,@ABCDEFMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuv€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ@BACED'()F*+, tested on GHC only experimental Simon Meier <iridcode@gmail.com>None GWrite a HTML escaped and UTF-8 encoded Unicode character to a bufffer. ¡O(1).< Serialize a HTML escaped Unicode character using the UTF-8  encoding. ¢O(n)#. Serialize a HTML escaped Unicode · using the UTF-8  encoding. £O(n). Serialize a value by ¸#ing it and then, HTML escaping and  UTF-8 encoding the resulting ·. ¤O(n)*. Serialize a HTML escaped strict Unicode ¹ value using the  UTF-8 encoding. ¥O(n)#. Serialize a HTML escaped Unicode º using the UTF-8 encoding.  ¡¢£¤¥ GHIJKL ¡¢£¤¥ ¡¢£¤¥ ¡¢£¤¥Ë !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~QRSTUV € ‚ ƒ „ … † ‡ ˆ ‰ Š ‹ Œ Ž ‘ ’ “ ” • – — ˜ ™ š › œ ž Ÿ   ¡ ¢ £ ¤ ¥ ¦ § ¨©ª«"#¬­8 ® ¯ °±²³´µ¶·¸²¹´º»¼½»¾¿ÀÁÂÀö·ÄÅ»ÆÇ»ÆÈ»Æɶ·Ê Ë Ì Í Î Ï Ð»ÑÒ»ÑÓ»ÑÔ¶·ÕÖblaze-builder-0.3.2.0'Blaze.ByteString.Builder.Internal.Types'Blaze.ByteString.Builder.Internal.Write(Blaze.ByteString.Builder.Internal.Buffer!Blaze.ByteString.Builder.Internal"Blaze.ByteString.Builder.Char.Utf8#Blaze.ByteString.Builder.ByteStringBlaze.ByteString.Builder.WordBlaze.ByteString.Builder.Char8Blaze.ByteString.Builder.HTTPBlaze.ByteString.Builder.Int"Blaze.ByteString.Builder.Html.Utf81Blaze.ByteString.Builder.Internal.UncheckedShiftsBlaze.ByteString.BuilderPutunPutBuilder unBuilder BuildStep runBuildStep BuildSignalInsertByteString BufferFullDoneBufRangedone bufferFullinsertByteString buildStepputBuildStepContfromBuildStepCont putBuilderfromPut putLiftIOWritePokerunPokegetPokerunWritegetBound getBound'pokeN exactWrite boundedWrite writeLiftIOwriteIfwriteEq writeOrderingwriteOrd fromWritefromWriteSingleton fromWriteList writeStorable fromStorable fromStorablesBufferAllocStrategyBufferfreeSize sliceSize bufferSize allocBuffer reuseBufferunsafeFreezeBufferunsafeFreezeNonEmptyBufferupdateEndOfSlice execBuildStep nextSliceallNewBuffersStrategyreuseBufferStrategyrunPutdefaultBufferSizedefaultMinimalBufferSizedefaultFirstBufferSizedefaultMaximalCopySizeflushtoLazyByteStringWithtoLazyByteString toByteStringtoByteStringIOWithtoByteStringIOwriteToByteString writeCharfromChar fromStringfromShowfromText fromLazyTextwriteByteStringfromByteStringfromByteStringWithcopyByteStringfromLazyByteStringfromLazyByteStringWithcopyLazyByteStringinsertLazyByteString writeWord8 writeWord16be writeWord16le writeWord32be writeWord32le writeWord64be writeWord64le writeWordhostwriteWord16hostwriteWord32hostwriteWord64host fromWord8 fromWord8s fromWord16be fromWord16sbe fromWord16le fromWord16sle fromWord32be fromWord32sbe fromWord32le fromWord32sle fromWord64be fromWord64sbe fromWord64le fromWord64sle fromWordhost fromWordshostfromWord16hostfromWord16shostfromWord32hostfromWord32shostfromWord64hostfromWord64shostchunkedTransferEncodingchunkedTransferTerminator writeInt8 writeInt16be writeInt16le writeInt32be writeInt32le writeInt64be writeInt64le writeInthostwriteInt16hostwriteInt32hostwriteInt64hostfromInt8 fromInt8s fromInt16be fromInt16sbe fromInt16le fromInt16sle fromInt32be fromInt32sbe fromInt32le fromInt32sle fromInt64be fromInt64sbe fromInt64le fromInt64sle fromInthost fromIntshost fromInt16hostfromInt16shost fromInt32hostfromInt32shost fromInt64hostfromInt64shostwriteHtmlEscapedCharfromHtmlEscapedCharfromHtmlEscapedStringfromHtmlEscapedShowfromHtmlEscapedTextfromHtmlEscapedLazyText $fMonadPut $fFunctorPut$fMonoidBuilder $fMonoidWrite $fMonoidPoke shiftr_w16 shiftr_w32 shiftr_w64 nonEmptyChunkbytestring-0.10.0.2Data.ByteString.Lazy.Internal ByteString packChunksghc-prim GHC.TypesIOData.ByteString.InternalencodeCharUtf8baseGHC.BaseStringGHC.ShowShow text-0.11.2.3Data.Text.InternalTextData.Text.Lazy.InternalCharcopyByteStringStepGHC.WordWord16Word32Word64Word writeCRLF execWriteword32HexLengthpokeWord32HexNiterationsUntilZerowriteWord32HexGHC.IntInt16Int32Int64Int