ai-agent-diff-patch-0.0.1.0: src/AIAgent/DiffPatch/Unified/Interface/StdIO.hs
{-# LANGUAGE OverloadedStrings #-}
-- | Interface layer: stdout output implementation for IOFunc._writeIOFunc.
-- Used when the caller wants diff/patch results written to stdout
-- rather than back to a file (e.g. ai-agent-diff and ai-agent-patch executables).
module AIAgent.DiffPatch.Unified.Interface.StdIO
( write
) where
import qualified Data.ByteString as BS
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import System.IO (hSetBinaryMode, stdout)
-- | Write Text to stdout as UTF-8 binary.
-- The FilePath argument is ignored; it exists only to match the
-- '_writeIOFunc :: FilePath -> T.Text -> IO ()' signature so that
-- write can be injected into IOFunc without a wrapper.
write :: FilePath -> T.Text -> IO ()
write _ txt = do
hSetBinaryMode stdout True
BS.hPutStr stdout (TE.encodeUtf8 txt)