Add SessionConfig
[opengl.git] / src / Language / Haskell / LSP / Test / Compat.hs
1 {-# LANGUAGE CPP #-}
2 -- For some reason ghc warns about not using
3 -- Control.Monad.IO.Class but it's needed for
4 -- MonadIO
5 {-# OPTIONS_GHC -Wunused-imports #-}
6 module Language.Haskell.LSP.Test.Compat where
7
8 import Control.Concurrent.Chan
9 import Control.Monad.IO.Class
10 import Data.Conduit
11
12 #ifdef mingw32_HOST_OS
13
14 import qualified System.Win32.Process as P (getCurrentProcessId)
15 getProcessID :: IO Int
16 getProcessID = fromIntegral <$> P.getCurrentProcessId
17
18 #else
19
20 import qualified System.Posix.Process as P (getProcessID)
21 getProcessID :: IO Int
22 getProcessID = fromIntegral <$> P.getProcessID
23
24 #endif
25
26 #if MIN_VERSION_conduit(1,3,0)
27 chanSource :: MonadIO m => Chan o -> ConduitT i o m b
28 #else
29 chanSource :: MonadIO m => Chan o -> ConduitM i o m b
30 #endif
31 chanSource c = do
32   x <- liftIO $ readChan c
33   yield x
34   chanSource c
35