[Haskell-cafe] Exclusive mode in openFile

Max Bolingbroke batterseapower at hotmail.com
Tue Jun 28 19:26:24 CEST 2011


On 28 June 2011 17:50, Gracjan Polak <gracjanpolak at gmail.com> wrote:
> It seems I'm not allowed to open same file both for writing and for reading:

This behaviour is part of the Haskell 98 specification (section
21.2.3, http://www.haskell.org/onlinereport/io.html):

"""
Implementations should enforce as far as possible, at least locally to
the Haskell process, multiple-reader single-writer locking on files.
That is, there may either be many handles on the same file which
manage input, or just one handle on the file which manages output. If
any open or semi-closed handle is managing a file for output, no new
handle can be allocated for that file.
"""

I've been bitten by this before and don't like it. It would be
possible for GHC to enforce Unix semantics instead (there are
appropriate flags to CreateFile that get those semantics on Windows),
which would support more use cases. This change would have to be
carefully thought through, and the report would have to be amended.

Cheers,
Max



More information about the Haskell-Cafe mailing list