diff --git a/src/Colourista/IO.hs b/src/Colourista/IO.hs index 7160cf5..9171b0d 100644 --- a/src/Colourista/IO.hs +++ b/src/Colourista/IO.hs @@ -30,12 +30,14 @@ module Colourista.IO , italicMessage -- * General purpose , formattedMessage + , formattedErrorMessage ) where #if __GLASGOW_HASKELL__ < 804 import Data.Semigroup (Semigroup (..)) #endif import Data.Text (Text) +import System.IO (stderr) import qualified Data.Text.IO as TIO @@ -126,7 +128,7 @@ warningMessage t = yellowMessage $ " ⚠ " <> t <> -} errorMessage :: Text -> IO () -errorMessage t = redMessage $ " \128721 " <> t +errorMessage t = formattedErrorMessage [Colourista.red] $ " \128721 " <> t {-# INLINE errorMessage #-} ---------------------------------------------------------------------------- @@ -156,3 +158,9 @@ list, no formatting is applied. formattedMessage :: [Text] -> Text -> IO () formattedMessage formatting = TIO.putStrLn . Colourista.formatWith formatting {-# INLINE formattedMessage #-} + +{- | A variant of 'formattedMessage' that writes to 'stderr' +-} +formattedErrorMessage :: [Text] -> Text -> IO () +formattedErrorMessage formatting = TIO.hPutStrLn stderr . Colourista.formatWith formatting +{-# INLINE formattedErrorMessage #-}