Open nikita-volkov opened 10 years ago
I suggest to use MonadPlus instances instead of throwing IOError. E.g.:
MonadPlus
IOError
fromSocketTimeout :: (MonadIO m, MonadPlus m) => Int -> Socket.Socket -> Int -> Producer' BS m () fromSocketTimeout wait sock nbytes = loop where loop = do mbs <- liftIO (timeout wait (Network.Socket.ByteString.recv sock nbytes)) case mbs of Just bs | ByteString.null bs -> return () | otherwise -> yield bs >> loop Nothing -> mzero
I suggest to use
MonadPlus
instances instead of throwingIOError
. E.g.: