-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dhall format --inplace should force the resulting string before writing it #498
Comments
freeze also does inplace changes so maybe it should apply there as well |
Yep, anywhere we're writing files should do this. I think using strict text might be sufficient, but that might still have the problem of truncating the file if creating that text goes into an infinite loop. |
I would like to suggest an alternative solution. Most Unix utilities that do in-place modification support backing up the original file in case anything goes wrong and perhaps the |
|
@sjakobi: Sure, that seems fine |
It seems that
We could alternatively use the Or we could just have custom wrappers around the |
@sjakobi: I don't believe there are any issues with binary mode. The documentation you reference only raises concerns about using text mode on Unix/Windows. My understanding is that binary mode on both Unix and Windows writes out the bytes without modification, which is what we want |
@Gabriel439 My understanding is, that if we'd use e.g. |
@sjakobi: Also, to answer your question about durability, it is not important. Atomicity is all that matters here Specifically, in the absence of durability that would imply that if Durability is usually a property that only databases needed: specifically durability guarantees that if a transaction registered as completed then the user can feel confident that the change they made took effect permanently (i.e. was "durable") and won't be accidentally lost or reverted. However, So this is a long-winded way of saying that using the |
I just lost a Dhall file because I ran
dhall-format
on it and hit a bug. This meant the file just contained a huge list of(
- presumably an infinite loop somewhere - causing me to lose the contents of the file (yet to reach source control). In an ideal world it wouldn't go wrong, but we don't live in an ideal world. I'll take the extra memory usage of buffering the contents first and witnessing the formatting terminate before writing the file.This is on Dhall 1.15. I can't report a bug as to what went wrong with formatting because I don't have the input anymore 😆
The text was updated successfully, but these errors were encountered: