Re: getContents
Simon Marlow wrote: [snip] > "Once a semi-closed handle becomes closed, the contents of > the associated stream becomes fixed, and is the list of those > items which were succesfully read from that handle". [snip] Ah, now I see. I had assumed that hClose'ing a semi-closed handle would result in the entire file being read till EOF, after which the file would be closed. Thanks. ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: getContents
> contents <- hGetContents handle > seq (last contents) (hClose handle) vs. > contents <- hGetContents handle > hClose handle > However I looked at the manual and it seems that hClose should > force the whole of contents to be read anyway. If some manual says this, it is wrong. The Haskell Report says that 'hGetContents' gives the handle a special status, called "semi-closed". A semi-closed handle becomes fully closed when 'hClose' is applied to it. When this occurs, the contents of the associated stream of characters (i.e. those returned by 'hGetContents') is truncated, and is the list of characters that have already been read from that handle. Regards, Malcolm ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: getContents
> I don't really understand getContents. (Does anyone?) I > have some code here > (far too large to submit). If I do (on Linux, ghc4.08.1, > both with and without optimisation) > -- > contents <- hGetContents handle > seq (last contents) (hClose handle) > -- > the code works. However I looked at the manual and it seems > that hClose should > force the whole of contents to be read anyway. So I changed it to > -- > contents <- hGetContents handle > hClose handle > -- > and then the code doesn't work. If these are meant to be the > same, then we have a GHC > bug. If not, could someone explain in words of one syllable why not? > > PS - if you want the source code you'll have to download and > compile the whole of UniForM!! Using hClose on a semi-closed handle is a Bad Thing. The Haskell Report says: "Once a semi-closed handle becomes closed, the contents of the associated stream becomes fixed, and is the list of those items which were succesfully read from that handle". So I take this to mean that when you hClose a semi-closed handle, you get a random amount of data in the handle which depends on how good your compiler's strictness analyser is. yesno? Cheers, Simon ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
getContents
I don't really understand getContents. (Does anyone?) I have some code here (far too large to submit). If I do (on Linux, ghc4.08.1, both with and without optimisation) -- contents <- hGetContents handle seq (last contents) (hClose handle) -- the code works. However I looked at the manual and it seems that hClose should force the whole of contents to be read anyway. So I changed it to -- contents <- hGetContents handle hClose handle -- and then the code doesn't work. If these are meant to be the same, then we have a GHC bug. If not, could someone explain in words of one syllable why not? PS - if you want the source code you'll have to download and compile the whole of UniForM!! ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users