diff options
| author | Joey Hess <joeyh@joeyh.name> | 2016-06-22 15:28:50 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-06-22 15:28:50 -0400 |
| commit | d2309fce1cab98788260b03bd62dfa737f410050 (patch) | |
| tree | 0cf60502d7107847c254bbe640b12155eb8ab8b1 | |
| parent | 83519ad575d69650a79473dc13b94126e9987255 (diff) | |
comment
| -rw-r--r-- | doc/forum/use_withUmask_in_a_property/comment_5_da0074f18fe0ce020325a9f59f44cb1d._comment | 13 |
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) +"""]] |
