never executed always true always false
    1 module PureClaw.Handles.Channel
    2   ( -- * Message types
    3     IncomingMessage (..)
    4   , OutgoingMessage (..)
    5     -- * Handle type
    6   , ChannelHandle (..)
    7     -- * Implementations
    8   , mkNoOpChannelHandle
    9   ) where
   10 
   11 import Data.Text (Text)
   12 
   13 import PureClaw.Core.Errors
   14 import PureClaw.Core.Types
   15 
   16 -- | A message received from a channel user.
   17 data IncomingMessage = IncomingMessage
   18   { _im_userId  :: UserId
   19   , _im_content :: Text
   20   }
   21   deriving stock (Show, Eq)
   22 
   23 -- | A message to send to a channel user.
   24 newtype OutgoingMessage = OutgoingMessage
   25   { _om_content :: Text
   26   }
   27   deriving stock (Show, Eq)
   28 
   29 -- | Channel communication capability interface. Concrete implementations
   30 -- (CLI, Telegram, Signal) live in @PureClaw.Channels.*@ modules.
   31 --
   32 -- 'sendError' only accepts 'PublicError' — internal errors with stack
   33 -- traces or model names cannot be sent to channel users. This is enforced
   34 -- at the type level.
   35 data ChannelHandle = ChannelHandle
   36   { _ch_receive   :: IO IncomingMessage
   37   , _ch_send      :: OutgoingMessage -> IO ()
   38   , _ch_sendError :: PublicError -> IO ()
   39   }
   40 
   41 -- | No-op channel handle. Receive returns an empty message, send and
   42 -- sendError are silent.
   43 mkNoOpChannelHandle :: ChannelHandle
   44 mkNoOpChannelHandle = ChannelHandle
   45   { _ch_receive   = pure (IncomingMessage (UserId "") "")
   46   , _ch_send      = \_ -> pure ()
   47   , _ch_sendError = \_ -> pure ()
   48   }