    {- 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 where

    import Utility.Exception
    import Control.Applicative
    import Data.Maybe
    import Prelude
    import qualified System.Environment as E

    getEnv :: String -> IO (Maybe String)
    getEnv :: String -> IO (Maybe String)
    getEnv = IO String -> IO (Maybe String)
    forall (m :: * -> *) a. MonadCatch m => m a -> m (Maybe a)
    catchMaybeIO (IO String -> IO (Maybe String))
    -> (String -> IO String) -> String -> IO (Maybe String)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> IO String
    E.getEnv

    getEnvDefault :: String -> String -> IO String
    getEnvDefault :: String -> String -> IO String
    getEnvDefault var :: String
    var fallback :: String
    fallback = String -> Maybe String -> String
    forall a. a -> Maybe a -> a
    fromMaybe String
    fallback (Maybe String -> String) -> IO (Maybe String) -> IO String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> String -> IO (Maybe String)
    getEnv String
    var