{-# LANGUAGE CPP #-}
-
module Language.Haskell.LSP.Test.Compat where
+import Control.Concurrent.Chan
+import Control.Monad.IO.Class
+import Data.Conduit
#ifdef mingw32_HOST_OS
getProcessID = fromIntegral <$> P.getProcessID
#endif
+
+#if MIN_VERSION_conduit(1,3,0)
+chanSource :: MonadIO m => Chan o -> ConduitT i o m b
+#else
+chanSource :: MonadIO m => Chan o -> ConduitM i o m b
+#endif
+chanSource c = do
+ x <- liftIO $ readChan c
+ yield x
+ chanSource c
import Data.Maybe
import Language.Haskell.LSP.Messages
import Language.Haskell.LSP.Types
+import Language.Haskell.LSP.Test.Compat
import Language.Haskell.LSP.Test.Decoding
import Language.Haskell.LSP.Test.Messages
import System.IO
then return x
else empty
-chanSource :: MonadIO m => Chan o -> ConduitT i o m b
-chanSource c = do
- x <- liftIO $ readChan c
- yield x
- chanSource c
-
runSession' :: Chan FromServerMessage -> SessionContext -> SessionState -> Session a -> IO (a, SessionState)
runSession' chan context state session = runReaderT (runStateT conduit state) context
where conduit = runConduit $ chanSource chan .| runConduitParser session