Adding new contructors to IOMode to support "don't overwrite if already exists" behavior

Carter Schonwald carter.schonwald at
Tue Mar 31 22:15:24 UTC 2020

One really important question is what modes are actually promised by actual
file systems on every posix or otherwise supported platforms .  Table
stakes is code should work well on every tier 1 platform and tier 2 as well

And it’s been pointed out to me that this is part of the Haskell report so
whatever final design is done needs to be excellent

Meta aside : on and off I sometimes wonder what the world would be like if
file systems weren’t stuck in posix minima tar pits (heck an Mvcc with
transactions file system would rock).  But that’s unrelated to improving
the world we have. Do either way this at least starts a discussion about
what we can do better today !

Pardon the slow reply, I think everyone everywhere is having a very strange
start to spring.

Be well and look forward to improving bits and pieces of how we deal with
files on computers ;)


On Tue, Mar 31, 2020 at 5:51 PM Carter Schonwald <carter.schonwald at>

> At least naively, this seems like a really good idea.
> 1) do folks who have more experience across the range of supported
> platforms have any opinions about these additional semantics ?
> 2) are these names suitably descriptive / unambiguous and or otherwise
> widely used / discoverable ?
> On Mon, Mar 30, 2020 at 12:22 PM Grey Mitchell <grey at>
> wrote:
>> The current behavior for System.IO.openFile will either truncate an
>> existing
>> file (with WriteMode) or append new content to the end (with AppendMode).
>> However, there's another behavior that's available from the underlying
>> API:
>> signal an error when the file already exists. I poked around at the code
>> and i
>> think that with a couple extra variants of IOMode, this behavior could be
>> added
>> with a relatively small patch.
>> I have a branch pushed where i added this behavior:
>> I'm a relative newcomer to contributing to GHC or the base library, so if
>> i'm
>> missing something in my patch please let me know. Specifically, i would
>> like to
>> know is there's a place i can add a test for this behavior. I'm also open
>> to
>> changing the names of the new IOModes - this was just something i wrote
>> in to
>> get something working.
>> Looking forward to working with maintainers to get this added!
>> Thanks,
>> Grey Mitchell (@QuietMisdreavus)
>> _______________________________________________
>> Libraries mailing list
>> Libraries at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list