unix-bytestring v0.2.0 (Was: Re: Proposal: add ByteString support to unix:System.Posix.IO API)
wren ng thornton
wren at freegeek.org
Sun Mar 6 13:16:21 CET 2011
On 3/5/11 10:03 AM, Bas van Dijk wrote:
> 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.
I even have a note in the source file to that effect :)
One thing I considered was to offer both versions, one for compatibility
with the old string versions (and for decluttering client code) and
then one that just gives the bytestring. Of course, then the issue is
what to name them...
So the big question is: how minimal should we be, vs how much in the way
of convenience functions should we offer?
Update: In v0.2.1 I added an fdReads function which lets you pass a
predicate for determining whether to retry after incomplete reads.
More information about the Libraries