aboutsummaryrefslogtreecommitdiff
path: root/src/CabalHelper/Compiletime/Compat/Environment.hs
blob: 535bcc6939b18c3b4b99169e83f38a032b652667 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{-# LANGUAGE CPP #-}
module CabalHelper.Compiletime.Compat.Environment where

import qualified System.Environment
#ifndef mingw32_HOST_OS
import qualified System.Posix.Env (setEnv)
#endif

lookupEnv :: String -> IO (Maybe String)
lookupEnv var =
  do env <- System.Environment.getEnvironment
     return (lookup var env)

setEnv :: String -> String -> IO ()
#ifdef mingw32_HOST_OS
setEnv = System.Environment.setEnv
#else
setEnv k v = System.Posix.Env.setEnv k v True
#endif