[Haskell-cafe] Running out of space while concatinating a list of bytestring
C K Kashyap
ckkashyap at gmail.com
Wed Feb 27 12:09:40 CET 2013
Oops, false alarm.
Please ignore - and sorry about it.
Regards,
Kashyap
On Wed, Feb 27, 2013 at 1:32 PM, C K Kashyap <ckkashyap at gmail.com> wrote:
> Hi,
>
> I have the following code - It looks like things go okay until
> concatination is attempted. I get the following output
>
> There are 2258 ByteStrings
> *** Exception: <stdout>: hPutBuf: resource exhausted (Not enough space)
>
> I am thinking that I should do strict concatination at each point in the
> support function - how can I go about doing so? (BS is the lazy.char8
> bytestring)
>
>
> connectionGetNBytes :: NC.Connection -> Int -> IO ByteString
> connectionGetNBytes c n = do
> bs <- connectionGetNBytes' c n
> putStrLn ("There are " ++ (show (length bs)) ++ "
> ByteStrings")
> return (BS.concat bs)
>
> connectionGetNBytes' :: NC.Connection -> Int -> IO [ByteString]
> connectionGetNBytes' _ 0 = return []
> connectionGetNBytes' c n = do
> l <- NC.connectionGet c n
> let ll = BS.length l
> remaining <- connectionGetNBytes' c (n - ll)
> return (l:crlfStr:remaining)
>
>
> Regards,
> Kashyap
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130227/bb1cfb17/attachment.htm>
More information about the Haskell-Cafe
mailing list