aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2019-01-27 18:54:07 +0100
committertv <tv@krebsco.de>2019-01-27 18:54:07 +0100
commitf91b27cf8dce8a92c0b296209323a79cc1e36873 (patch)
treea2f926dc037101b169f24083c82e5c80c8ae45c7
parent4d85ce5584c5bc69b402b7d3b94c623f37ea69f5 (diff)
Reaktor: use forM_ like whenJust
-rw-r--r--src/Reaktor.hs17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/Reaktor.hs b/src/Reaktor.hs
index 34baadb..042fcfe 100644
--- a/src/Reaktor.hs
+++ b/src/Reaktor.hs
@@ -10,6 +10,7 @@ module Reaktor
import Blessings.Text
import Control.Concurrent.Extended
import Control.Exception
+import Control.Monad (forM_)
import Data.Attoparsec.Text (feed,parse)
import Data.Attoparsec.Text (IResult(Done,Fail,Partial))
import Data.ByteString (ByteString)
@@ -71,11 +72,9 @@ run Config{..} getPlugins =
aSend msg = logMsg msg >> putOutMsg msg
logMsg msg =
- case logMsgFilter msg of
- Just msg' -> do
- let bs = formatMessage msg'
- aLog $ SGR [38,5,235] "> " <> SGR [35,1] (Plain bs)
- Nothing -> return ()
+ forM_ (logMsgFilter msg) $ \msg' -> do
+ let bs = formatMessage msg'
+ aLog $ SGR [38,5,235] "> " <> SGR [35,1] (Plain bs)
mapM_ (\(s, f) -> installHandler s (Catch f) Nothing) [
(sigINT, shutdown)
@@ -143,11 +142,9 @@ receiver Actions{..} putInMsg sockRecv =
logErr s = aLog $ SGR [31,1] ("! receive: " <> s)
logMsg msg =
- case logMsgFilter msg of
- Just msg' -> do
- let bs = formatMessage msg'
- aLog $ SGR [38,5,235] "< " <> SGR [38,5,244] (Plain bs)
- Nothing -> return ()
+ forM_ (logMsgFilter msg) $ \msg' -> do
+ let bs = formatMessage msg'
+ aLog $ SGR [38,5,235] "< " <> SGR [38,5,244] (Plain bs)
sender :: IO Message -> (ByteString -> IO ()) -> IO ()