From a65254a5b7a5312bc616d601737f8595b14279ef Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Sat, 9 Jun 2018 23:34:44 -0400 Subject: [PATCH] Compatibility with GHC 8.2.1 --- src/Language/Haskell/LSP/Test/Compat.hs | 14 +++++++++++++- src/Language/Haskell/LSP/Test/Parsing.hs | 7 +------ 2 files changed, 14 insertions(+), 7 deletions(-) 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 -- 2.30.2