diff options
Diffstat (limited to 'System/Posix/Env/ByteString.hsc')
-rw-r--r-- | System/Posix/Env/ByteString.hsc | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/System/Posix/Env/ByteString.hsc b/System/Posix/Env/ByteString.hsc index c6c374c..3ce867b 100644 --- a/System/Posix/Env/ByteString.hsc +++ b/System/Posix/Env/ByteString.hsc @@ -45,7 +45,9 @@ import Data.ByteString (ByteString) -- |'getEnv' looks up a variable in the environment. -getEnv :: ByteString -> IO (Maybe ByteString) +getEnv :: + ByteString {- ^ variable name -} -> + IO (Maybe ByteString) {- ^ variable value -} getEnv name = do litstring <- B.useAsCString name c_getenv if litstring /= nullPtr @@ -56,7 +58,10 @@ getEnv name = do -- programmer can specify a fallback if the variable is not found -- in the environment. -getEnvDefault :: ByteString -> ByteString -> IO ByteString +getEnvDefault :: + ByteString {- ^ variable name -} -> + ByteString {- ^ fallback value -} -> + IO ByteString {- ^ variable value or fallback value -} getEnvDefault name fallback = liftM (fromMaybe fallback) (getEnv name) foreign import ccall unsafe "getenv" @@ -86,7 +91,7 @@ foreign import ccall unsafe "&environ" -- |'getEnvironment' retrieves the entire environment as a -- list of @(key,value)@ pairs. -getEnvironment :: IO [(ByteString,ByteString)] +getEnvironment :: IO [(ByteString,ByteString)] {- ^ @[(key,value)]@ -} getEnvironment = do env <- getEnvironmentPrim return $ map (dropEq.(BC.break ((==) '='))) env @@ -98,7 +103,7 @@ getEnvironment = do -- |The 'unsetEnv' function deletes all instances of the variable name -- from the environment. -unsetEnv :: ByteString -> IO () +unsetEnv :: ByteString {- ^ variable name -} -> IO () #if HAVE_UNSETENV # if !UNSETENV_RETURNS_VOID unsetEnv name = B.useAsCString name $ \ s -> @@ -121,7 +126,7 @@ unsetEnv name = putEnv (name ++ "=") -- |'putEnv' function takes an argument of the form @name=value@ -- and is equivalent to @setEnv(key,value,True{-overwrite-})@. -putEnv :: ByteString -> IO () +putEnv :: ByteString {- ^ "key=value" -} -> IO () putEnv keyvalue = B.useAsCString keyvalue $ \s -> throwErrnoIfMinus1_ "putenv" (c_putenv s) @@ -135,7 +140,11 @@ foreign import ccall unsafe "putenv" not reset, otherwise it is reset to the given value. -} -setEnv :: ByteString -> ByteString -> Bool {-overwrite-} -> IO () +setEnv :: + ByteString {- ^ variable name -} -> + ByteString {- ^ variable value -} -> + Bool {- ^ overwrite -} -> + IO () #ifdef HAVE_SETENV setEnv key value ovrwrt = do B.useAsCString key $ \ keyP -> |