2 -- For some reason ghc warns about not using
3 -- Control.Monad.IO.Class but it's needed for
5 {-# OPTIONS_GHC -Wunused-imports #-}
6 module Language.Haskell.LSP.Test.Compat where
8 import Control.Concurrent.Chan
9 import Control.Monad.IO.Class
13 #if MIN_VERSION_process(1,6,3)
14 import System.Process hiding (getPid)
15 import qualified System.Process (getPid)
18 import System.Process.Internals
19 import Control.Concurrent.MVar
22 #ifdef mingw32_HOST_OS
23 import qualified System.Win32.Process
25 import qualified System.Posix.Process
29 getCurrentProcessID :: IO Int
30 #ifdef mingw32_HOST_OS
31 getCurrentProcessID = fromIntegral <$> System.Win32.Process.getCurrentProcessId
33 getCurrentProcessID = fromIntegral <$> System.Posix.Process.getProcessID
36 getProcessID :: ProcessHandle -> IO Int
37 getProcessID p = fromIntegral . fromJust <$> getProcessID' p
39 #if MIN_VERSION_process(1,6,3)
40 getProcessID' = System.Process.getPid
42 getProcessID' (ProcessHandle mh _ _) = do
45 #ifdef mingw32_HOST_OS
47 pid <- System.Win32.Process.getProcessId h
50 OpenHandle pid -> return $ Just pid
55 #if MIN_VERSION_conduit(1,3,0)
56 chanSource :: MonadIO m => Chan o -> ConduitT i o m b
58 chanSource :: MonadIO m => Chan o -> ConduitM i o m b
61 x <- liftIO $ readChan c