never executed always true always false
    1 module PureClaw.Channels.CLI
    2   ( -- * CLI channel
    3     mkCLIChannelHandle
    4   ) where
    5 
    6 import Data.Text qualified as T
    7 import Data.Text.IO qualified as TIO
    8 import System.IO
    9 
   10 import PureClaw.Core.Types
   11 import PureClaw.Handles.Channel
   12 
   13 -- | Create a channel handle that reads from stdin and writes to stdout.
   14 -- Receive prints a @>@ prompt and reads a line. EOF (Ctrl-D) causes
   15 -- an 'IOError' which the agent loop catches to exit cleanly.
   16 mkCLIChannelHandle :: ChannelHandle
   17 mkCLIChannelHandle = ChannelHandle
   18   { _ch_receive = do
   19       putStr "> "
   20       hFlush stdout
   21       line <- TIO.getLine
   22       pure IncomingMessage
   23         { _im_userId  = UserId "cli-user"
   24         , _im_content = line
   25         }
   26   , _ch_send = \msg -> do
   27       TIO.putStrLn ""
   28       TIO.putStrLn (_om_content msg)
   29       TIO.putStrLn ""
   30   , _ch_sendError = \err ->
   31       TIO.hPutStrLn stderr $ "Error: " <> T.pack (show err)
   32   }