8ea5f3ff99
Eliminated some dead code. In other cases, exported a currently unused function, since it was a logical part of the API. Of course this improves the API documentation. It may also sometimes let ghc optimize code better, since it can know a function is internal to a module. 364 modules still to go, according to git grep -E 'module [A-Za-z.]+ where'
25 lines
546 B
Haskell
25 lines
546 B
Haskell
{- portable environment variables, without any dependencies
|
|
-
|
|
- Copyright 2013 Joey Hess <id@joeyh.name>
|
|
-
|
|
- License: BSD-2-clause
|
|
-}
|
|
|
|
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
|
|
|
module Utility.Env.Basic (
|
|
getEnv,
|
|
getEnvDefault,
|
|
) where
|
|
|
|
import Utility.Exception
|
|
import Control.Applicative
|
|
import Data.Maybe
|
|
import Prelude
|
|
import qualified System.Environment as E
|
|
|
|
getEnv :: String -> IO (Maybe String)
|
|
getEnv = catchMaybeIO . E.getEnv
|
|
|
|
getEnvDefault :: String -> String -> IO String
|
|
getEnvDefault var fallback = fromMaybe fallback <$> getEnv var
|