gdritter repos hatch / master src / Util.hs
master

Tree @master (Download .tar.gz)

Util.hs @masterraw · history · blame

{-# LANGUAGE OverloadedStrings #-}

module Util
( printErr
) where

import           Control.Monad (when)
import qualified System.Posix.Terminal as Unix
import qualified System.Posix.IO as Unix

printErr :: String -> IO ()
printErr msg = do
  isTTY <- Unix.queryTerminal Unix.stdOutput
  when isTTY $ putStr "\x1b[91m"
  putStr msg
  when isTTY $ putStr "\x1b[39m"
  putStrLn ""