+import Language.Haskell.LSP.Test.Session
+import System.Console.ANSI
+
+satisfy :: (MonadIO m, MonadSessionConfig m) => (FromServerMessage -> Bool) -> ConduitParser FromServerMessage m FromServerMessage
+satisfy pred = do
+ timeout <- timeout <$> lift sessionConfig
+ tId <- liftIO myThreadId
+ timeoutThread <- liftIO $ forkIO $ do
+ threadDelay (timeout * 1000000)
+ throwTo tId TimeoutException
+ x <- await
+ liftIO $ killThread timeoutThread
+
+ if pred x
+ then do
+ liftIO $ do
+ setSGR [SetColor Foreground Vivid Magenta]
+ putStrLn $ "<-- " ++ B.unpack (encodeMsg x)
+ setSGR [Reset]
+ return x
+ else empty