summaryrefslogtreecommitdiff
path: root/doc/forum
diff options
context:
space:
mode:
Diffstat (limited to 'doc/forum')
-rw-r--r--doc/forum/use_withUmask_in_a_property/comment_5_da0074f18fe0ce020325a9f59f44cb1d._comment13
1 files changed, 13 insertions, 0 deletions
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)
+"""]]