#1276: a sum-file program not working under Windows
------------------------------------+---------------------------------------
    Reporter:  [EMAIL PROTECTED]  |       Owner:         
        Type:  bug                  |      Status:  new    
    Priority:  normal               |   Milestone:         
   Component:  Compiler             |     Version:  6.6    
    Severity:  normal               |    Keywords:         
  Difficulty:  Unknown              |    Testcase:         
Architecture:  x86                  |          Os:  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 = [http://shootout.alioth.debian.org/download
 /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

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1276>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to