withFile defeats dead handle closure

Ryan Trinkle ryan at trinkle.org
Wed Dec 30 20:55:40 UTC 2020


Although it might be nice to have a weak-reference-based alternative to
withFile, I think it would be best to keep the behavior of withFile as
predictable as possible (i.e. the current behavior), since closing a
file can be semantically significant.  For instance, if someone is using
/dev/watchdog to make their system automatically reboot when their
userspace daemon fails, closing the file handle early would cause the
watchdog functionality to be disabled, which is almost certainly not
what someone would mean by `withFile "/dev/watchdog" $ \_ -> blah`.

On 12/30/20 3:47 PM, Henning Thielemann wrote:
>
> On Wed, 30 Dec 2020, David Feuer wrote:
>
>> withFile keeps the handle it creates alive until the user action
>> completes. If we want to avoid this, we can.
>
> Why should we?
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


More information about the Libraries mailing list