úÎŒ…\H      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGportable to Hugs and GHC experimental,Lennart Kolmodin <kolmodin@dtek.chalmers.se>NoneA # is an efficient way to build lazy Hs. . There are several functions for constructing s, but only one G to inspect them: to extract any data, you have to turn them into lazy  Hs using . Internally, a  constructs a lazy  by filling byte 9 arrays piece by piece. As each buffer is filled, it is 'popped' 2 off, to become a new chunk of the resulting lazy H. ) All this is hidden from the user of the . O(1). The empty Builder, satisfying    = IO(1)., A Builder taking a single byte, satisfying   ( b) = J bO(1).= The concatenation of two Builders, an associative operation  with identity  , satisfying   ( x y) = K ( x) ( y)O(1). A Builder taking a L , satisfying   ( bs) = M [bs]O(1). A Builder taking a lazy H , satisfying   ( bs) = bsO(n). Extract a lazy H from a . D The construction work takes place if and when the relevant part of  the lazy H is demanded. O(1). Pop the L% we have constructed so far, if any, ) yielding a new chunk in the result lazy H. $Write a Word16 in big endian format 'Write a Word16 in little endian format $Write a Word32 in big endian format 'Write a Word32 in little endian format $Write a Word64 in big endian format 'Write a Word64 in little endian format O(1).< A Builder taking a single native machine word. The word is = written in host order, host endian form, for the machine you're on. G On a 64 bit machine the Word is an 8 byte value, on a 32 bit machine, 6 4 bytes. Values written this way are not portable to > different endian or word sized machines, without conversion. 9Write a Word16 in native host order and host endianness. % 2 bytes will be written, unaligned. 9Write a Word32 in native host order and host endianness. % 4 bytes will be written, unaligned. %Write a Word64 in native host order. J On a 32 bit machine we write two host order Word32s, in big endian form. % 8 bytes will be written, unaligned.  N   Nportable to Hugs and GHC. experimental,Lennart Kolmodin <kolmodin@dtek.chalmers.se>NoneIThe Get monad is just a State monad carrying around the input ByteString ' We treat it as a strict state monad. Run the Get monad applies a O&-based parser on the input ByteString Run the Get monad applies a O-based parser on the input F ByteString. Additional to the result of get it returns the number of + consumed bytes and the rest of the input.  Skip ahead n bytes. Fails if fewer than n bytes are available.  Skip ahead n bytes. No error if there isn't enough bytes. Run ga*, but return without consuming its input.  Fails if ga fails. Like , but consume the input if gma returns 'Just _'.  Fails if gma fails. Like , but consume the input if gea returns 'Right _'.  Fails if gea fails. Get the next up to n6 bytes as a lazy ByteString, without consuming them. 2Get the total number of bytes read to this point. ,Get the number of remaining unparsed bytes. : Useful for checking whether all input has been consumed. . Note that this forces the rest of the input. *Test whether all input has been consumed, - i.e. there are no remaining unparsed bytes.  An efficient O/ method for strict ByteStrings. Fails if fewer  than n bytes are left in the input.  An efficient O: method for lazy ByteStrings. Does not fail if fewer than  n bytes are left in the input. @Get a lazy ByteString that is terminated with a NUL byte. Fails 7 if it reaches the end of input without hitting a NUL. !-Get the remaining bytes as a lazy ByteString " important Pull n/ bytes from the input, as a strict ByteString. #"Read a Word8 from the monad state $#Read a Word16 in big endian format %&Read a Word16 in little endian format &#Read a Word32 in big endian format '&Read a Word32 in little endian format (#Read a Word64 in big endian format )&Read a Word64 in little endian format *O(1).8 Read a single native machine word. The word is read in 2 host order, host endian form, for the machine you're on. On a 64 bit D machine the Word is an 8 byte value, on a 32 bit machine, 4 bytes. +O(1).@ Read a 2 byte Word16 in native host order and host endianness. ,O(1).9 Read a Word32 in native host order and host endianness. -O(1).8 Read a Word64 in native host order and host endianess.  !"#$%&'()*+,-PQRS !"#$%&'()*+,-"# !$&(%')*+,-  !"#$%&'()*+,-PQRS(Portable to Hugs and GHC. Requires MPTCsstable,Lennart Kolmodin <kolmodin@dtek.chalmers.se> Safe-Infered.=Put merely lifts Builder into a Writer monad, applied to (). /AThe PutM type. A Writer monad over the efficient Builder monoid. 2Run the . monad with a serialiser 3BPop the ByteString we have constructed so far, if any, yielding a % new chunk in the result ByteString. 40Efficiently write a byte into the output buffer 5LAn efficient primitive to write a strict ByteString into the output buffer. J It flushes the current buffer, and writes the argument into a new chunk. 6?Write a lazy ByteString efficiently, simply appending the lazy ( ByteString chunks to the output buffer 7$Write a Word16 in big endian format 8'Write a Word16 in little endian format 9$Write a Word32 in big endian format :'Write a Word32 in little endian format ;$Write a Word64 in big endian format <'Write a Word64 in little endian format =O(1).1 Write a single native machine word. The word is = written in host order, host endian form, for the machine you're on. G On a 64 bit machine the Word is an 8 byte value, on a 32 bit machine, 6 4 bytes. Values written this way are not portable to > different endian or word sized machines, without conversion. >O(1).: Write a Word16 in native host order and host endianness.  For portability issues see  putWordhost. ?O(1).: Write a Word32 in native host order and host endianness.  For portability issues see  putWordhost. @O(1).% Write a Word64 in native host order J On a 32 bit machine we write two host order Word32s, in big endian form.  For portability issues see  putWordhost. ./0123456789:;<=>?@TUV./0123456789:;<=>?@./012345679;8:<=>?@./0123456789:;<=>?@TUVFportable to Hugs and GHC. Requires the FFI and some flexible instancesunstable,Lennart Kolmodin <kolmodin@dtek.chalmers.se> Safe-InferedAThe Binary class provides B and C, methods to encode and F decode a Haskell value to a lazy ByteString. It mirrors the Read and B Show classes for textual representation of Haskell types, and is D suitable for serialising Haskell values to disk, over the network. BFor parsing and generating simple external binary formats (e.g. C A structures), Binary may be used, but in general is not suitable ? for complex protocols. Instead use the Put and Get primitives  directly. ;Instances of Binary should satisfy the following property:   decode . encode == id  That is, the C and B' methods should be the inverse of each D other. A range of instances are provided for basic Haskell types. B!Encode a value in the Put monad. C Decode a value in the Get monad D@Encode a value using binary serialisation to a lazy ByteString. ENDecode a value from a lazy ByteString, reconstructing the original structure. F#Lazily serialise a value to a file 'This is just a convenience function, it's defined simply as:  ' encodeFile f = B.writeFile f . encode ASo for example if you wanted to compress as well, you could use: # B.writeFile f . compress . encode G9Lazily reconstruct a value previously written to a file. 'This is just a convenience function, it's defined simply as:  1 decodeFile f = return . decode =<< B.readFile f CSo for example if you wanted to decompress as well, you could use:  / return . decode . decompress =<< B.readFile f 0After contructing the data from the input file, G checks F if the file is empty, and in doing so will force the associated file B handle closed, if it is indeed empty. If the file is not empty, D it is up to the decoding instance to consume the rest of the data, % or otherwise finalise the resource. /ABCDEFGWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ#.4ABCDEFG ABC.4#DEFG-ABCDEFGWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~„      !"#$%&'()*+,-./01234565789:;<=>?@ABCDECFCF CF CGECFHI>JKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{yz|yz}yz~yz€ binary-0.4.5Data.Binary.BuilderData.Binary.GetData.Binary.Put Data.BinaryL BytestringBuilderempty singletonappendfromByteStringfromLazyByteStringtoLazyByteStringflush putWord16be putWord16le putWord32be putWord32le putWord64be putWord64le putWordhost putWord16host putWord32host putWord64hostGetrunGet runGetStateskip uncheckedSkip lookAhead lookAheadM lookAheadEuncheckedLookAhead bytesRead remainingisEmpty getByteStringgetLazyByteStringgetLazyByteStringNulgetRemainingLazyByteStringgetBytesgetWord8 getWord16be getWord16le getWord32be getWord32le getWord64be getWord64le getWordhost getWord16host getWord32host getWord64hostPutPutMunPutrunPutputWord8 putByteStringputLazyByteStringBinaryputgetencodedecode encodeFile decodeFilebytestring-0.9.2.1Data.ByteString.Lazy.Internal ByteStringData.ByteString.LazyData.ByteString.Internal fromChunks$fMonoidBuilder $fMonadFixGet $fMonadGet$fApplicativeGet $fFunctorGet $fMonadPutM$fApplicativePutM $fFunctorPutM$fBinaryUArray $fBinaryArray $fBinaryTree $fBinaryFloat$fBinaryDouble $fBinarySeq$fBinaryIntMap$fBinaryIntSet $fBinaryMap $fBinarySet$fBinaryByteString$fBinaryByteString0$fBinaryEither $fBinaryMaybe $fBinary[]$fBinary(,,,,,,,,,)$fBinary(,,,,,,,,)$fBinary(,,,,,,,)$fBinary(,,,,,,)$fBinary(,,,,,)$fBinary(,,,,) $fBinary(,,,) $fBinary(,,) $fBinary(,) $fBinaryChar $fBinaryRatio$fBinaryInteger $fBinaryInt $fBinaryWord $fBinaryInt64 $fBinaryInt32 $fBinaryInt16 $fBinaryInt8$fBinaryWord64$fBinaryWord32$fBinaryWord16 $fBinaryWord8$fBinaryOrdering $fBinaryBool $fBinary()baseGHC.WordWordWord8Word16Word32Word64