
The basic problem is just that it's error prone when you're doing things that are non-trivial wrt the lifetime of the file. Part of the original motivation for Haskell's "purity" was that lazy evaluation and side-effects are hard to think about. In languages that allow it, "don't mix laziness and effects" is a bit of common folk-wisdom. See e.g: https://stuartsierra.com/2015/08/25/clojure-donts-lazy-effects If I'm writing a simple program that just reads in some data, does stuff, and spits it back out, I usually don't stress about it. But for long running programs, file descriptor leaks can be a problem, and between that and needing to be async-exception safe, the usual resource management strategies in Haskell make the whole thing pretty dicey. Quoting Vanessa McHale (2019-03-28 14:26:22)
the second issue could be better resolved with linear types!
How would this work? Not sure I follow.