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 | |
parent | 3a69e87a90d494aff3d187de2174cc1e92c331b0 (diff) | |
download | trivmix-3576f981b8e1ea2e23dafc6351c52e614b0dc13c.tar trivmix-3576f981b8e1ea2e23dafc6351c52e614b0dc13c.tar.gz trivmix-3576f981b8e1ea2e23dafc6351c52e614b0dc13c.tar.bz2 trivmix-3576f981b8e1ea2e23dafc6351c52e614b0dc13c.tar.xz trivmix-3576f981b8e1ea2e23dafc6351c52e614b0dc13c.zip |
code cleanup
-rw-r--r-- | src/Trivmix.hs | 5 | ||||
-rw-r--r-- | trivmix.cabal | 2 |
2 files changed, 3 insertions, 4 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 |
diff --git a/trivmix.cabal b/trivmix.cabal index c986fe2..933f01b 100644 --- a/trivmix.cabal +++ b/trivmix.cabal | |||
@@ -2,7 +2,7 @@ | |||
2 | -- documentation, see http://haskell.org/cabal/users-guide/ | 2 | -- documentation, see http://haskell.org/cabal/users-guide/ |
3 | 3 | ||
4 | name: trivmix | 4 | name: trivmix |
5 | version: 2.1.0 | 5 | version: 2.2.0 |
6 | -- synopsis: | 6 | -- synopsis: |
7 | -- description: | 7 | -- description: |
8 | license: PublicDomain | 8 | license: PublicDomain |