2

This code gives <stdin>: hGetBufSome: resource exhausted (Not enough space) error as soon as it's executed.

import qualified Data.ByteString.Lazy.Char8 as B8
main = do
    (l:_) <- B8.lines `fmap` B8.getContents
    B8.putStrLn l

I'm just trying to get the first line. So because of lazy loading it wouldn't try to get others right? I can't figure out how to avoid this error.

Dulguun Otgon
  • 1,925
  • 1
  • 19
  • 38

2 Answers2

2

There seems to be a problem with lazy bytestrings on 64-bit Windows 7, e.g.

Since the reports are all from over a year ago, I would try using GHC 7.8.3 (for example, from the Haskell Platform 2014.2.0.0) if you are not already using that version.

ErikR
  • 51,541
  • 9
  • 73
  • 124
1

Here's the bug report against GHC on this issue: https://ghc.haskell.org/trac/ghc/ticket/11009#ticket

I guess the solution for now is to not use getContents on lazy bytestrings (switch to strict or just read incrementally).

sclv
  • 38,665
  • 7
  • 99
  • 204