From: Luke Lau Date: Sun, 10 Jun 2018 03:34:44 +0000 (-0400) Subject: Compatibility with GHC 8.2.1 X-Git-Tag: 0.1.0.0~76^2~1 X-Git-Url: http://git.lukelau.me/?p=lsp-test.git;a=commitdiff_plain;h=a65254a5b7a5312bc616d601737f8595b14279ef Compatibility with GHC 8.2.1 --- diff --git a/src/Language/Haskell/LSP/Test/Compat.hs b/src/Language/Haskell/LSP/Test/Compat.hs index 00f2c0b..cd7de08 100644 --- a/src/Language/Haskell/LSP/Test/Compat.hs +++ b/src/Language/Haskell/LSP/Test/Compat.hs @@ -1,7 +1,9 @@ {-# 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 @@ -16,3 +18,13 @@ getProcessID :: IO Int 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 diff --git a/src/Language/Haskell/LSP/Test/Parsing.hs b/src/Language/Haskell/LSP/Test/Parsing.hs index 2e829f3..49c24c9 100644 --- a/src/Language/Haskell/LSP/Test/Parsing.hs +++ b/src/Language/Haskell/LSP/Test/Parsing.hs @@ -18,6 +18,7 @@ import Data.Conduit.Parser 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 @@ -108,12 +109,6 @@ satisfy pred = do 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