socketReader :: Handle -> Bot s a
socketReader sock = do
  inQ <- use inQueue
  debugMsg "starting socketReader"
  forever $ do
    debugMsg "waiting for socket input..."
    line <- liftIO (BS.hGetLine sock)
    debugMsgByteString line
    case feed (toIRCMsg line) "" of
      Partial _ -> debugMsg "impossible partial result"
      Fail _ context errMsg ->
        debugMsg $ "parse error: " <> show context <> " " <> errMsg 
      Done leftover msg -> do
        debugMsg $ "Sending message to input queue: " <> show msg
        --putStrLn . show $ msg
        --unless (BS.null leftover) . BS.hPutStrLn stderr 
        --  $ "socketReader: warning: leftovers when parsing: " <> leftover
        writeChan inQ msg
  
-- |Indefinitely read IRC messages from the bot output queue, serialize them, and write them to the given handle
socketReader :: Handle -> Bot s a
socketReader sock = do
  inQ <- use inQueue
  debugMsg "starting socketReader"
  forever $ do
    debugMsg "waiting for socket input..."
    line <- liftIO (BS.hGetLine sock)
    debugMsgByteString line
    case feed (toIRCMsg line) "" of
      Partial _ -> debugMsg "impossible partial result"
      Fail _ context errMsg ->
        debugMsg $ "parse error: " <> show context <> " " <> errMsg 
      Done leftover msg -> do
        debugMsg $ "Sending message to input queue: " <> show msg
        --putStrLn . show $ msg
        --unless (BS.null leftover) . BS.hPutStrLn stderr 
        --  $ "socketReader: warning: leftovers when parsing: " <> leftover
        writeChan inQ msg
  
-- |Indefinitely read IRC messages from the bot output queue, serialize them, and write them to the given handle
socketReader sock = do
  inQ <- use inQueue
  debugMsg "starting socketReader"
  forever $ do
    debugMsg "waiting for socket input..."
    line <- liftIO (BS.hGetLine sock)
    debugMsgByteString line
    case feed (toIRCMsg line) "" of
      Partial _ -> debugMsg "impossible partial result"
      Fail _ context errMsg ->
        debugMsg $ "parse error: " <> show context <> " " <> errMsg 
      Done leftover msg -> do
        debugMsg $ "Sending message to input queue: " <> show msg
        --putStrLn . show $ msg
        --unless (BS.null leftover) . BS.hPutStrLn stderr 
        --  $ "socketReader: warning: leftovers when parsing: " <> leftover
        writeChan inQ msg
  
-- |Indefinitely read IRC messages from the bot output queue, serialize them, and write them to the given handle