module Basement.Environment
    ( getArgs
    , lookupEnv
    ) where

import           Basement.Compat.Base
import           Basement.UTF8.Base (String)
import qualified System.Environment as Sys (getArgs, lookupEnv)

-- | Returns a list of the program's command line arguments (not including the program name).
getArgs :: IO [String]
getArgs :: IO [String]
getArgs = (String -> String) -> [String] -> [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> String
forall l. IsList l => [Item l] -> l
fromList ([String] -> [String]) -> IO [String] -> IO [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO [String]
Sys.getArgs

-- | Lookup variable in the environment
lookupEnv :: String -> IO (Maybe String)
lookupEnv :: String -> IO (Maybe String)
lookupEnv String
s = (String -> String) -> Maybe String -> Maybe String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> String
forall l. IsList l => [Item l] -> l
fromList (Maybe String -> Maybe String)
-> IO (Maybe String) -> IO (Maybe String)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> IO (Maybe String)
Sys.lookupEnv (String -> [Item String]
forall l. IsList l => l -> [Item l]
toList String
s)