satisfy :: MonadIO m => (a -> Bool) -> ConduitParser a m a
satisfy pred = do
tId <- liftIO myThreadId
timeoutThread <- liftIO $ forkIO $ do
threadDelay 1000000
throwTo tId TimeoutException
x <- await
liftIO $ killThread timeoutThread
if pred x
then return x
else empty
However I would rather not deal with the risks involved with handling concurrency myself and use a system library like System.Timeout:
satisfy :: MonadIO m => (a -> Bool) -> ConduitParser a m a
satisfy pred = do
x <- timeout 1000000 await
if pred x
then return x
else empty