[Haskell-cafe] Re[2]: Streams: the extensible I/O library

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Sun Feb 12 12:04:26 EST 2006


Bulat Ziganshin <bulatz at HotPOP.com> writes:

> i reported only the speed of the buffering transformers. this don't
> include speed of char encoding that should be very low at this time.

Recoding will be slow if it's done on top of buffering and if encoding
itself has heavy startup. Buffering should be on the very top, so it
amortizes the cost of starting the recoder.

It should be possible to use iconv for recoding. Iconv works on blocks
and it should not be applied to one character at a time.

Byte streams and character streams should be distinguished in types,
preferably by class-constrained parametric polymorphism. In particular
byte buffers and char buffers should be reperesented differently,
so block copying between byte streams moves whole blocks of memory.

I have designed and implemented these issues for my language Kogut,
and now I'm trying to port them to Haskell.

Static typing gets in the way in various places (hiding the type
behind an existentially qualified type, passing optional named
arguments), but it looks doable.

The design uses buffers internally. A buffer is a queue of characters
or bytes, with amortized O(1) cost of operating at an end, and fast
block operations. A buffer itself is a stream too (reading eats its
contents from the beginning, writing appends to the end).

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak at knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/


More information about the Haskell-Cafe mailing list