diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2015-06-09 22:55:40 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2015-06-09 22:55:40 +0200 |
commit | 3576f981b8e1ea2e23dafc6351c52e614b0dc13c (patch) | |
tree | 37837db69f3bc16078e7d87e650bb9b891ff7fb7 /src | |
parent | 3a69e87a90d494aff3d187de2174cc1e92c331b0 (diff) | |
download | trivmix-3576f981b8e1ea2e23dafc6351c52e614b0dc13c.tar trivmix-3576f981b8e1ea2e23dafc6351c52e614b0dc13c.tar.gz trivmix-3576f981b8e1ea2e23dafc6351c52e614b0dc13c.tar.bz2 trivmix-3576f981b8e1ea2e23dafc6351c52e614b0dc13c.tar.xz trivmix-3576f981b8e1ea2e23dafc6351c52e614b0dc13c.zip |
code cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/Trivmix.hs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/Trivmix.hs b/src/Trivmix.hs index ede6f67..fe592fe 100644 --- a/src/Trivmix.hs +++ b/src/Trivmix.hs | |||
@@ -140,13 +140,12 @@ handleFiles inotify level files = do | |||
140 | initLevel <- readMVar level | 140 | initLevel <- readMVar level |
141 | levelChanges <- (newChan :: IO (Chan Level)) | 141 | levelChanges <- (newChan :: IO (Chan Level)) |
142 | let | 142 | let |
143 | handleFiles' = mapM handleFile files | ||
144 | handleFile file = do | 143 | handleFile file = do |
145 | levelChanges' <- dupChan levelChanges | 144 | levelChanges' <- dupChan levelChanges |
146 | forkIO $ forever $ do -- Broadcast level changes and update all files | 145 | forkIO $ forever $ do -- Broadcast level changes and update all files |
147 | readChan levelChanges' >>= writeLevel file | 146 | readChan levelChanges' >>= writeLevel file |
148 | addWatch inotify watchedAttrs file (const $ readLevel levelChanges level file) | 147 | addWatch inotify watchedAttrs file (const $ readLevel levelChanges level file) |
149 | foldl (.) id [onStateFile f (show initLevel ++ "\n") | f <- files] $ handleFiles' | 148 | sequence [onStateFile f (show initLevel ++ "\n") handleFile f | f <- files] |
150 | forkIO $ forever $ do | 149 | forkIO $ forever $ do |
151 | readChan levelChanges >>= swapMVar level | 150 | readChan levelChanges >>= swapMVar level |
152 | return () | 151 | return () |
@@ -171,7 +170,7 @@ onStateFile file initial action = do | |||
171 | False -> removeFile file | 170 | False -> removeFile file |
172 | releaseDir = case dirExists of | 171 | releaseDir = case dirExists of |
173 | True -> return () | 172 | True -> return () |
174 | False -> removeFile directory | 173 | False -> removeDirectory directory |
175 | acquire = acquireFile | 174 | acquire = acquireFile |
176 | release = releaseFile >> releaseDir | 175 | release = releaseFile >> releaseDir |
177 | bracket_ acquire release action | 176 | bracket_ acquire release action |