ByteString I/O Performance

apfelmus apfelmus at quantentunnel.de
Wed Sep 5 04:14:39 EDT 2007


Peter Simons wrote:
> Duncan Coutts writes:
> 
>  > We can't provide this interface as it modifies the immutable
>  > input ByteString.
> 
> Well, one could call it unsafeHGet. :-)
> 
> 
>  > [Mutable input buffer] really requires an api that guarantees
>  > that the buffer is no longer in use when the next chunk is
>  > read, destroying the previous content of the buffer.
> 
> I see your point. It would be nice if the API would guarantee
> that the ByteString cannot be misused. Personally, I feel that is
> a minor point though.

Remember that Haskell expressions are evaluated lazily, that's why we 
have the IO monad for doing input/output. Hence, mutable values that 
look like pure ones become unpredictable and are considered a major sin 
in Haskell land, please don't do it.

As  catBuf  crucially depends on the mutability of the buffer, 
ByteStrings  are not the right data structure to use in that case, 
that's all there is to it.

Regards,
apfelmus



More information about the Libraries mailing list