[Haskell-cafe] Re: Writing binary files?

Glynn Clements glynn.clements at virgin.net
Thu Sep 16 16:16:46 EDT 2004


MR K P SCHUPKE wrote:

> >In the general case, it needs to be a bit more complex than that,
> 
> Thats why the functions handled lists not individual characters,
> I was assuming that each [Word8] -> [Char] represented a valid
> and complete encoding block... IE at the start of each call it
> assumes no escapes. All this means is than when reading in chunks
> you paste those chunks together before conversion, and you can
> only break outside of escapes. This in my opinion is better
> behaviour anyway... I don't want some hidden escape state mangling
> output, just because some earler code generated invalid output.

Right. Certainly, a stateless interface will handle converting
"complete" strings (pathnames, arguments, etc).

But, ultimately we will have need of a more general interface. E.g. in
the chunked HTTP example which Oleg gave, you would probably want
separate decoders for the headers and body, switching between them as
you read the stream. You wouldn't want to have to accumulate the
entire body as a single byte string just so that you could decode it
in one go, and you can't just "push" a decoder onto the stream.

-- 
Glynn Clements <glynn.clements at virgin.net>


More information about the Haskell-Cafe mailing list