]> woffs.de Git - fd/haskell-amqp-utils.git/commitdiff
simplify printparam use
authorFrank Doepper <[email protected]>
Fri, 6 Dec 2019 21:41:21 +0000 (22:41 +0100)
committerFrank Doepper <[email protected]>
Fri, 6 Dec 2019 21:41:21 +0000 (22:41 +0100)
Network/AMQP/Utils/Connection.hs
Network/AMQP/Utils/Helpers.hs
agitprop.hs
konsum.hs

index 24a25e2a7136cf869cef9e6d5dab713063d4dbe4..327878c04a9ee42d7fb08900e958064eb926e912 100644 (file)
@@ -18,7 +18,7 @@ import System.X509
 connect :: Args -> IO (Connection, Channel)
 connect args = do
   printparam "server" $ server args
-  printparam "port" $ show $ port args
+  printparam "port" $ port args
   printparam "vhost" $ vHost args
   printparam "connection_name" $ connectionName args
   printparam "connect timeout" $ (show (connect_timeout args)) ++ "s"
index a6db9ea269515da98ae355107e2c848f2192fcc6..6e135158cc3d4e4e93c34f7e7431befd7941bc24 100644 (file)
@@ -36,9 +36,24 @@ class Flexprint a where
 instance Flexprint (Maybe String) where
   flexprint = fmap (hPutStrLn stderr)
 
+instance Flexprint (Maybe Int) where
+  flexprint = fmap (hPutStrLn stderr . show)
+
 instance Flexprint String where
   flexprint x = flexprint (Just x)
 
+instance Flexprint [String] where
+  flexprint = flexprint . unwords
+
+instance Flexprint Bool where
+  flexprint = flexprint . show
+
+instance  Flexprint Int where
+  flexprint = flexprint . show
+
+instance Flexprint T.Text where
+  flexprint = flexprint . T.unpack
+
 -- | optional or required parameters
 printparam :: Flexprint a => String -> a -> IO ()
 printparam labl x = printwithlabel labl $ flexprint x
index a34aec09caa2dd068775d5bb51b695146433e0ef..95cad414369f671980647656b2e6faa0e2ef8f79 100644 (file)
@@ -47,7 +47,7 @@ main = do
            else ""
   (conn, chan) <- connect args
   addChannelExceptionHandler chan (X.throwTo tid)
-  printparam "confirm mode" $ show $ confirm args
+  printparam "confirm mode" $ confirm args
   if (confirm args)
     then do
       confirmSelect chan False
index d00954f85a520cfd190e02f971f28cc9c09aa1f6..a68acb8dc801d4f3a73fb76cdf785a061f4de35e 100644 (file)
--- a/konsum.hs
+++ b/konsum.hs
@@ -22,7 +22,7 @@ main = do
   (conn, chan) <- connect args
   addChannelExceptionHandler chan (X.throwTo tid)
   -- set prefetch
-  printparam "prefetch" $ show $ preFetch args
+  printparam "prefetch" $ preFetch args
   qos chan 0 (fromIntegral $ preFetch args) False
   -- attach to given queue? or build exclusive queue and bind it?
   queue <-
@@ -30,11 +30,11 @@ main = do
       (tempQueue chan (tmpQName args) (bindings args) (currentExchange args))
       (return)
       (fmap T.pack (qName args))
-  printparam "queue name" $ T.unpack queue
-  printparam "shown body chars" $ fmap show $ anRiss args
+  printparam "queue name" queue
+  printparam "shown body chars" $ anRiss args
   printparam "temp dir" $ tempDir args
   printparam "callback" $ fileProcess args
-  printparam "callback args" $ listToMaybeUnwords addiArgs
+  printparam "callback args" $ addiArgs
   -- subscribe to the queue
   ctag <-
     consumeMsgs
don't click here