[Haskell] RFC: Streams: CharEncoding transformer
Bulat Ziganshin
bulatz at HotPOP.com
Wed Feb 8 03:41:25 EST 2006
Hello
Streams library includes CharEncoding transformer that allows to
read/write files in UTF-8 and any other encodings. according to the
Einar's requirement, i made CharEncoding transformer dynamic - apllied
encoding can be changed at any time. now i thinks that this design may
limit speed of encoding and plan to use alternate design where
concrete encoding is "burned" into the tramsformer and cannot be
changed after creation of the transformed stream. due to the ability
to create transformed stream at any moment this should not impose big
limitations. say, instead:
h <- openFD "test" WriteMode >>= withEncoding utf8
vPutStrLn h "testing"
vSetEncoding h latin1
vPutStrLn h "testing"
now we should write:
h <- openFD "test" WriteMode
h1 <- withEncoding utf8 h
vPutStrLn h1 "testing"
h2 <- withEncoding latin1 h
vPutStrLn h2 "testing"
or
h <- openFD "test" WriteMode
blockWithEncoding utf8 h $ \h -> do
vPutStrLn h "testing"
blockWithEncoding latin1 h $ \h -> do
vPutStrLn h "testing"
So, the gain is faster speed on typical usage where dynamic change of
encoding is not used. the loss is more restricted abilities to change
the encoding - the stream with new encoding is new object and
therefore these encoding changes should have a structure of enclosed
blocks (such as HTML structure)
THE QUESTION: is this new interface enough for your usage, or someone
will need a more dynamic approach given by the old interface?
--
Best regards,
Bulat mailto:bulatz at HotPOP.com
More information about the Haskell
mailing list