
Now that ghc 9.0.2 is the oldest supported version. Eg cruft from https://web.archive.org/web/20190424185034/https://prime.haskell.org/wiki/Libraries/Proposals/SemigroupMonoid Sponsored-by: Jack Hill
23 lines
504 B
Haskell
23 lines
504 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 Data.Maybe
|
|
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
|