]> woffs.de Git - fd/haskell-amqp-utils.git/commitdiff
flexprint default with show
authorFrank Doepper <[email protected]>
Sat, 7 Dec 2019 17:30:19 +0000 (18:30 +0100)
committerFrank Doepper <[email protected]>
Sat, 7 Dec 2019 17:30:19 +0000 (18:30 +0100)
Network/AMQP/Utils/Helpers.hs

index de07d1002360db3691b693a786c8d5bfe0db8341..8037b0beaa2bad4cb8eb943367baf18acc368375 100644 (file)
@@ -17,9 +17,11 @@ import System.Exit
 import System.IO
 import System.Process
 
-class Flexprint a where
+class (Show a) =>
+      Flexprint a
+  where
   flexprint :: a -> IO ()
-  flexprint _ = return ()
+  flexprint = (hPutStrLn stderr) . show
   printparam :: String -> a -> IO ()
   printparam label x = do
     mapM_ (hPutStr stderr) [" --- ", label, ": "]
@@ -36,20 +38,17 @@ instance Flexprint String where
 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
 
 instance Flexprint BL.ByteString where
   flexprint x = hPutStrLn stderr "" >> BL.hPut stderr x >> hPutStrLn stderr ""
 
-instance Flexprint ExitCode where
-  flexprint = flexprint . show
+instance Flexprint Bool
+
+instance Flexprint Int
+
+instance Flexprint ExitCode
 
 -- | log marker
 hr :: String -> IO ()
don't click here