a sum-file program not working under Windows
This program just hangs under Windows, ghc-6-6.msi:
module Main where
main = print . sum . map read . lines =<< getContents
I compiled with:
ghc -O sumcol.hs -o sumcol_O.exe
and ran as:
sumcol_O.exe "sumcol-input.txt"
where sumcol-input.txt = sumcol-input.txt :: Text_File (KB 6, Lines 1000)
Replacing 'getContents' with 'readFile "sumcol-input.txt" ' works.
Similar observed behavior under ghci:
Prelude> :set args "sumcol-input.txt"
Prelude> print . sum . map read . lines =<< getContents
_
and
Prelude> print . sum . map read . lines =<< readFile "sumcol-input.txt"
500
Prelude> _
It might also be relevant that when compiling and running this version of the sum-file program:
{-# OPTIONS -fbang-patterns #-}
module Main where
import Data.List
import qualified Data.ByteString.Lazy.Char8 as L
main = print . foldl' (+) 0 . unfoldr parse =<< L.getContents
parse !s | Just (n,t) <- L.readInt s = Just (n, L.tail t)
| otherwise = Nothing
with
ghc -O -fglasgow-exts sumcol.hs -o sumcol_O.exe
and then
sumcol_O.exe "sumcol-input.txt"
I get
sumcol_O.exe: <stdin>: hGetBufNonBlocking: resource exhausted (Not enough space)
System: ghc 6.6 under WinXP Pro SP2 Intel Celeron 2.53GHz, 512 RAM
I'll be happy to provide any other necessary information:
Fernando Gonzalez, nanotitan at google's mail service
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.6 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |