{-# LANGUAGE GeneralizedNewtypeDeriving #-} module Data.Cursor.CLASE.Gen.PrintM where import Control.Monad import Control.Monad.Reader import System.IO newtype PrintM a = PrintM { runPrintM :: ReaderT Handle IO a } deriving Monad runPrint :: Handle -> PrintM a -> IO a runPrint h = flip runReaderT h . runPrintM printLn :: String -> PrintM () printLn s = PrintM $ (ask >>= liftIO . flip hPutStrLn s) printLns :: [String] -> PrintM () printLns s = PrintM $ (ask >>= liftIO . flip hPutStr (unlines s))