Add logColor config option
[lsp-test.git] / src / Language / Haskell / LSP / Test / Parsing.hs
index 3ecc53888b31f5090b64344a866d512b5dd1460b..b6830357db5b32144f9629d900d5f42b91f64196 100644 (file)
@@ -19,7 +19,6 @@ import Language.Haskell.LSP.Messages
 import Language.Haskell.LSP.Types as LSP hiding (error)
 import Language.Haskell.LSP.Test.Messages
 import Language.Haskell.LSP.Test.Session
-import System.Console.ANSI
 
 satisfy :: (FromServerMessage -> Bool) -> Session FromServerMessage
 satisfy pred = do
@@ -42,10 +41,7 @@ satisfy pred = do
 
   if pred x
     then do
-      liftIO $ do
-        setSGR [SetColor Foreground Vivid Magenta]
-        putStrLn $ "<-- " ++ B.unpack (encodeMsg x)
-        setSGR [Reset]
+      logMsg LogServer x
       return x
     else empty
 
@@ -53,9 +49,8 @@ satisfy pred = do
 message :: forall a. (Typeable a, FromJSON a) => Session a
 message =
   let parser = decode . encodeMsg :: FromServerMessage -> Maybe a
-  in named (T.pack $ show $ head $ snd $ splitTyConApp $ last $ typeRepArgs $ typeOf parser) $ do
-    x <- satisfy (isJust . parser)
-    return $ castMsg x
+  in named (T.pack $ show $ head $ snd $ splitTyConApp $ last $ typeRepArgs $ typeOf parser) $
+    castMsg <$> satisfy (isJust . parser)
 
 -- | Matches if the message is a notification.
 anyNotification :: Session FromServerMessage