[Haskell-cafe] getContents and lazy evaluation

Esa Ilari Vuokko eivuokko at gmail.com
Wed Sep 6 16:30:20 EDT 2006


On 9/6/06, David Roundy <droundy at darcs.net> wrote:
> Fortunately, the undefined behavior in this case is unrelated to the
> lazy IO.  On windows, the removal of the file will fail, while on
> posix systems there won't be any failure at all.  The same behavior
> would show up if you opened the file for non-lazy reading, and tried
> to read part of the file, then delete it, then read the rest.

This is not strictly speaking true.  If all the handles opened to the file
in question are in FILE_SHARE_DELETE-sharing mode, it can be
marked for deletion when last handle to it is closed.  It can also be
moved and renamed.

But it is true that removal might fail because of open handle, and it is true
that it will fail as implemented currently for ghc (and probably for other
compilers as well.)

> The "undefinedness" in this example, isn't in the haskell language,
> but in the filesystem semantics, and that's not something we want the
> language specifying (since it's something over which it has no

Happily this isn't lazy IO-issue, it's just file IO issue for all
files opened as
specified by haskell98.  Sharing mode would be really nice to have in
Windows, as would security attributes.  But as you say, these are hard
things to specify because not everyone has those features.  So, at least
it works nicely in posixy-systems, eh?

Best regards,
--Esa Ilari Vuokko

More information about the Haskell-Cafe mailing list