unix-bytestring v0.2.0 (Was: Re: Proposal: add ByteString support to unix:System.Posix.IO API)

Bas van Dijk v.dijk.bas at gmail.com
Sat Mar 5 16:03:18 CET 2011

On 5 March 2011 13:30, wren ng thornton <wren at freegeek.org> wrote:
> This currently consists of:
> * System.Posix.IO.ByteString
>    * fdRead   -- like System.Posix.IO.fdRead, the same as before.

What about changing this:

fdRead :: Fd -> ByteCount -> IO (ByteString, ByteCount)

to this:

fdRead :: Fd -> ByteCount -> IO ByteString

I agree that it's nice to be consistent with the String version but
since that version might go away and since the length (O(1)) of the
ByteString should always equal the ByteCount I think it's better to
remove that invariant.

> * System.Posix.IO.ByteString.Lazy
>    -- I'm keeping this around for now, for my own convenience.
>    * fdRead   -- simple wrapper around System.Posix.IO.ByteString.fdRead,
> the same as before.

Although calculating the length of a lazy ByteString is O(n/c), since
you always return a single chunk I think the same argument applies

Nice work!


More information about the Libraries mailing list