From 72085dec92059c314cd822e4adbb296ca9ad6def Mon Sep 17 00:00:00 2001 From: Pi3r Date: Wed, 4 Oct 2017 09:53:19 +0200 Subject: [PATCH] Add `putErrLn` to match `putStrLn` (#67) * Add `putErrLn` to match `putStrLn` Fix #66 * Add putErr for the most usual inference case * Rename `putErr` into `putErrText` In order to allow further specializations in the future if necessary. --- src/Protolude/Show.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Protolude/Show.hs b/src/Protolude/Show.hs index a069c8888..f6a190d94 100644 --- a/src/Protolude/Show.hs +++ b/src/Protolude/Show.hs @@ -8,6 +8,7 @@ module Protolude.Show ( Print(..), putText, + putErrText, putLText, putByteString, putLByteString, @@ -27,7 +28,7 @@ import qualified Data.Text.IO as T import qualified Data.Text.Lazy as TL import qualified Data.Text.Lazy.IO as TL -import System.IO (Handle, stdout) +import System.IO (Handle, stdout, stderr) class Print a where @@ -37,6 +38,8 @@ class Print a where hPutStrLn :: MonadIO m => Handle -> a -> m () putStrLn :: MonadIO m => a -> m () putStrLn = hPutStrLn stdout + putErrLn :: MonadIO m => a -> m () + putErrLn = hPutStrLn stderr instance Print T.Text where hPutStr = \h -> liftIO . T.hPutStr h @@ -74,3 +77,7 @@ putByteString = putStrLn putLByteString :: MonadIO m => BL.ByteString -> m () putLByteString = putStrLn {-# SPECIALIZE putLByteString :: BL.ByteString -> Base.IO () #-} + +putErrText :: MonadIO m => T.Text -> m () +putErrText = putErrLn +{-# SPECIALIZE putErrText :: T.Text -> Base.IO () #-}