module HR.Monad.Terminal
(
MonadTerminal(..)
) where
import qualified System.Console.Terminal.Size as TS
import Data.Text (Text)
import qualified Data.Text.IO as TIO
class Monad m => MonadTerminal m where
getWidth :: m (Maybe Int)
putStrLn :: Text -> m ()
instance MonadTerminal IO where
getWidth :: IO (Maybe Int)
getWidth = (Window Int -> Int) -> Maybe (Window Int) -> Maybe Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Window Int -> Int
forall a. Window a -> a
TS.width (Maybe (Window Int) -> Maybe Int)
-> IO (Maybe (Window Int)) -> IO (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO (Maybe (Window Int))
forall n. Integral n => IO (Maybe (Window n))
TS.size
{-# INLINE getWidth #-}
putStrLn :: Text -> IO ()
putStrLn = Text -> IO ()
TIO.putStrLn
{-# INLINE putStrLn #-}