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

Bulat Ziganshin bulatz at HotPOP.com
Sun Feb 12 12:56:21 EST 2006


Hello Marcin,

Sunday, February 12, 2006, 8:04:26 PM, you wrote:

>> 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.

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

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

recoding don't need any startup. each vGetChar or vPutChar
just executes one or more vGetByte/vPutByte calls, according to
encoding rules. this should be fast enough


MQK> Byte streams and character streams should be distinguished in types,
MQK> preferably by class-constrained parametric polymorphism. In particular

so that vGetBuf, vGetChar, and getWord32 can't be used at the same
stream?


MQK> byte buffers and char buffers should be reperesented differently,
MQK> so block copying between byte streams moves whole blocks of memory.

in my lib, block copying between streams can be performed only at the
byte level. if you need to copy N chars with non-trivial encoding, or
need to copy chars with recoding, you should use "vGetChar h1 >>=
vPutChar h2" operation repeated


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

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

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

i use different design. we can compare speed/features/robustness/easy
of adding new features of our libraries. you can see my lib at:

You can find further information about the library at the page
http://haskell.org/haskellwiki/Library/Streams and download it as
http://freearc.narod.ru/Streams.tar.gz





-- 
Best regards,
 Bulat                            mailto:bulatz at HotPOP.com





More information about the Haskell-Cafe mailing list