[Haskell] Re: Using newArray with hGetArray

Andre Pang ozone at algorithm.com.au
Mon May 23 12:32:28 EDT 2005


On 24/05/2005, at 2:03 AM, Andre Pang wrote:

> Hi all, I have the following snippet of code:
>
>    mutableMemoryArray <- newArray_ (0, bufferSize - 1)
>    bytesRead <- hGetArray handle mutableMemoryArray bufferSize
>
> The problem is that hGetArray (like hGetBuf) may read less than the  
> amount that you specify (since you may hit EOF before filling up  
> the whole array).
> [..]
> Am I missing something obvious here?

Oops, never mind, I completely forgot that hPutArray also takes in a  
'count' parameter, and that the array bounds simply reflects its size  
rather than how many elements of it are present.

Thanks to Lemmih for bringing this to my attention on #haskell!


-- 
% Andre Pang : trust.in.love.to.save  <http://www.algorithm.com.au/>




More information about the Haskell mailing list