From d2309fce1cab98788260b03bd62dfa737f410050 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 22 Jun 2016 15:28:50 -0400 Subject: comment --- .../comment_5_da0074f18fe0ce020325a9f59f44cb1d._comment | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 doc/forum/use_withUmask_in_a_property/comment_5_da0074f18fe0ce020325a9f59f44cb1d._comment diff --git a/doc/forum/use_withUmask_in_a_property/comment_5_da0074f18fe0ce020325a9f59f44cb1d._comment b/doc/forum/use_withUmask_in_a_property/comment_5_da0074f18fe0ce020325a9f59f44cb1d._comment new file mode 100644 index 00000000..c566bb64 --- /dev/null +++ b/doc/forum/use_withUmask_in_a_property/comment_5_da0074f18fe0ce020325a9f59f44cb1d._comment @@ -0,0 +1,13 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 5""" + date="2016-06-22T19:24:43Z" + content=""" +Unfortunately `withFile` uses IO, instead of being generalized to MonadIO, +so the approaches that work with `withUmask` don't work with it. + +One way is to write a version of withFile that's generalized to MonadIO: + + withFile' :: (MonadIO m, MonadMask m) => FilePath -> IOMode -> (Handle -> m r) -> m r + withFile' name mode = bracket (liftIO $ openFile name mode) (liftIO . hClose) +"""]] -- cgit v1.2.3